diff options
| -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) |
