add config to open or close automatically

This commit is contained in:
kiyan42 2020-03-04 13:15:33 +01:00
parent 03168a5155
commit 3678169bd6
5 changed files with 27 additions and 3 deletions

View File

@ -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 <leader>n :LuaTreeFindFile<CR>
- 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

View File

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

View File

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

View File

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

View File

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