config auto close for nvim-tree.lua
This commit is contained in:
parent
b12894691d
commit
fc3ad5ab30
|
@ -79,6 +79,23 @@ return {
|
|||
init = function(_)
|
||||
vim.g.loaded_netrw = 1
|
||||
vim.g.loaded_netrwPlugin = 1
|
||||
|
||||
vim.api.nvim_create_autocmd("QuitPre", {
|
||||
callback = function()
|
||||
local invalid_win = {}
|
||||
local wins = vim.api.nvim_list_wins()
|
||||
for _, w in ipairs(wins) do
|
||||
local bufname = vim.api.nvim_buf_get_name(vim.api.nvim_win_get_buf(w))
|
||||
if bufname:match("NvimTree_") ~= nil then
|
||||
table.insert(invalid_win, w)
|
||||
end
|
||||
end
|
||||
if #invalid_win == #wins - 1 then
|
||||
-- Should quit, so we close all invalid windows.
|
||||
for _, w in ipairs(invalid_win) do vim.api.nvim_win_close(w, true) end
|
||||
end
|
||||
end
|
||||
})
|
||||
end,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue