Skip to content

Commit 7378f8d

Browse files
committed
feat(lsp): update key mappings for diagnostics and errors
- Users can now jump to the previous and next errors using new key mappings. - The key mapping for opening workspace diagnostics has been changed for clarity. - Updated documentation to reflect the new key mappings for diagnostics and error navigation.
1 parent b47cf8a commit 7378f8d

4 files changed

Lines changed: 22 additions & 9 deletions

File tree

lazy-lock.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" },
1010
"lazydev.nvim": { "branch": "main", "commit": "2367a6c0a01eb9edb0464731cc0fb61ed9ab9d2c" },
1111
"mason.nvim": { "branch": "main", "commit": "8024d64e1330b86044fed4c8494ef3dcd483a67c" },
12-
"mini.ai": { "branch": "main", "commit": "34f187f70fa485ac934772a410a44f4b93fd1874" },
12+
"mini.ai": { "branch": "main", "commit": "e66a71449bdf719b4b9c96e0cd7b7d6cc4112f88" },
1313
"mini.align": { "branch": "main", "commit": "cf210e2f270fcc0361ad3580d00053bb66c94cbf" },
1414
"mini.clue": { "branch": "main", "commit": "9d3001a921809f951e4fed04e0b0275bec778d6c" },
1515
"mini.diff": { "branch": "main", "commit": "63a7ce537ced356b8180892d9586826b0afb519c" },
@@ -18,7 +18,7 @@
1818
"mini.notify": { "branch": "main", "commit": "9996951977b503b8c9572a0bdb2c516f099701f9" },
1919
"mini.operators": { "branch": "main", "commit": "f6945e0655ba0715a469dfa4ebdd6039d4b56658" },
2020
"mini.pairs": { "branch": "main", "commit": "42407ccb80ec59c84e7c91d815f42ed90a8cc093" },
21-
"mini.surround": { "branch": "main", "commit": "6f21f10285f145e16cbb65aa816bf17302be8352" },
21+
"mini.surround": { "branch": "main", "commit": "f59022c2c66c1cffd3cd755b105faa468b25a4e0" },
2222
"nvim-dap": { "branch": "master", "commit": "5dd4d50f2e6a2eaf9e57fad023d294ef371bda35" },
2323
"nvim-dap-view": { "branch": "main", "commit": "280213aa7a553c03fccf97771e340f991706478c" },
2424
"nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" },

lua/plugins/dap.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ return {
3535
{ "<f17>", dap.terminate, "Stop session" }, -- <s-f5>
3636
{ "<f10>", dap.step_over, "Step Over" },
3737
{ "<f11>", dap.step_into, "Step Into" },
38-
{ "<f23>", dap.step_out, "Step Out" }, -- <s-f11
38+
{ "<f23>", dap.step_out, "Step Out" }, -- <s-f11>
3939
}
4040

4141
return vim.fn.get_lazy_keys_conf(mappings, "Debug")

plugin/autocmds/lsp-attach.lua

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,19 @@ local function diagnostics()
4141
current_line = true,
4242
},
4343
})
44+
45+
local k = vim.keymap.set
46+
47+
local function jump_to_error(direction)
48+
return function()
49+
local count = direction == "next" and 1 or -1
50+
local opts = { count = count, severity = vim.diagnostic.severity.ERROR, float = true }
51+
vim.diagnostic.jump(opts)
52+
end
53+
end
54+
55+
k("n", "[x", jump_to_error("prev"), { desc = "Jump to previous error", silent = true })
56+
k("n", "]x", jump_to_error("next"), { desc = "Jump to next error", silent = true })
4457
end
4558

4659
-- Set keymaps for LSP
@@ -77,8 +90,8 @@ local function keymaps(bufnr, client)
7790
k("gD", vim.lsp.buf.declaration, "Jump to declaration")
7891
k("grr", snacks.picker.lsp_references, "References")
7992
k("gO", snacks.picker.lsp_symbols, "Symbols")
80-
k("<leader>xx", snacks.picker.diagnostics, "Diagnostics: Workspace")
81-
k("<leader>xf", snacks.picker.diagnostics_buffer, "Diagnostics: File")
93+
k("<leader>xX", snacks.picker.diagnostics, "Diagnostics: Workspace")
94+
k("<leader>xx", snacks.picker.diagnostics_buffer, "Diagnostics: File")
8295
k("K", hover, "Hover")
8396

8497
if client:supports_method(methods.textDocument_typeDefinition) then

readme.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -312,10 +312,10 @@ Random features added.
312312
- `<c-s>` display signature help
313313
- `<c-]>` jump to definition
314314
- `<c-w>]` jump to definition (vslipt)
315-
- `<leader>xx` open diagnostics (workspace)
316-
- `<leader>xf` open diagnostics (buffer)
317-
- `[x` jump to previous diagnostic
318-
- `]x` jump to next diagnostic
315+
- `<leader>xx` open diagnostics (buffer)
316+
- `<leader>xX` open diagnostics (workspace)
317+
- `[x` jump to previous error
318+
- `]x` jump to next error
319319

320320
### Debugger:
321321

0 commit comments

Comments
 (0)