dotfiles/.config/nvim/lua/plugins/tree.lua

70 lines
1.5 KiB
Lua
Raw Normal View History

2023-09-22 00:43:46 +02:00
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
2023-09-21 19:01:37 +02:00
local tree = {
'nvim-tree/nvim-tree.lua',
lazy = false,
dependencies = { 'nvim-tree/nvim-web-devicons' },
opts = {
2023-09-22 00:43:46 +02:00
on_attach = on_attach,
disable_netrw = true,
2023-09-21 19:01:37 +02:00
sort_by = "case_sensitive",
view = {
adaptive_size = true,
2023-09-22 00:43:46 +02:00
centralize_selection = true,
number = true,
relativenumber = true,
2023-09-21 19:01:37 +02:00
},
renderer = {
group_empty = true,
2023-09-22 00:43:46 +02:00
highlight_git = true,
2023-09-21 19:01:37 +02:00
},
filters = {
dotfiles = true,
},
2023-09-22 00:43:46 +02:00
update_focused_file = {
enable = true,
},
actions = {
change_dir = {
enable = false,
},
},
2023-09-21 19:01:37 +02:00
},
}
2023-09-22 00:43:46 +02:00
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,
})
-- ]]
2023-09-21 19:01:37 +02:00
return { tree }