Add close all other tabs shortcut
This commit is contained in:
parent
d1b3891e7e
commit
3e40d04572
1 changed files with 25 additions and 0 deletions
|
|
@ -240,6 +240,12 @@
|
|||
action = ":bp|bd #<CR>";
|
||||
options = { desc = "Close current buffer"; };
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>X";
|
||||
action = ":lua close_other_buffers()<CR>";
|
||||
options = { desc = "Close all buffers except current"; };
|
||||
}
|
||||
|
||||
# System integration
|
||||
{
|
||||
|
|
@ -317,6 +323,25 @@
|
|||
}
|
||||
}
|
||||
|
||||
-- Close all buffers except current (preserving NvimTree and other special buffers)
|
||||
function close_other_buffers()
|
||||
local current_buf = vim.api.nvim_get_current_buf()
|
||||
local buffers = vim.api.nvim_list_bufs()
|
||||
|
||||
for _, buf in ipairs(buffers) do
|
||||
if buf ~= current_buf and vim.api.nvim_buf_is_valid(buf) then
|
||||
local buftype = vim.api.nvim_buf_get_option(buf, 'buftype')
|
||||
local filetype = vim.api.nvim_buf_get_option(buf, 'filetype')
|
||||
|
||||
-- Skip special buffers (NvimTree, terminals, quickfix, etc.)
|
||||
if buftype == "" and filetype ~= "NvimTree" then
|
||||
-- Only delete if it's a normal file buffer
|
||||
vim.api.nvim_buf_delete(buf, { force = false })
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Unicode-safe file operations
|
||||
function open_file_with_system_app()
|
||||
local filepath = vim.fn.expand('%:p')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue