docs(diagnostics): location list / quickfix example #31371

This commit is contained in:
Yochem van Rosmalen 2024-11-29 19:07:08 +01:00 committed by GitHub
parent 3056115785
commit 2833925cfc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -163,6 +163,33 @@ show a sign for the highest severity diagnostic on a given line: >lua
}
<
*diagnostic-loclist-example*
Whenever the |location-list| is opened, the following `show` handler will show
the most recent diagnostics: >lua
vim.diagnostic.handlers.loclist = {
show = function(_, _, _, opts)
-- Generally don't want it to open on every update
opts.loclist.open = opts.loclist.open or false
local winid = vim.api.nvim_get_current_win()
vim.diagnostic.setloclist(opts.loclist)
vim.api.nvim_set_current_win(winid)
end
}
<
The handler accepts the same options as |vim.diagnostic.setloclist()| and can be
configured using |vim.diagnostic.config()|: >lua
-- Open the location list on every diagnostic change (warnings/errors only).
vim.diagnostic.config({
loclist = {
open = true,
severity = { min = vim.diagnostic.severity.WARN },
}
})
<
==============================================================================
HIGHLIGHTS *diagnostic-highlights*