mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-07-29 07:05:30 +02:00
feat(keymaps): enable toggling in quickfix list and location list (#5608)
## Description This PR addresses issue #5503 by modifying the behavior of `<leader>xq` and `<leader>xl` so that they toggle the quickfix and location lists rather than simply opening them. To prevent the full Lua error stack from being printed when no list exists prior to using `copen` or `lopen`, I've wrapped the commands in `pcall` and used `vim.notify` to alert the user in the same manner as before. ## Related Issue(s) #5503 ## Screenshots https://github.com/user-attachments/assets/b22b1861-e6e5-4d8a-967e-f760cca15719 ## Checklist - [x] I've read the [CONTRIBUTING](https://github.com/LazyVim/LazyVim/blob/main/CONTRIBUTING.md) guidelines.
This commit is contained in:
parent
98fca895e8
commit
32e575aa75
1 changed files with 15 additions and 2 deletions
|
@ -94,8 +94,21 @@ map("n", "<leader>l", "<cmd>Lazy<cr>", { desc = "Lazy" })
|
|||
-- new file
|
||||
map("n", "<leader>fn", "<cmd>enew<cr>", { desc = "New File" })
|
||||
|
||||
map("n", "<leader>xl", "<cmd>lopen<cr>", { desc = "Location List" })
|
||||
map("n", "<leader>xq", "<cmd>copen<cr>", { desc = "Quickfix List" })
|
||||
-- location list
|
||||
map("n", "<leader>xl", function()
|
||||
local success, err = pcall(vim.fn.getloclist(0, { winid = 0 }).winid ~= 0 and vim.cmd.lclose or vim.cmd.lopen)
|
||||
if not success and err then
|
||||
vim.notify(err, vim.log.levels.ERROR)
|
||||
end
|
||||
end, { desc = "Location List" })
|
||||
|
||||
-- quickfix list
|
||||
map("n", "<leader>xq", function()
|
||||
local success, err = pcall(vim.fn.getqflist({ winid = 0 }).winid ~= 0 and vim.cmd.cclose or vim.cmd.copen)
|
||||
if not success and err then
|
||||
vim.notify(err, vim.log.levels.ERROR)
|
||||
end
|
||||
end, { desc = "Quickfix List" })
|
||||
|
||||
map("n", "[q", vim.cmd.cprev, { desc = "Previous Quickfix" })
|
||||
map("n", "]q", vim.cmd.cnext, { desc = "Next Quickfix" })
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue