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

@@ -10,12 +10,12 @@ return {
opts = { opts = {
-- Configure core features of AstroNvim -- Configure core features of AstroNvim
features = { features = {
large_buf = { size = 1024 * 256, lines = 10000 }, -- set global limits for large files for disabling features like treesitter large_buf = { size = 1024 * 256, lines = 10000 }, -- set global limits for large files for disabling features like treesitter
autopairs = true, -- enable autopairs at start autopairs = true, -- enable autopairs at start
cmp = true, -- enable completion at start cmp = true, -- enable completion at start
diagnostics = { virtual_text = true, virtual_lines = false }, -- diagnostic settings on startup diagnostics = { virtual_text = true, virtual_lines = false }, -- diagnostic settings on startup
highlighturl = true, -- highlight URLs at start highlighturl = true, -- highlight URLs at start
notifications = true, -- enable notifications at start notifications = true, -- enable notifications at start
}, },
-- Diagnostics configuration (for vim.diagnostics.config({...})) when diagnostics are on -- Diagnostics configuration (for vim.diagnostics.config({...})) when diagnostics are on
diagnostics = { diagnostics = {
@@ -37,14 +37,14 @@ return {
}, },
-- vim options can be configured here -- vim options can be configured here
options = { options = {
opt = { -- vim.opt.<key> opt = { -- vim.opt.<key>
relativenumber = true, -- sets vim.opt.relativenumber relativenumber = true, -- sets vim.opt.relativenumber
number = true, -- sets vim.opt.number number = true, -- sets vim.opt.number
spell = false, -- sets vim.opt.spell spell = false, -- sets vim.opt.spell
signcolumn = 'yes', -- sets vim.opt.signcolumn to yes signcolumn = 'yes', -- sets vim.opt.signcolumn to yes
wrap = false, -- sets vim.opt.wrap wrap = false, -- sets vim.opt.wrap
}, },
g = { -- vim.g.<key> g = { -- vim.g.<key>
-- configure global vim variables (vim.g) -- configure global vim variables (vim.g)
-- NOTE: `mapleader` and `maplocalleader` must be set in the AstroNvim opts or before `lazy.setup` -- NOTE: `mapleader` and `maplocalleader` must be set in the AstroNvim opts or before `lazy.setup`
-- This can be found in the `lua/lazy_setup.lua` file -- This can be found in the `lua/lazy_setup.lua` file
@@ -81,6 +81,36 @@ return {
desc = 'Close buffer from tabline', 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 -- tables with just a `desc` key will be registered with which-key if it's installed
-- this is useful for naming menus -- this is useful for naming menus
-- ["<Leader>b"] = { desc = "Buffers" }, -- ["<Leader>b"] = { desc = "Buffers" },