diff --git a/lua/znvim/plugins/editor.lua b/lua/znvim/plugins/editor.lua index b28a1f9..e6c7483 100644 --- a/lua/znvim/plugins/editor.lua +++ b/lua/znvim/plugins/editor.lua @@ -1,6 +1,31 @@ return { - { -- file explorer + { -- use bdelete instead + "https://github.com/famiu/bufdelete.nvim", + config = function() + -- switches to Alpha dashboard when last buffer is closed + local alpha_on_empty = vim.api.nvim_create_augroup("alpha_on_empty", { clear = true }) + vim.api.nvim_create_autocmd("User", { + pattern = "BDeletePost*", + group = alpha_on_empty, + callback = function(event) + local fallback_name = vim.api.nvim_buf_get_name(event.buf) + local fallback_ft = vim.api.nvim_buf_get_option(event.buf, "filetype") + local fallback_on_empty = fallback_name == "" and fallback_ft == "" + if fallback_on_empty then + require("neo-tree").close_all() + vim.cmd("Alpha") + vim.cmd(event.buf .. "bwipeout") + end + end, + }) + end, + keys = { + { "bd", "Bdelete", desc = "delete buffer" }, + { "bD", "Bdelete!", desc = "delete buffer!" }, + }, + }, + { -- neo-tree file explorer "https://github.com/nvim-neo-tree/neo-tree.nvim", cmd = "Neotree",