aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--neovim/.config/nvim/lua/plugins/filetree.lua34
1 files changed, 20 insertions, 14 deletions
diff --git a/neovim/.config/nvim/lua/plugins/filetree.lua b/neovim/.config/nvim/lua/plugins/filetree.lua
index cdee9f7..2455cb1 100644
--- a/neovim/.config/nvim/lua/plugins/filetree.lua
+++ b/neovim/.config/nvim/lua/plugins/filetree.lua
@@ -1,31 +1,37 @@
1return { 1return {
2 "preservim/nerdtree", 2 "nvim-neo-tree/neo-tree.nvim",
3 branch = "v3.x",
3 lazy = false, 4 lazy = false,
5 dependencies = {
6 "nvim-lua/plenary.nvim",
7 "nvim-tree/nvim-web-devicons",
8 "MunifTanjim/nui.nvim",
9 },
10 keys = {
11 { "<leader>e", "<cmd>Neotree toggle<cr>", desc = "Toggle file explorer" },
12 },
4 config = function() 13 config = function()
5 -- Open NERDTree when no file is specified; quit when it's the last window 14 require("neo-tree").setup({
6 local augroup = vim.api.nvim_create_augroup("nerdtree_auto", { clear = true }) 15 close_if_last_window = true,
16 filesystem = {
17 follow_current_file = { enabled = true },
18 },
19 })
7 20
21 -- Open neo-tree when no file is specified (mirrors the vimrc's old
22 -- NERDTree auto-open behavior), but not when nvim is reading stdin.
23 local augroup = vim.api.nvim_create_augroup("neotree_auto", { clear = true })
8 vim.api.nvim_create_autocmd("StdinReadPre", { 24 vim.api.nvim_create_autocmd("StdinReadPre", {
9 group = augroup, 25 group = augroup,
10 callback = function() 26 callback = function()
11 vim.g.std_in = 1 27 vim.g.std_in = 1
12 end, 28 end,
13 }) 29 })
14
15 vim.api.nvim_create_autocmd("VimEnter", { 30 vim.api.nvim_create_autocmd("VimEnter", {
16 group = augroup, 31 group = augroup,
17 callback = function() 32 callback = function()
18 if vim.fn.argc() == 0 and vim.g.std_in == nil then 33 if vim.fn.argc() == 0 and vim.g.std_in == nil then
19 vim.cmd("NERDTree") 34 vim.cmd("Neotree show")
20 end
21 end,
22 })
23
24 vim.api.nvim_create_autocmd("BufEnter", {
25 group = augroup,
26 callback = function()
27 if vim.fn.winnr("$") == 1 and vim.bo.filetype == "nerdtree" then
28 vim.cmd("quit")
29 end 35 end
30 end, 36 end,
31 }) 37 })