override quickfix and loclist to toggle instead of just show

This commit is contained in:
Natercio Moniz
2025-08-13 09:25:20 +01:00
parent 2f4095512a
commit 9bb11a28e4

View File

@@ -81,6 +81,36 @@ return {
desc = 'Close buffer from tabline',
},
['<Leader>xq'] = {
function()
local qf_open = vim.tbl_isempty(vim.tbl_filter(function(win)
return win.quickfix == 1
end, vim.fn.getwininfo()))
if qf_open then
vim.cmd.copen()
else
vim.cmd.cclose()
end
end,
desc = 'Toggle Quickfix list',
},
['<Leader>xl'] = {
function()
local ll_open = vim.tbl_isempty(vim.tbl_filter(function(win)
return win.loclist == 1
end, vim.fn.getwininfo()))
if ll_open then
vim.cmd.lclose()
else
vim.cmd.lopen()
end
end,
desc = 'Toggle Local list',
},
-- tables with just a `desc` key will be registered with which-key if it's installed
-- this is useful for naming menus
-- ["<Leader>b"] = { desc = "Buffers" },