The gitsigns keymaps were defined in on_attach, so they were buffer-local and created asynchronously - gitsigns shells out to git before attaching. which-key had already built its keymap tree for the buffer by then, and it only invalidates that cache on BufReadPost, BufNew and LspAttach, so maps added afterwards stayed invisible. Buf:get() returns cached mode state unless explicitly passed `update`, which is why re-entering the buffer didn't help either. Mapping globally instead means the maps exist before which-key builds any tree. The gitsigns API no-ops in buffers it hasn't attached to (checked stage/reset/preview/blame/nav in a non-git directory), so the only change is that the maps now exist everywhere rather than just in git-tracked buffers. Also puts the diagnostic float and quickfix list on <leader>d. Nvim already binds <C-W>d and ]d/[d for these, so this is a rebinding for discoverability rather than new capability. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
23 lines
660 B
Lua
23 lines
660 B
Lua
local sev = vim.diagnostic.severity
|
|
|
|
vim.diagnostic.config({
|
|
severity_sort = true,
|
|
update_in_insert = false,
|
|
float = {
|
|
border = 'rounded',
|
|
source = true,
|
|
},
|
|
signs = {
|
|
text = {
|
|
[sev.ERROR] = 'E',
|
|
[sev.WARN] = 'W',
|
|
[sev.INFO] = 'I',
|
|
[sev.HINT] = 'H',
|
|
},
|
|
},
|
|
})
|
|
|
|
-- Nvim already binds ]d / [d to jump and <C-W>d to show the diagnostic under
|
|
-- the cursor; these put the same actions on <leader> so which-key lists them.
|
|
vim.keymap.set('n', '<leader>dd', vim.diagnostic.open_float, { desc = 'Show diagnostic' })
|
|
vim.keymap.set('n', '<leader>dq', vim.diagnostic.setqflist, { desc = 'Diagnostics to quickfix' })
|