How do I use Neovim 0.11's unified diagnostic jump API to navigate to the next or previous diagnostic?
Answer
vim.diagnostic.jump({count=1})
Explanation
Neovim 0.11 introduced vim.diagnostic.jump() as a single, unified function replacing the older vim.diagnostic.goto_next() and vim.diagnostic.goto_prev() pair. It gives you finer control over diagnostic navigation through a single, consistent API with support for direction, severity filtering, and floating window display.
How it works
countcontrols direction and distance: positive values move forward, negative values move backwardseverityrestricts jumps to a specific diagnostic levelwrap(defaulttrue) controls whether navigation wraps around the end of the filefloatcontrols whether a floating window with the diagnostic message is shown on jump
-- Jump to next diagnostic (any severity)
vim.diagnostic.jump({ count = 1 })
-- Jump to previous diagnostic
vim.diagnostic.jump({ count = -1 })
-- Jump forward, errors only, show float
vim.diagnostic.jump({ count = 1, severity = vim.diagnostic.severity.ERROR, float = true })
Example
A typical keybinding setup in your Neovim config:
vim.keymap.set('n', ']d', function()
vim.diagnostic.jump({ count = 1, float = true })
end)
vim.keymap.set('n', '[d', function()
vim.diagnostic.jump({ count = -1, float = true })
end)
vim.keymap.set('n', ']e', function()
vim.diagnostic.jump({ count = 1, severity = vim.diagnostic.severity.ERROR })
end)
Tips
vim.diagnostic.goto_next()andvim.diagnostic.goto_prev()are deprecated in Neovim 0.11 — migrate tojump()- Passing
count = 2skips ahead two diagnostics in a single call - The
floatoption accepts either a boolean or a table of options passed tovim.diagnostic.open_float()