2024-06-17 16:19:21 +02:00

74 lines
1.7 KiB
Lua

local function on_attach(bufnr)
local api = require("nvim-tree.api")
-- default mappings
api.config.mappings.default_on_attach(bufnr)
local function opts(desc)
return { desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true }
end
-- navigation
vim.keymap.set("n", "<C-Up>", api.tree.change_root_to_parent, opts("Up"))
vim.keymap.set("n", "<C-Left>", api.tree.change_root_to_parent, opts("Up"))
vim.keymap.set("n", "<C-Down>", api.tree.change_root_to_node, opts("Enter"))
vim.keymap.set("n", "<C-Right>", api.tree.change_root_to_node, opts("Enter"))
-- open folders with a single click
vim.keymap.set("n", "<LeftRelease>", function()
vim.defer_fn(function ()
local win = vim.api.nvim_get_current_win()
local view = require("nvim-tree.view")
if view.get_winnr() ~= win then return end
api.node.open.edit()
api.tree.focus()
end, 10)
end, opts("Open folder/file"))
end
return {
"nvim-tree/nvim-tree.lua",
event = "VeryLazy",
dependencies = {
"nvim-tree/nvim-web-devicons",
},
keys = {
{ "<leader>e", function() require("nvim-tree.api").tree.toggle() end, desc = "Toggle files" },
},
opts = {
filesystem_watchers = {
enable = true,
},
filters = {
dotfiles = false,
},
on_attach = on_attach,
renderer = {
root_folder_label = false,
highlight_git = true,
icons = {
show = {
git = false,
},
glyphs = {
git = {
unstaged = "",
untracked = "",
deleted = "",
},
},
},
},
sync_root_with_cwd = true,
update_focused_file = {
enable = true,
update_root = false,
},
view = {
width = 30,
},
},
config = true,
}