better logic for closing the tree
This commit is contained in:
11
lua/tree.lua
11
lua/tree.lua
@@ -90,8 +90,11 @@ local function find_file()
|
||||
tree.set_index_and_redraw(bufname)
|
||||
end
|
||||
|
||||
local function on_leave()
|
||||
if #api.nvim_list_wins() == 1 and tree.win_open() then
|
||||
function M.on_leave()
|
||||
if #api.nvim_list_wins() == 2
|
||||
and tree.win_open()
|
||||
and api.nvim_get_current_buf() ~= tree.Tree.bufnr
|
||||
then
|
||||
api.nvim_command(':qa!')
|
||||
end
|
||||
end
|
||||
@@ -113,10 +116,6 @@ local function update_root_dir()
|
||||
end
|
||||
|
||||
function M.buf_enter()
|
||||
if vim.g.lua_tree_auto_close ~= 0 then
|
||||
on_leave()
|
||||
end
|
||||
|
||||
update_root_dir()
|
||||
if vim.g.lua_tree_follow ~= 0 then
|
||||
find_file()
|
||||
|
||||
@@ -11,6 +11,9 @@ hi def link LuaTreePopup Normal
|
||||
augroup LuaTree
|
||||
au BufWritePost * lua require'tree'.refresh()
|
||||
au BufEnter * lua require'tree'.buf_enter()
|
||||
if get(g:, 'lua_tree_auto_close') == 1
|
||||
au QuitPre * lua require'tree'.on_leave()
|
||||
endif
|
||||
au VimEnter * lua require'tree'.on_enter()
|
||||
au ColorScheme * lua require'tree'.reset_highlight()
|
||||
augroup end
|
||||
|
||||
Reference in New Issue
Block a user