neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 570e62d0f99dbc99e4f506ad1b874bb1842159d0
parent 4fae013a21a9bb14cec684438ab9bea44c3aee1e
Author: Maria José Solano <majosolano99@gmail.com>
Date:   Tue, 13 May 2025 21:39:05 -0500

docs(diagnostic): add `on_jump` example (#33933)


Diffstat:
Mruntime/doc/diagnostic.txt | 22++++++++++++++++++++++
1 file changed, 22 insertions(+), 0 deletions(-)

diff --git a/runtime/doc/diagnostic.txt b/runtime/doc/diagnostic.txt @@ -180,6 +180,28 @@ the `virtual_lines` handler with the following keymap: >lua end, { desc = 'Toggle diagnostic virtual_lines' }) < + *diagnostic-on-jump-example* +You can use the `on_jump` option from |vim.diagnostic.jump()| to show the +diagnostic that was jumped to using a specific handler. For example, the +following uses the `virtual_lines` handler when jumping to a diagnostic: >lua + + local virt_lines_ns = vim.api.nvim_create_namespace 'on_diagnostic_jump' + + --- @param diagnostic? vim.Diagnostic + --- @param bufnr integer + local function on_jump(diagnostic, bufnr) + if not diagnostic then return end + + vim.diagnostic.show( + virt_lines_ns, + bufnr, + { diagnostic }, + { virtual_lines = { current_line = true }, virtual_text = false } + ) + end + + vim.diagnostic.config({ jump = { on_jump = on_jump } }) + *diagnostic-loclist-example* Whenever the |location-list| is opened, the following `show` handler will show the most recent diagnostics: >lua