Skip to content

Commit

Permalink
feat(bufremove): ask to save changes before trying to remove a buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Oct 6, 2023
1 parent e1f5484 commit 54df3e2
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions lua/lazyvim/plugins/editor.lua
Expand Up @@ -387,9 +387,27 @@ return {
-- buffer remove
{
"echasnovski/mini.bufremove",
-- stylua: ignore

keys = {
{ "<leader>bd", function() require("mini.bufremove").delete(0, false) end, desc = "Delete Buffer" },
{
"<leader>bd",
function()
local bd = require("mini.bufremove").delete
if vim.bo.modified then
local choice = vim.fn.confirm(("Save changes to %q?"):format(vim.fn.bufname()), "&Yes\n&No\n&Cancel")
if choice == 1 then -- Yes
vim.cmd.write()
bd(0)
elseif choice == 2 then -- No
bd(0, true)
end
else
bd(0)
end
end,
desc = "Delete Buffer",
},
-- stylua: ignore
{ "<leader>bD", function() require("mini.bufremove").delete(0, true) end, desc = "Delete Buffer (Force)" },
},
},
Expand Down

0 comments on commit 54df3e2

Please sign in to comment.