diff options
| author | Aotrix <[email protected]> | 2025-03-03 19:34:20 +0100 |
|---|---|---|
| committer | Aotrix <[email protected]> | 2025-03-03 19:34:20 +0100 |
| commit | 9478a8611b46399f9d2925c86ef5517650691feb (patch) | |
| tree | 3b951beb5fd00db1203f1a6f972a1957a5f04c94 /lua/aotrix/quickfix.lua | |
| parent | 1c3e92203bc04acc1b2f5c2233d389de079bf625 (diff) | |
added quickfix loop
Diffstat (limited to 'lua/aotrix/quickfix.lua')
| -rw-r--r-- | lua/aotrix/quickfix.lua | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/lua/aotrix/quickfix.lua b/lua/aotrix/quickfix.lua index f1f1008..71a8677 100644 --- a/lua/aotrix/quickfix.lua +++ b/lua/aotrix/quickfix.lua @@ -21,7 +21,9 @@ vim.api.nvim_create_autocmd('DiagnosticChanged', { end end }) -local current_quickfix_line = 1 +local get_current_quickfix_index = function() + return tonumber(vim.fn.getqflist({idx = 0})['idx']) +end vim.keymap.set("n", "<leader>q", function() if #vim.diagnostic.get() > 0 then if quickfix_is_open then @@ -30,29 +32,24 @@ 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 current_quickfix_line < nb_elements_quickfix then + if get_current_quickfix_index() < nb_elements_quickfix then vim.cmd.cnext() - current_quickfix_line = current_quickfix_line + 1 else 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 current_quickfix_line > 1 then + if get_current_quickfix_index() > 1 then vim.cmd.cprev() - current_quickfix_line = current_quickfix_line - 1 else vim.cmd.clast() - current_quickfix_line = nb_elements_quickfix end end end) |
