fix: ignore changed bufs for bo

This commit is contained in:
Klesh Wong 2022-12-07 19:51:41 +08:00
parent 8a51047728
commit f828d4f7ad

View File

@ -8,7 +8,7 @@ local COMMAND = 'c'
vim.api.nvim_create_user_command("CloseOtherBuffers", function() vim.api.nvim_create_user_command("CloseOtherBuffers", function()
local current_buffer_name = vim.api.nvim_buf_get_name(0) local current_buffer_name = vim.api.nvim_buf_get_name(0)
for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do
if vim.api.nvim_buf_is_loaded(bufnr) then if vim.api.nvim_buf_is_loaded(bufnr) and not vim.api.nvim_buf_get_option(bufnr, "modified") then
local bufname = vim.api.nvim_buf_get_name(bufnr) local bufname = vim.api.nvim_buf_get_name(bufnr)
if bufname ~= current_buffer_name then if bufname ~= current_buffer_name then
vim.cmd(":bd " .. bufnr) vim.cmd(":bd " .. bufnr)