feat: add NvimTreeFindFileToggle (#735)

This commit is contained in:
figsoda 2021-10-23 09:35:28 -04:00 committed by GitHub
parent ec3f10e211
commit 514619897f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 4 deletions

View File

@ -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

View File

@ -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

View File

@ -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
@ -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