summaryrefslogtreecommitdiff
path: root/lua/aotrix
diff options
context:
space:
mode:
authorAotrix <[email protected]>2025-03-03 15:29:18 +0100
committerAotrix <[email protected]>2025-03-03 15:29:18 +0100
commit167171b4d9f4d5e3364d82280d5fe4d4509ed0df (patch)
tree5141c36349366d7da7a5f6394278e96870894fa0 /lua/aotrix
parent8eecbebc86b48b47d8e05bd403768be5bb550da9 (diff)
added quickfix looping
Diffstat (limited to 'lua/aotrix')
-rw-r--r--lua/aotrix/quickfix.lua18
1 files changed, 12 insertions, 6 deletions
diff --git a/lua/aotrix/quickfix.lua b/lua/aotrix/quickfix.lua
index c169d75..f1f1008 100644
--- a/lua/aotrix/quickfix.lua
+++ b/lua/aotrix/quickfix.lua
@@ -21,6 +21,7 @@ vim.api.nvim_create_autocmd('DiagnosticChanged', {
end
end
})
+local current_quickfix_line = 1
vim.keymap.set("n", "<leader>q", function()
if #vim.diagnostic.get() > 0 then
if quickfix_is_open then
@@ -29,24 +30,29 @@ vim.keymap.set("n", "<leader>q", function()
else
vim.diagnostic.setqflist()
vim.cmd.cfirst()
+ current_quickfix_line = 1
end
end
end)
vim.keymap.set("n", "<M-j>", function()
if #vim.diagnostic.get() > 0 and quickfix_is_open then
- if #vim.diagnostic.get() == 1 then
- vim.cmd.cfirst()
+ if current_quickfix_line < nb_elements_quickfix then
+ vim.cmd.cnext()
+ current_quickfix_line = current_quickfix_line + 1
else
- vim.diagnostic.goto_next({float = false})
+ vim.cmd.cfirst()
+ current_quickfix_line = 1
end
end
end)
vim.keymap.set("n", "<M-k>", function()
if #vim.diagnostic.get() > 0 and quickfix_is_open then
- if #vim.diagnostic.get() == 1 then
- vim.cmd.cfirst()
+ if current_quickfix_line > 1 then
+ vim.cmd.cprev()
+ current_quickfix_line = current_quickfix_line - 1
else
- vim.diagnostic.goto_prev({float = false})
+ vim.cmd.clast()
+ current_quickfix_line = nb_elements_quickfix
end
end
end)