utils: close_buffer: Ask for confirmation when using on modified files

neovim handles this internally so why not use it
This commit is contained in:
Akianonymus 2022-08-17 21:15:23 +05:30 committed by Sidhanth Rathod
parent ce86597c3d
commit 5e81ae8379
1 changed files with 1 additions and 3 deletions

View File

@ -6,12 +6,10 @@ local merge_tb = vim.tbl_deep_extend
M.close_buffer = function(bufnr) M.close_buffer = function(bufnr)
if vim.bo.buftype == "terminal" then if vim.bo.buftype == "terminal" then
vim.cmd(vim.bo.buflisted and "set nobl | enew" or "hide") vim.cmd(vim.bo.buflisted and "set nobl | enew" or "hide")
elseif vim.bo.modified then
print "save the file bruh"
else else
bufnr = bufnr or api.nvim_get_current_buf() bufnr = bufnr or api.nvim_get_current_buf()
require("core.utils").tabuflinePrev() require("core.utils").tabuflinePrev()
vim.cmd("bd" .. bufnr) vim.cmd("silent! confirm bd" .. bufnr)
end end
end end