Skip to content

Commit 60e6b68

Browse files
committed
feat(qf): add key mappings for quickfix navigation
- Users can now navigate to the next quickfix item with Ctrl+j. - Users can navigate to the previous quickfix item with Ctrl+k. - Pressing Enter on a quickfix item opens it and closes the quickfix window.
1 parent 4ebdc88 commit 60e6b68

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

after/ftplugin/qf.lua

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
11
vim.opt_local.relativenumber = false
22
vim.opt_local.statusline = "%!v:lua._G.status_line_qf()"
33
vim.opt_local.cursorline = true
4+
5+
vim.keymap.set("n", "<c-j>", "j", { desc = "Next quickfix item", buffer = true })
6+
vim.keymap.set("n", "<c-k>", "k", { desc = "Previous quickfix item", buffer = true })
7+
8+
vim.keymap.set("n", "<cr>", function()
9+
local item = vim.fn.getqflist()[vim.fn.line(".")]
10+
if item and item.valid == 1 then
11+
vim.cmd("cc " .. vim.fn.line("."))
12+
vim.cmd("cclose")
13+
end
14+
end, { buffer = true, desc = "Open item and close quickfix" })

0 commit comments

Comments
 (0)