diff --git a/README.md b/README.md index 5b122818..636b23a1 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,8 @@ Plug 'kyazdani42/nvim-tree.lua' let g:lua_tree_side = 'right' | 'left' "left by default let g:lua_tree_size = 40 "30 by default let g:lua_tree_ignore = [ '.git', 'node_modules', '.cache' ] "empty by default, not working on mac atm +let g:lua_tree_auto_open = 1 "0 by default, opens the tree when typing `vim $DIR` or `vim` +let g:lua_tree_auto_close = 1 "0 by default, closes the tree when it's the last window let g:lua_tree_follow = 1 "0 by default, this option will bind BufEnter to the LuaTreeFindFile command " :help LuaTreeFindFile for more info @@ -62,6 +64,7 @@ nnoremap n :LuaTreeFindFile - Tree creation should be async - refactor all `system` call to `libuv` functions, with better error management - bufferize leafs of node being closed so when opening again the node, we open every directory that was previously open +- make config module to make it easier to add/modify user options ### Features - sneak like cd command to find a file/directory diff --git a/doc/nvim-tree-lua.txt b/doc/nvim-tree-lua.txt index 34474a43..8a46d2fa 100644 --- a/doc/nvim-tree-lua.txt +++ b/doc/nvim-tree-lua.txt @@ -57,7 +57,19 @@ Each pattern is passed into the 'ls' function as `--ignore=PATTERN` |g:lua_tree_follow| *g:lua_tree_follow* Can be `0` or `1`. When `1`, will bind |:LuaTreeFindFile| to |BufEnter| +Default is 0 +|g:lua_tree_auto_open| *g:lua_tree_auto_open* + +Can be `0` or `1`. When `1`, will bind |VimEnter| to automatically +open tree on startup if no files are specified. +Default is 0 + +|g:lua_tree_auto_close| *g:lua_tree_auto_close* + +Can be `0` or `1`. When `1`, will bind |BufEnter| to automatically +close the tree if it's the last window. +Default is 0 ============================================================================== INFORMATIONS *nvim-tree-info* diff --git a/doc/tags b/doc/tags index 057eb2db..a80e826e 100644 --- a/doc/tags +++ b/doc/tags @@ -1,6 +1,8 @@ :LuaTreeFindFile nvim-tree-lua.txt /*:LuaTreeFindFile* :LuaTreeRefresh nvim-tree-lua.txt /*:LuaTreeRefresh* :LuaTreeToggle nvim-tree-lua.txt /*:LuaTreeToggle* +g:lua_tree_auto_open nvim-tree-lua.txt /*g:lua_tree_auto_open* +g:lua_tree_auto_open nvim-tree-lua.txt /*g:lua_tree_auto_open* g:lua_tree_follow nvim-tree-lua.txt /*g:lua_tree_follow* g:lua_tree_ignore nvim-tree-lua.txt /*g:lua_tree_ignore* g:lua_tree_side nvim-tree-lua.txt /*g:lua_tree_side* diff --git a/lua/tree.lua b/lua/tree.lua index 359926c0..41ae3541 100644 --- a/lua/tree.lua +++ b/lua/tree.lua @@ -37,7 +37,8 @@ init_tree() local function toggle() if is_win_open() == true then - close() + local wins = api.nvim_list_wins() + if #wins > 1 then close() end else open() update_view() diff --git a/plugin/tree.vim b/plugin/tree.vim index 6033867b..905cf024 100644 --- a/plugin/tree.vim +++ b/plugin/tree.vim @@ -9,8 +9,14 @@ let g:loaded_netrwPlugin = 1 hi def link LuaTreePopup Normal au BufWritePost * lua require'tree'.refresh() -au BufEnter * lua require'tree'.check_windows_and_close() -au VimEnter * lua require'tree'.check_buffer_and_open() + +if get(g:, 'lua_tree_auto_close') != 0 + au BufEnter * lua require'tree'.check_windows_and_close() +endif + +if get(g:, 'lua_tree_auto_open') != 0 + au VimEnter * lua require'tree'.check_buffer_and_open() +endif " TODO set status line dynamically on bufenter in the luatree " to remove lightline and other possible components