From 2a11da636074d5e6101047ea7f2deff8249a2123 Mon Sep 17 00:00:00 2001 From: Daniel McKnight Date: Tue, 10 Jun 2025 11:54:52 -0700 Subject: [PATCH] Update neotree to auto-close upon file selection --- .config/nvim/lua/plugins/neotree.lua | 49 ++++++++++++++++------------ 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/.config/nvim/lua/plugins/neotree.lua b/.config/nvim/lua/plugins/neotree.lua index 95df0f4..60aba4c 100644 --- a/.config/nvim/lua/plugins/neotree.lua +++ b/.config/nvim/lua/plugins/neotree.lua @@ -1,22 +1,31 @@ return { - "nvim-neo-tree/neo-tree.nvim", - branch = "v3.x", - dependencies = { - "nvim-lua/plenary.nvim", - "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended - "MunifTanjim/nui.nvim", - -- {"3rd/image.nvim", opts = {}}, -- Optional image support in preview window: See `# Preview Mode` for more information - }, - lazy = false, -- neo-tree will lazily load itself - opts = { - filesystem = { - filtered_items = { - visible = true, --- hide_dotfiles = false, - hide_by_name = { - '.git' - } - } - } - } + "nvim-neo-tree/neo-tree.nvim", + branch = "v3.x", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", -- not strictly required, but recommended + "MunifTanjim/nui.nvim", + -- {"3rd/image.nvim", opts = {}}, -- Optional image support in preview window: See `# Preview Mode` for more information + }, + lazy = false, -- neo-tree will lazily load itself + opts = { + filesystem = { + filtered_items = { + visible = true, + -- hide_dotfiles = false, + hide_by_name = { + ".git", + }, + }, + }, + event_handlers = { + { + event = "file_opened", + handler = function(file_path) + --auto close neo-tree when file is opened + vim.cmd("Neotree close") + end, + }, + }, + }, }