You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.4 KiB
Lua

vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
vim.opt.termguicolors = true
local M = { "nvim-tree/nvim-tree.lua" }
1 week ago
M.tag = "nvim-tree-v1.9.0"
1 week ago
M.keys = {
{ "<leader>nt", ":NvimTreeToggle<CR>", desc = "toggle nvim tree" }
1 week ago
}
M.dependencies = {
-- https://github.com/nvim-tree/nvim-web-devicons
"nvim-tree/nvim-web-devicons", opts = {}
1 week ago
}
function M.config()
require("nvim-tree").setup()
vim.api.nvim_create_autocmd("WinClosed", {
1 week ago
nested = true,
callback = function()
M.handle_closed(tonumber(vim.fn.expand("<amatch>")))
1 week ago
end,
})
end
function M.handle_closed(window)
local tab = vim.api.nvim_win_get_tabpage(window)
local buffer = vim.api.nvim_win_get_buf(window)
local info = vim.fn.getbufinfo(buffer)[1]
local function filter_window(w)
return w ~= window
end
local windows = vim.tbl_filter(filter_window, vim.api.nvim_tabpage_list_wins(tab))
local buffers = vim.tbl_map(vim.api.nvim_win_get_buf, windows)
if info.name:match(".*NvimTree_%d*$") then
if not vim.tbl_isempty(buffers) then
require("nvim-tree.api").tree.close()
end
return
end
if #buffers ~= 1 then
return
end
local last_info = vim.fn.getbufinfo(buffers[1])[1]
if last_info.name:match(".*NvimTree_%d*$") then
vim.schedule(function()
if #vim.api.nvim_list_wins() == 1 then
vim.cmd "quit"
else
vim.api.nvim_win_close(windows[1], true)
end
end)
end
end
1 week ago
return M