Feat: add focus on tree functionality (#563)

This commit is contained in:
颜贵彬
2021-08-14 17:06:56 +08:00
committed by GitHub
parent b8b70cf340
commit 7014b6aff4
4 changed files with 13 additions and 1 deletions

View File

@@ -115,7 +115,7 @@ let g:nvim_tree_icons = {
nnoremap <C-n> :NvimTreeToggle<CR>
nnoremap <leader>r :NvimTreeRefresh<CR>
nnoremap <leader>n :NvimTreeFindFile<CR>
" NvimTreeOpen and NvimTreeClose are also available if you need them
" NvimTreeOpen, NvimTreeClose and NvimTreeFocus are also available if you need them
set termguicolors " this variable must be enabled for colors to be applied properly

View File

@@ -33,6 +33,10 @@ closes the tree
open or close the tree
|:NvimTreeFocus| *:NvimTreeFocus*
open the tree if it is closed, and then focus on the tree
|:NvimTreeRefresh| *:NvimTreeRefresh*
refresh the tree

View File

@@ -11,6 +11,13 @@ local api = vim.api
local M = {}
function M.focus()
if not view.win_open() then
lib.open()
end
view.focus();
end
function M.toggle()
if view.win_open() then
view.close()

View File

@@ -37,6 +37,7 @@ augroup end
command! NvimTreeOpen lua require'nvim-tree'.open()
command! NvimTreeClose lua require'nvim-tree'.close()
command! NvimTreeToggle lua require'nvim-tree'.toggle()
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)