diff --git a/plugin/20_keymaps.lua b/plugin/20_keymaps.lua index d5e7677..2fc699c 100644 --- a/plugin/20_keymaps.lua +++ b/plugin/20_keymaps.lua @@ -48,13 +48,14 @@ nmap_leader("bD", function() pcall(vim.cmd, "bdelete!") end, "Delete!") nmap_leader("bw", function() pcall(vim.cmd, "bwipeout") end, "Wipeout") nmap_leader("bW", function() pcall(vim.cmd, "bwipeout!") end, "Wipeout!") nmap_leader("bo", function() - local current = vim.api.nvim_get_current_buf() + local visible = vim.iter(vim.api.nvim_list_wins()):map(vim.api.nvim_win_get_buf):totable() + for _, buf in ipairs(vim.api.nvim_list_bufs()) do - if buf ~= current and vim.api.nvim_buf_is_loaded(buf) and vim.bo[buf].buflisted then + if not vim.list_contains(visible, buf) then pcall(vim.api.nvim_buf_delete, buf, { force = false }) end end -end, "Close all but current") +end, "Close all invisible buffers") -- Debug ======================================================================= nmap_leader("db", function() require("dap").toggle_breakpoint() end, "Toggle Breakpoint", "dap")