48 lines
1.1 KiB
Lua
48 lines
1.1 KiB
Lua
-- disable netrw at the very start of your init.lua (strongly advised)
|
|
vim.g.loaded_netrw = 1
|
|
vim.g.loaded_netrwPlugin = 1
|
|
|
|
-- set termguicolors to enable highlight groups
|
|
vim.opt.termguicolors = true
|
|
|
|
-- OR setup with some options
|
|
require("nvim-tree").setup({
|
|
auto_reload_on_write = true,
|
|
sort_by = "case_sensitive",
|
|
sync_root_with_cwd = true,
|
|
respect_buf_cwd = true,
|
|
update_focused_file = {
|
|
enable = true,
|
|
update_root = true,
|
|
},
|
|
filters = { custom = { ".git" } },
|
|
view = {
|
|
width = 30,
|
|
mappings = {
|
|
list = {
|
|
{ key = "u", action = "dir_up" },
|
|
},
|
|
},
|
|
},
|
|
renderer = {
|
|
group_empty = true,
|
|
},
|
|
})
|
|
|
|
local function open_nvim_tree(data)
|
|
-- buffer is a directory
|
|
local directory = vim.fn.isdirectory(data.file) == 1
|
|
|
|
if not directory then
|
|
return
|
|
end
|
|
|
|
-- change to the directory
|
|
vim.cmd.cd(data.file)
|
|
|
|
-- open the tree
|
|
require("nvim-tree.api").tree.open()
|
|
end
|
|
|
|
vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree })
|