How to load the mini.starter dashboard when all the buffers are either deleted/wiped out? #389
-
I use famiu/bufdelete.nvim to delete my Neovim buffers and goolord/alpha-nvim for the starter dashboard. And I've the following autocommand configured to load local autocmd = vim.api.nvim_create_autocmd
local augroup = function(name)
return vim.api.nvim_create_augroup("augroup" .. name, { clear = true })
end
autocmd("User", {
desc = "Open Alpha dashboard when all buffers are removed",
group = augroup("open_alpha_on_buffer_removal"),
pattern = "BDeletePost*",
callback = function(event)
local fallback_name = vim.api.nvim_buf_get_name(event.buf)
local fallback_filetype = vim.api.nvim_buf_get_option(event.buf, "filetype")
local fallback_on_empty = fallback_name == "" and fallback_filetype == ""
if fallback_on_empty then
vim.cmd("Neotree close")
vim.cmd("Alpha")
vim.cmd(event.buf .. "bwipeout")
end
end,
}) And is the same behaviour possible when using |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Yes this behavior is possible, but I'd suggest a different route then creating an autocommand. What about creating own commands for buffer delete and wipeout? Something like this: local open_starter_if_empty_buffer = function()
local buf_id = vim.api.nvim_get_current_buf()
local is_empty = vim.api.nvim_buf_get_name(buf_id) == "" and vim.bo[buf_id].filetype == ''
if not is_empty then return end
vim.cmd("Neotree close")
require('mini.starter').open()
vim.cmd(buf_id .. "bwipeout")
end
_G.my_bufdelete = function(...)
require('mini.bufremove').delete(...)
open_starter_if_empty_buffer()
end
_G.my_bufwipeout = function(...)
require('mini.bufremove').wipeout(...)
open_starter_if_empty_buffer()
end It is a comparable amount of code with a more freedom for user customization. Of course, it also means replacing mappings for |
Beta Was this translation helpful? Give feedback.
Yes this behavior is possible, but I'd suggest a different route then creating an autocommand.
What about creating own commands for buffer delete and wipeout? Something like this: