mirror of
https://github.com/neovim/neovim.git
synced 2025-09-11 22:08:18 +00:00
fix(diagnostic): virtual_text prefix function should have index and total (#25801)
The prefix option of the diagnostic virtual text can be a function, but previously it was only a function of diagnostic. This function should also have additional parameters index and total, more consistently and similarily as in the prefix function for `vim.diagnostic.open_float()`. These additional parameters will be useful when there are too many number of diagnostics in a single line.
This commit is contained in:
@@ -1237,7 +1237,7 @@ end)
|
||||
return prefix .. message
|
||||
]])
|
||||
|
||||
eq('[err-code] Some error', exec_lua [[
|
||||
eq('[(1/1) err-code] Some error', exec_lua [[
|
||||
local diagnostics = {
|
||||
make_error('Some error', 0, 0, 0, 0, nil, 'err-code'),
|
||||
}
|
||||
@@ -1245,7 +1245,7 @@ end)
|
||||
vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, diagnostics, {
|
||||
underline = false,
|
||||
virtual_text = {
|
||||
prefix = function(diag) return string.format('[%s]', diag.code) end,
|
||||
prefix = function(diag, i, total) return string.format('[(%d/%d) %s]', i, total, diag.code) end,
|
||||
suffix = '',
|
||||
}
|
||||
})
|
||||
|
Reference in New Issue
Block a user