dotfiles-guix/home-config/nvim/lua/tree.lua

121 lines
2.5 KiB
Lua
Raw Normal View History

2023-10-10 00:25:38 +00:00
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
local function on_attach(bufnr)
local api = require("nvim-tree.api")
local function opts(desc)
return { desc = "nvim-tree: " .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true }
end
local function edit_or_open()
local node = api.tree.get_node_under_cursor()
if node.nodes ~= nil then
-- expand or collapse folder
api.node.open.edit()
else
-- open file
api.node.open.edit()
-- Close the tree if file was opened
api.tree.close()
end
end
api.config.mappings.default_on_attach(bufnr)
vim.keymap.set("n", "<CR>", edit_or_open, opts("Open"))
end
require("nvim-tree").setup({
sort_by = "case_sensitive",
view = {
2023-10-10 04:15:27 +00:00
adaptive_size = false,
centralize_selection = true,
2023-10-10 00:25:38 +00:00
width = 30,
2023-10-10 04:15:27 +00:00
side = "left",
preserve_window_proportions = false,
number = false,
relativenumber = false,
signcolumn = "yes",
float = {
enable = false,
quit_on_focus_loss = true,
open_win_config = {
relative = "editor",
border = "rounded",
width = 30,
height = 30,
row = 1,
col = 1,
},
},
2023-10-10 00:25:38 +00:00
},
renderer = {
group_empty = true,
},
actions = {
use_system_clipboard = true,
change_dir = {
enable = true,
global = false,
restrict_above_cwd = false,
},
expand_all = {
max_folder_discovery = 300,
exclude = {},
},
file_popup = {
open_win_config = {
col = 1,
row = 1,
relative = "cursor",
border = "shadow",
style = "minimal",
},
},
open_file = {
window_picker = {
enable = false,
picker = "default",
chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890",
exclude = {
filetype = { "notify", "lazy", "qf", "diff", "fugitive", "fugitiveblame" },
buftype = { "nofile", "terminal", "help" },
},
}
},
remove_file = {
close_window = true,
},
},
tab = {
sync = {
open = false,
close = false,
ignore = {},
},
},
git = {
enable = true,
ignore = false,
show_on_dirs = true,
show_on_open_dirs = true,
timeout = 200,
},
filters = {
dotfiles = false,
git_clean = false,
no_buffer = false,
custom = { "node_modules", "\\.cache" },
exclude = {},
},
update_cwd = true,
respect_buf_cwd = true,
update_focused_file = {
enable = true,
update_cwd = true
},
on_attach = on_attach
})