2022-10-17 20:40:36 +02:00
|
|
|
-- import nvim-tree plugin safely
|
|
|
|
local setup, nvimtree = pcall(require, "nvim-tree")
|
|
|
|
if not setup then
|
2022-11-05 22:13:18 +01:00
|
|
|
return
|
2022-10-17 20:40:36 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
-- recommended settings from nvim-tree documentation
|
2022-11-15 23:43:45 +01:00
|
|
|
vim.g.loaded_netrw = 1
|
2022-10-17 20:40:36 +02:00
|
|
|
vim.g.loaded_netrwPlugin = 1
|
|
|
|
|
|
|
|
-- change color for arrows in tree to light blue
|
|
|
|
vim.cmd([[ highlight NvimTreeIndentMarker guifg=#3FC5FF ]])
|
|
|
|
|
|
|
|
-- configure nvim-tree
|
|
|
|
nvimtree.setup({
|
2022-11-05 22:13:18 +01:00
|
|
|
-- change folder arrow icons
|
|
|
|
renderer = {
|
|
|
|
icons = {
|
|
|
|
glyphs = {
|
|
|
|
folder = {
|
|
|
|
arrow_closed = "", -- arrow when folder is closed
|
|
|
|
arrow_open = "", -- arrow when folder is open
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
-- disable window_picker for
|
|
|
|
-- explorer to work well with
|
|
|
|
-- window splits
|
|
|
|
actions = {
|
|
|
|
open_file = {
|
|
|
|
window_picker = {
|
|
|
|
enable = false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2022-11-15 23:43:45 +01:00
|
|
|
-- git = {
|
|
|
|
-- ignore = false,
|
|
|
|
-- },
|
2022-10-17 20:40:36 +02:00
|
|
|
})
|
2023-02-13 16:39:10 +01:00
|
|
|
|
|
|
|
-- open nvim-tree on setup
|
|
|
|
|
|
|
|
local function open_nvim_tree(data)
|
|
|
|
-- buffer is a [No Name]
|
|
|
|
local no_name = data.file == "" and vim.bo[data.buf].buftype == ""
|
|
|
|
|
|
|
|
-- buffer is a directory
|
|
|
|
local directory = vim.fn.isdirectory(data.file) == 1
|
|
|
|
|
|
|
|
if not no_name and not directory then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
-- change to the directory
|
|
|
|
if directory then
|
|
|
|
vim.cmd.cd(data.file)
|
|
|
|
end
|
|
|
|
|
|
|
|
-- open the tree
|
|
|
|
require("nvim-tree.api").tree.open()
|
|
|
|
end
|
|
|
|
|
|
|
|
vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree })
|