commit a8361c3afc5b9281814e9f16a9d4291e095b38fa
parent ab8371a26cf47a40d26af637455ea71da0d5a59d
Author: Sergei Slipchenko <faergeek@gmail.com>
Date: Mon, 2 Mar 2026 21:51:31 +0400
docs(diagnostics): use the original namespace in "on-jump" example (#38124)
Problem: currently in the example a new diagnostic namespace is created
for showing it manually with a custom config. Because of a separate
namespace, when the original diagnostic source sets diagnostics again,
it will not affect the diagnostic shown in that new namespace and the
user would need to implement the logic for hiding it themselves,
separately as well.
Solution: instead of creating a new namespace, reuse the original
diagnostic's namespace, so once the source sets diagnostics again, it's
removed and hidden automatically without user having to do anything
extra for that.
Diffstat:
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/runtime/doc/diagnostic.txt b/runtime/doc/diagnostic.txt
@@ -192,15 +192,13 @@ 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,
+ diagnostic.namespace
bufnr,
{ diagnostic },
{ virtual_lines = { current_line = true }, virtual_text = false }