diff options
Diffstat (limited to 'nvim/lua/jonathan/plugins/nvim-tree.lua')
-rw-r--r-- | nvim/lua/jonathan/plugins/nvim-tree.lua | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/nvim/lua/jonathan/plugins/nvim-tree.lua b/nvim/lua/jonathan/plugins/nvim-tree.lua new file mode 100644 index 0000000..fc551e1 --- /dev/null +++ b/nvim/lua/jonathan/plugins/nvim-tree.lua @@ -0,0 +1,53 @@ +-- import nvim-tree plugin safely +local setup, nvimtree = pcall(require, "nvim-tree") +if not setup then + return +end + +-- recommended settings from nvim-tree documentation +vim.g.loaded_netrw = 1 +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({ + -- disable window_picker for + -- explorer to work well with + -- window splits + actions = { + open_file = { + window_picker = { + enable = false, + }, + }, + }, + -- git = { + -- ignore = false, + -- }, +}) + +-- 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 }) |