From cd3b426b15ace7d35c71bdee593163e09994c76f Mon Sep 17 00:00:00 2001 From: Tom van der Lee Date: Thu, 10 Sep 2026 22:21:57 +0200 Subject: Swap nerdtree for neo-tree.nvim in the Neovim config Requested: a modern, git-status-aware file explorer instead of nerdtree (which has no built-in git integration). neo-tree.nvim shows per-file git status (modified/staged/added/etc.) directly in the tree, plus dedicated git-status/buffers/diagnostics panels if wanted later. - Same auto-open-when-no-file / stdin-guard behavior as the old nerdtree autocmds, reimplemented for neo-tree. - close_if_last_window = true replaces nerdtree's manual "quit when it's the last window" autocmd. - Added e to toggle it, since neo-tree isn't opened by a memorable bare command the way :NERDTree was. Vim's own vimrc still uses nerdtree, untouched - this only affects the Neovim-only config. --- neovim/.config/nvim/lua/plugins/filetree.lua | 34 ++++++++++++++++------------ 1 file 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 @@ return { - "preservim/nerdtree", + "nvim-neo-tree/neo-tree.nvim", + branch = "v3.x", lazy = false, + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", + "MunifTanjim/nui.nvim", + }, + keys = { + { "e", "Neotree toggle", desc = "Toggle file explorer" }, + }, config = function() - -- Open NERDTree when no file is specified; quit when it's the last window - local augroup = vim.api.nvim_create_augroup("nerdtree_auto", { clear = true }) + require("neo-tree").setup({ + close_if_last_window = true, + filesystem = { + follow_current_file = { enabled = true }, + }, + }) + -- Open neo-tree when no file is specified (mirrors the vimrc's old + -- NERDTree auto-open behavior), but not when nvim is reading stdin. + local augroup = vim.api.nvim_create_augroup("neotree_auto", { clear = true }) vim.api.nvim_create_autocmd("StdinReadPre", { group = augroup, callback = function() vim.g.std_in = 1 end, }) - vim.api.nvim_create_autocmd("VimEnter", { group = augroup, callback = function() if vim.fn.argc() == 0 and vim.g.std_in == nil then - vim.cmd("NERDTree") - end - end, - }) - - vim.api.nvim_create_autocmd("BufEnter", { - group = augroup, - callback = function() - if vim.fn.winnr("$") == 1 and vim.bo.filetype == "nerdtree" then - vim.cmd("quit") + vim.cmd("Neotree show") end end, }) -- cgit v1.3