better logic for closing the tree

This commit is contained in:
kiyan42
2020-05-30 01:55:29 +02:00
parent e4630f8782
commit 058cd31e2a
2 changed files with 8 additions and 6 deletions

View File

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