mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge pull request #17045 from gpanders/diagnostic-fixups
Various diagnostic fixups
This commit is contained in:
commit
f92a2457c2
@ -334,8 +334,9 @@ config({opts}, {namespace}) *vim.diagnostic.config()*
|
|||||||
that returns any of the above.
|
that returns any of the above.
|
||||||
|
|
||||||
Parameters: ~
|
Parameters: ~
|
||||||
{opts} table Configuration table with the following
|
{opts} table|nil When omitted or "nil", retrieve the
|
||||||
keys:
|
current configuration. Otherwise, a
|
||||||
|
configuration table with the following keys:
|
||||||
• underline: (default true) Use underline for
|
• underline: (default true) Use underline for
|
||||||
diagnostics. Options:
|
diagnostics. Options:
|
||||||
• severity: Only underline diagnostics
|
• severity: Only underline diagnostics
|
||||||
|
@ -30,7 +30,7 @@ M.handlers = setmetatable({}, {
|
|||||||
__newindex = function(t, name, handler)
|
__newindex = function(t, name, handler)
|
||||||
vim.validate { handler = {handler, "t" } }
|
vim.validate { handler = {handler, "t" } }
|
||||||
rawset(t, name, handler)
|
rawset(t, name, handler)
|
||||||
if not global_diagnostic_options[name] then
|
if global_diagnostic_options[name] == nil then
|
||||||
global_diagnostic_options[name] = true
|
global_diagnostic_options[name] = true
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
@ -552,7 +552,8 @@ end
|
|||||||
--- - `table`: Enable this feature with overrides. Use an empty table to use default values.
|
--- - `table`: Enable this feature with overrides. Use an empty table to use default values.
|
||||||
--- - `function`: Function with signature (namespace, bufnr) that returns any of the above.
|
--- - `function`: Function with signature (namespace, bufnr) that returns any of the above.
|
||||||
---
|
---
|
||||||
---@param opts table Configuration table with the following keys:
|
---@param opts table|nil When omitted or "nil", retrieve the current configuration. Otherwise, a
|
||||||
|
--- configuration table with the following keys:
|
||||||
--- - underline: (default true) Use underline for diagnostics. Options:
|
--- - underline: (default true) Use underline for diagnostics. Options:
|
||||||
--- * severity: Only underline diagnostics matching the given severity
|
--- * severity: Only underline diagnostics matching the given severity
|
||||||
--- |diagnostic-severity|
|
--- |diagnostic-severity|
|
||||||
@ -599,7 +600,7 @@ end
|
|||||||
--- global diagnostic options.
|
--- global diagnostic options.
|
||||||
function M.config(opts, namespace)
|
function M.config(opts, namespace)
|
||||||
vim.validate {
|
vim.validate {
|
||||||
opts = { opts, 't' },
|
opts = { opts, 't', true },
|
||||||
namespace = { namespace, 'n', true },
|
namespace = { namespace, 'n', true },
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -611,10 +612,13 @@ function M.config(opts, namespace)
|
|||||||
t = global_diagnostic_options
|
t = global_diagnostic_options
|
||||||
end
|
end
|
||||||
|
|
||||||
for opt in pairs(global_diagnostic_options) do
|
if not opts then
|
||||||
if opts[opt] ~= nil then
|
-- Return current config
|
||||||
t[opt] = opts[opt]
|
return vim.deepcopy(t)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
for k, v in pairs(opts) do
|
||||||
|
t[k] = v
|
||||||
end
|
end
|
||||||
|
|
||||||
if namespace then
|
if namespace then
|
||||||
@ -823,6 +827,7 @@ M.handlers.signs = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bufnr = get_bufnr(bufnr)
|
bufnr = get_bufnr(bufnr)
|
||||||
|
opts = opts or {}
|
||||||
|
|
||||||
if opts.signs and opts.signs.severity then
|
if opts.signs and opts.signs.severity then
|
||||||
diagnostics = filter_by_severity(opts.signs.severity, diagnostics)
|
diagnostics = filter_by_severity(opts.signs.severity, diagnostics)
|
||||||
@ -890,6 +895,7 @@ M.handlers.underline = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bufnr = get_bufnr(bufnr)
|
bufnr = get_bufnr(bufnr)
|
||||||
|
opts = opts or {}
|
||||||
|
|
||||||
if opts.underline and opts.underline.severity then
|
if opts.underline and opts.underline.severity then
|
||||||
diagnostics = filter_by_severity(opts.underline.severity, diagnostics)
|
diagnostics = filter_by_severity(opts.underline.severity, diagnostics)
|
||||||
@ -942,6 +948,7 @@ M.handlers.virtual_text = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bufnr = get_bufnr(bufnr)
|
bufnr = get_bufnr(bufnr)
|
||||||
|
opts = opts or {}
|
||||||
|
|
||||||
local severity
|
local severity
|
||||||
if opts.virtual_text then
|
if opts.virtual_text then
|
||||||
|
Loading…
Reference in New Issue
Block a user