config/.config/nvim/lua/lazyvim/plugins/nvim-tree.lua

132 lines
4.9 KiB
Lua

return {
{
"kyazdani42/nvim-tree.lua",
enabled = false,
cmd = "NvimTreeToggle",
config = function()
local nvim_tree = require("nvim-tree")
local icons = require("lazyvim.config.icons")
local function edit_or_open()
-- open as vsplit on current node
local action = "edit"
local node = lib.get_node_at_cursor()
-- Just copy what's done normally with vsplit
if node.link_to and not node.nodes then
require("nvim-tree.actions.node.open-file").fn(action, node.link_to)
view.close() -- Close the tree if file was opened
elseif node.nodes ~= nil then
lib.expand_or_collapse(node)
else
require("nvim-tree.actions.node.open-file").fn(action, node.absolute_path)
view.close() -- Close the tree if file was opened
end
end
nvim_tree.setup({
hijack_directories = {
enable = false,
},
ignore_ft_on_setup = {
"alpha",
},
filters = {
custom = { ".git" },
exclude = { ".gitignore" },
},
hijack_cursor = false,
update_cwd = true,
renderer = {
add_trailing = false,
group_empty = false,
highlight_git = false,
highlight_opened_files = "none",
root_folder_modifier = ":t",
indent_markers = {
enable = false,
icons = {
corner = "",
edge = "",
none = " ",
},
},
icons = {
webdev_colors = true,
git_placement = "before",
padding = " ",
symlink_arrow = "",
show = {
file = true,
folder = true,
folder_arrow = true,
git = true,
},
glyphs = {
default = "",
symlink = "",
folder = {
arrow_open = icons.ui.ArrowOpen,
arrow_closed = icons.ui.ArrowClosed,
default = "",
open = "",
empty = "",
empty_open = "",
symlink = "",
symlink_open = "",
},
git = {
unstaged = "",
staged = "S",
unmerged = "",
renamed = "",
untracked = "U",
deleted = "",
ignored = "",
},
},
},
},
diagnostics = {
enable = true,
icons = {
hint = icons.diagnostics.Hint,
info = icons.diagnostics.Information,
warning = icons.diagnostics.Warning,
error = icons.diagnostics.Error,
},
},
update_focused_file = {
enable = true,
update_cwd = true,
ignore_list = {},
},
git = {
enable = true,
ignore = true,
timeout = 500,
},
view = {
width = 30,
hide_root_folder = false,
side = "left",
number = false,
relativenumber = false,
mappings = {
custom_only = false,
list = {
{ key = "l", action = "edit", action_cb = edit_or_open },
{ key = "h", action = "close_node" },
},
},
},
actions = {
open_file = {
quit_on_open = true,
},
},
})
end,
},
}