mirror of
https://github.com/nvim-tree/nvim-tree.lua
synced 2024-09-16 14:34:03 +02:00
feat: add ability for the tree to change tab
- remove tags file - open/close the tree on `TabEnter` with the option `g:lua_tree_tab_open`
This commit is contained in:
parent
6a0e76edc8
commit
9eea2b8c62
6 changed files with 23 additions and 29 deletions
|
@ -34,6 +34,7 @@ let g:lua_tree_indent_markers = 1 "0 by default, this option shows indent marker
|
|||
let g:lua_tree_hide_dotfiles = 1 "0 by default, this option hides files and folders starting with a dot `.`
|
||||
let g:lua_tree_git_hl = 1 "0 by default, will enable file highlight for git attributes (can be used without the icons).
|
||||
let g:lua_tree_root_folder_modifier = ':~' "This is the default. See :help filename-modifiers for more options
|
||||
let g:lua_tree_tab_open = 1 "0 by default, will open the tree when entering a new tab and the tree was previously open
|
||||
let g:lua_tree_show_icons = {
|
||||
\ 'git': 1,
|
||||
\ 'folders': 0,
|
||||
|
|
1
doc/.gitignore
vendored
Normal file
1
doc/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
tags
|
|
@ -157,6 +157,12 @@ In what format to show root folder. See `:help filename-modifiers` for
|
|||
available options.
|
||||
Default is `:~`
|
||||
|
||||
|g:lua_tree_tab_open| *g:lua_tree_tab_open*
|
||||
|
||||
Can be 0 or 1. When 1, will open the tree when entering a new tab if the
|
||||
tree was previously open.
|
||||
Default is 0
|
||||
|
||||
==============================================================================
|
||||
INFORMATIONS *nvim-tree-info*
|
||||
|
||||
|
|
29
doc/tags
29
doc/tags
|
@ -1,29 +0,0 @@
|
|||
:LuaTreeClipboard nvim-tree-lua.txt /*:LuaTreeClipboard*
|
||||
:LuaTreeClose nvim-tree-lua.txt /*:LuaTreeClose*
|
||||
:LuaTreeFindFile nvim-tree-lua.txt /*:LuaTreeFindFile*
|
||||
:LuaTreeOpen nvim-tree-lua.txt /*:LuaTreeOpen*
|
||||
:LuaTreeRefresh nvim-tree-lua.txt /*:LuaTreeRefresh*
|
||||
:LuaTreeToggle nvim-tree-lua.txt /*:LuaTreeToggle*
|
||||
g:lua_tree_auto_close nvim-tree-lua.txt /*g:lua_tree_auto_close*
|
||||
g:lua_tree_auto_open nvim-tree-lua.txt /*g:lua_tree_auto_open*
|
||||
g:lua_tree_bindings nvim-tree-lua.txt /*g:lua_tree_bindings*
|
||||
g:lua_tree_disable_keybindings nvim-tree-lua.txt /*g:lua_tree_disable_keybindings*
|
||||
g:lua_tree_follow nvim-tree-lua.txt /*g:lua_tree_follow*
|
||||
g:lua_tree_git_hl nvim-tree-lua.txt /*g:lua_tree_git_hl*
|
||||
g:lua_tree_icons nvim-tree-lua.txt /*g:lua_tree_icons*
|
||||
g:lua_tree_ignore nvim-tree-lua.txt /*g:lua_tree_ignore*
|
||||
g:lua_tree_indent_markers nvim-tree-lua.txt /*g:lua_tree_indent_markers*
|
||||
g:lua_tree_show_icons nvim-tree-lua.txt /*g:lua_tree_show_icons*
|
||||
g:lua_tree_hide_dotfiles nvim-tree-lua.txt /*g:lua_tree_hide_dotfiles*
|
||||
g:lua_tree_side nvim-tree-lua.txt /*g:lua_tree_side*
|
||||
g:lua_tree_size nvim-tree-lua.txt /*g:lua_tree_size*
|
||||
lua_tree_highlight nvim-tree-lua.txt /*lua_tree_highlight*
|
||||
nvim-tree-commands nvim-tree-lua.txt /*nvim-tree-commands*
|
||||
nvim-tree-features nvim-tree-lua.txt /*nvim-tree-features*
|
||||
nvim-tree-highlight nvim-tree-lua.txt /*nvim-tree-highlight*
|
||||
nvim-tree-info nvim-tree-lua.txt /*nvim-tree-info*
|
||||
nvim-tree-introduction nvim-tree-lua.txt /*nvim-tree-introduction*
|
||||
nvim-tree-keybindings nvim-tree-lua.txt /*nvim-tree-keybindings*
|
||||
nvim-tree-options nvim-tree-lua.txt /*nvim-tree-options*
|
||||
nvim-tree-quickstart nvim-tree-lua.txt /*nvim-tree-quickstart*
|
||||
nvim-tree.lua nvim-tree-lua.txt /*nvim-tree.lua*
|
12
lua/tree.lua
12
lua/tree.lua
|
@ -24,6 +24,7 @@ end
|
|||
function M.close()
|
||||
if lib.win_open() then
|
||||
lib.close()
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -33,6 +34,17 @@ function M.open()
|
|||
end
|
||||
end
|
||||
|
||||
local winopts = config.window_options()
|
||||
function M.tab_change()
|
||||
-- we need defer_fn to make sure we close/open after we enter the tab
|
||||
vim.defer_fn(function()
|
||||
if M.close() then
|
||||
M.open()
|
||||
api.nvim_command('wincmd '..winopts.open_command)
|
||||
end
|
||||
end, 1)
|
||||
end
|
||||
|
||||
local function gen_go_to(mode)
|
||||
local icon_state = config.get_icon_state()
|
||||
local flags = mode == 'prev_git_item' and 'b' or ''
|
||||
|
|
|
@ -17,6 +17,9 @@ augroup LuaTree
|
|||
au VimEnter * lua require'tree'.on_enter()
|
||||
au ColorScheme * lua require'tree'.reset_highlight()
|
||||
au User FugitiveChanged lua require'tree'.refresh()
|
||||
if get(g:, 'lua_tree_tab_open') == 1
|
||||
au TabEnter * lua require'tree'.tab_change()
|
||||
endif
|
||||
augroup end
|
||||
|
||||
command! LuaTreeOpen lua require'tree'.open()
|
||||
|
|
Loading…
Reference in a new issue