better buffer delestion
This commit is contained in:
parent
2f0a4aa48c
commit
360f53ec43
1 changed files with 26 additions and 1 deletions
|
@ -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 = {
|
||||
{ "<leader>bd", "<CMD>Bdelete<CR>", desc = "delete buffer" },
|
||||
{ "<leader>bD", "<CMD>Bdelete!<CR>", desc = "delete buffer!" },
|
||||
},
|
||||
},
|
||||
|
||||
{ -- neo-tree file explorer
|
||||
"https://github.com/nvim-neo-tree/neo-tree.nvim",
|
||||
cmd = "Neotree",
|
||||
|
|
Loading…
Reference in a new issue