This commit is contained in:
zbirenbaum 2022-06-16 00:01:15 -04:00
parent 1383117bd3
commit 6bb209a834

View file

@ -6,8 +6,9 @@ local merge_tb = vim.tbl_deep_extend
M.close_buffer = function(force)
if vim.bo.buftype == "terminal" then
api.nvim_win_hide(0)
return
force = force or #api.nvim_list_wins() < 2 and ":bd!"
local swap = force and #api.nvim_list_bufs() > 1 and ":bp | bd!" .. fn.bufnr()
return vim.cmd(swap or force or "hide")
end
local fileExists = fn.filereadable(fn.expand "%p")
@ -20,7 +21,6 @@ M.close_buffer = function(force)
end
force = force or not vim.bo.buflisted or vim.bo.buftype == "nofile"
-- if not force, change to prev buf and then close current
local close_cmd = force and ":bd!" or ":bp | bd" .. fn.bufnr()
vim.cmd(close_cmd)