I’m trying to make autocamd that every time I I close All buffers neovim close all unnecessary hidden buffers and Go to Alpha dashboard automatically I typically close buffers by using Space bd or :bd
I tried this code But
local function emptybuf()
return vim.fn.line(‘$’) == 1 and vim.fn.getline(1)
end
vim.api.nvim_create_augroup(“alpha_on_empty”, { clear = true })
– launch alpha if user closed all buffers
vim.api.nvim_create_autocmd({ “BufDelete” }, {
group = “alpha_on_empty”,
callback = function()
if vim.fn.bufname(“%”) == “” then
if emptybuf() then
vim.cmd(“bd”)
vim.cmd(“Alpha”)
end
end
end,
})
It indeed goto alpha after I close all buffers
But when I open any buffers after that it literally does not open it just shows and empty buffer I had to close and reopen neovim to work normally. Does anyone have better solution