dev-environment-files/.config/nvim/lua/josean/plugins/nvim-tree.lua

65 lines
1.3 KiB
Lua
Raw Permalink Normal View History

2022-10-17 20:40:36 +02:00
-- import nvim-tree plugin safely
local setup, nvimtree = pcall(require, "nvim-tree")
if not setup then
return
2022-10-17 20:40:36 +02:00
end
-- recommended settings from nvim-tree documentation
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({
-- 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,
},
},
},
-- git = {
-- ignore = false,
-- },
2022-10-17 20:40:36 +02: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 })