nvim-tree updates

This commit is contained in:
fanyx 2023-09-22 00:43:46 +02:00
parent fb37ba1ad7
commit 948e49df35
1 changed files with 50 additions and 0 deletions

View File

@ -1,19 +1,69 @@
local function on_attach(bufnr)
local api = require("nvim-tree.api")
local function opts(desc)
return { desc = "Tree: " .. desc, buffer = bufnr, noremap = true,
silent = true, nowait = true }
end
vim.keymap.set("n", "<CR>", api.node.open.edit, opts("Open"))
end
local tree = {
'nvim-tree/nvim-tree.lua',
lazy = false,
dependencies = { 'nvim-tree/nvim-web-devicons' },
opts = {
on_attach = on_attach,
disable_netrw = true,
sort_by = "case_sensitive",
view = {
adaptive_size = true,
centralize_selection = true,
number = true,
relativenumber = true,
},
renderer = {
group_empty = true,
highlight_git = true,
},
filters = {
dotfiles = true,
},
update_focused_file = {
enable = true,
},
actions = {
change_dir = {
enable = false,
},
},
},
}
local function is_modified_buffer_open(buffers)
for _, v in pairs(buffers) do
if v.name:match("NvimTree_") == nil then
return true
end
end
return false
end
-- [[
vim.api.nvim_create_autocmd("BufEnter", {
nested = true,
callback = function()
if
#vim.api.nvim_list_wins() == 1
and vim.api.nvim_buf_get_name(0):match("NvimTree_") ~= nil
and is_modified_buffer_open(vim.fn.getbufinfo({ bufmodified = 1 })) == false
then
vim.cmd("quit")
end
end,
})
-- ]]
return { tree }