From 832a664fa0ac2da0f50f4638569b9c296125f355 Mon Sep 17 00:00:00 2001 From: Carlos Gutierrez Date: Thu, 5 Feb 2026 08:28:34 -0500 Subject: [PATCH] Bunmping version --- lua/cargdev/core/dashboard_config.lua | 2 +- lua/cargdev/plugins/nvim-tree.lua | 30 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/lua/cargdev/core/dashboard_config.lua b/lua/cargdev/core/dashboard_config.lua index 288538c..9752ccb 100644 --- a/lua/cargdev/core/dashboard_config.lua +++ b/lua/cargdev/core/dashboard_config.lua @@ -25,7 +25,7 @@ M.menu_items = { { key = "f", icon = "", desc = "Go to File", action = ":Telescope find_files" }, { key = "r", icon = "", desc = "Recent Files", action = ":Telescope oldfiles" }, { key = "g", icon = "", desc = "Find in Files", action = ":Telescope live_grep" }, - { key = "s", icon = "", desc = "Restore Session", action = ":lua require('persistence').load()" }, + { key = "s", icon = "", desc = "Recent Files", action = ":Telescope oldfiles" }, { key = "e", icon = "", desc = "Explorer", action = ":NvimTreeToggle" }, { key = "l", icon = "󰒲", desc = "Lazy", action = ":Lazy" }, { key = "m", icon = "", desc = "Mason", action = ":Mason" }, diff --git a/lua/cargdev/plugins/nvim-tree.lua b/lua/cargdev/plugins/nvim-tree.lua index dac26bb..dcedaa4 100644 --- a/lua/cargdev/plugins/nvim-tree.lua +++ b/lua/cargdev/plugins/nvim-tree.lua @@ -12,9 +12,39 @@ return { -- Disable netrw before it loads (must be in init, not config) vim.g.loaded_netrw = 1 vim.g.loaded_netrwPlugin = 1 + -- Create empty FileExplorer group to suppress E216 error from nvim-tree + vim.api.nvim_create_augroup("FileExplorer", { clear = true }) end, config = function() local nvimtree = require("nvim-tree") + local api = require("nvim-tree.api") + + -- Handle file deletion: switch to another buffer or create new one + local Event = api.events.Event + api.events.subscribe(Event.FileRemoved, function(data) + vim.schedule(function() + -- Close nvim-tree first + pcall(function() api.tree.close() end) + + -- Get all listed buffers with real files (excluding deleted one) + local deleted_path = data.fname + local bufs = vim.tbl_filter(function(b) + if not vim.api.nvim_buf_is_valid(b) then return false end + if not vim.bo[b].buflisted then return false end + local name = vim.api.nvim_buf_get_name(b) + if name == "" or name == deleted_path then return false end + if vim.bo[b].buftype ~= "" then return false end + return true + end, vim.api.nvim_list_bufs()) + + -- Switch to another buffer or create new one + if #bufs > 0 then + pcall(function() vim.cmd("buffer " .. bufs[1]) end) + else + pcall(function() vim.cmd("enew") end) + end + end) + end) nvimtree.setup({ view = {