Skip to content

feat: add NvimTreeFindFileToggle #735

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ let g:nvim_tree_icons = {
nnoremap <C-n> :NvimTreeToggle<CR>
nnoremap <leader>r :NvimTreeRefresh<CR>
nnoremap <leader>n :NvimTreeFindFile<CR>
" NvimTreeOpen, NvimTreeClose, NvimTreeFocus and NvimTreeResize are also available if you need them
" NvimTreeOpen, NvimTreeClose, NvimTreeFocus, NvimTreeFindFileToggle, and NvimTreeResize are also available if you need them

set termguicolors " this variable must be enabled for colors to be applied properly

Expand Down
5 changes: 5 additions & 0 deletions doc/nvim-tree-lua.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ It will also open the leafs of the tree leading to the file in the buffer
(if you opened a file with something else than the NvimTree, like `fzf` or
`:split`)

|:NvimTreeFindFileToggle| *:NvimTreeFindFileToggle*

close the tree or change the cursor in the tree for the current bufname,
similar to combination of |:NvimTreeToggle| and |:NvimTreeFindFile|

|:NvimTreeClipboard| *:NvimTreeClipboard*

Print clipboard content for both cut and copy
Expand Down
7 changes: 4 additions & 3 deletions lua/nvim-tree.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ function M.focus()
view.focus();
end

function M.toggle()
function M.toggle(find_file)
if view.win_open() then
view.close()
else
if _config.update_focused_file.enable then
if _config.update_focused_file.enable or find_file then
M.find_file(true)
end
if not view.win_open() then
Expand Down Expand Up @@ -356,11 +356,12 @@ local function setup_vim_commands()
vim.cmd [[
command! NvimTreeOpen lua require'nvim-tree'.open()
command! NvimTreeClose lua require'nvim-tree'.close()
command! NvimTreeToggle lua require'nvim-tree'.toggle()
command! NvimTreeToggle lua require'nvim-tree'.toggle(false)
command! NvimTreeFocus lua require'nvim-tree'.focus()
command! NvimTreeRefresh lua require'nvim-tree'.refresh()
command! NvimTreeClipboard lua require'nvim-tree'.print_clipboard()
command! NvimTreeFindFile lua require'nvim-tree'.find_file(true)
command! NvimTreeFindFileToggle lua require'nvim-tree'.toggle(true)
command! -nargs=1 NvimTreeResize lua require'nvim-tree'.resize(<args>)
]]
end
Expand Down