feat(diagnostic): add format option to setloclist/setqflist (#33977)

This commit is contained in:
Maria José Solano
2025-05-12 19:50:37 -05:00
committed by GitHub
parent c681336e3c
commit 2f24ae8de4
4 changed files with 78 additions and 1 deletions

View File

@@ -909,6 +909,9 @@ local function set_list(loclist, opts)
-- Don't clamp line numbers since the quickfix list can already handle line
-- numbers beyond the end of the buffer
local diagnostics = get_diagnostics(bufnr, opts --[[@as vim.diagnostic.GetOpts]], false)
if opts.format then
diagnostics = reformat_diagnostics(opts.format, diagnostics)
end
local items = M.toqflist(diagnostics)
local qf_id = nil
if loclist then
@@ -2361,6 +2364,11 @@ end
---
--- See |diagnostic-severity|.
--- @field severity? vim.diagnostic.SeverityFilter
---
--- A function that takes a diagnostic as input and returns a string or nil.
--- If the return value is nil, the diagnostic is not displayed in the quickfix list.
--- Else the output text is used to display the diagnostic.
--- @field format? fun(diagnostic:vim.Diagnostic): string?
--- Add all diagnostics to the quickfix list.
---
@@ -2389,6 +2397,11 @@ end
---
--- See |diagnostic-severity|.
--- @field severity? vim.diagnostic.SeverityFilter
---
--- A function that takes a diagnostic as input and returns a string or nil.
--- If the return value is nil, the diagnostic is not displayed in the location list.
--- Else the output text is used to display the diagnostic.
--- @field format? fun(diagnostic:vim.Diagnostic): string?
--- Add buffer diagnostics to the location list.
---