From 167171b4d9f4d5e3364d82280d5fe4d4509ed0df Mon Sep 17 00:00:00 2001 From: Aotrix Date: Mon, 3 Mar 2025 15:29:18 +0100 Subject: added quickfix looping --- lua/aotrix/quickfix.lua | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'lua') 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", "q", function() if #vim.diagnostic.get() > 0 then if quickfix_is_open then @@ -29,24 +30,29 @@ vim.keymap.set("n", "q", function() else vim.diagnostic.setqflist() vim.cmd.cfirst() + current_quickfix_line = 1 end end end) vim.keymap.set("n", "", 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", "", 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) -- cgit v1.2.3