Hey, I had this old function to confirm on close tab. I notice it broke, but it’s not exactly clear what is wrong.
I see one function is deprecated as well.
I’ve read through 0.10.0 briefly but I’m less familiar of what all these nvim functions are and atm i dont have time to really dig into it.
Is there a quick fix anyone could help me out with?
local function close_tab(force)
-- check if standard file buffer or a new unsaved buffer, otherwise do standard
-- bd as barbar won't handle quickfix window, neotree, etc
local bufid = vim.api.nvim_get_current_buf()
local bufname = vim.fn.bufname(bufid)
local buftype = vim.api.nvim_buf_get_option(bufid, "buftype")
if (buftype == "" and bufname ~= "") then
vim.cmd(force and "BufferClose!" or "BufferClose")
else
vim.cmd(force and "bd!" or "bd")
end
end
local function confirm_close_tab()
if buffer_modified() then
local choice = vim.fn.confirm("Save changes?", "&Yes\n&No\n&Cancel")
if choice == 2 then
close_tab(true)
end
else
close_tab(false)
end
end