mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 18:55:14 -07:00
Merge pull request #26555 from gpanders/diagnostic-sign-fixup
Diagnostic sign fixups
This commit is contained in:
commit
ad6c4c2e9d
@ -442,9 +442,15 @@ config({opts}, {namespace}) *vim.diagnostic.config()*
|
||||
Example: >lua
|
||||
|
||||
vim.diagnostic.config({
|
||||
sign = { text = { [vim.diagnostic.severity.ERROR] = 'E', ... } }
|
||||
signs = { text = { [vim.diagnostic.severity.ERROR] = 'E', ... } }
|
||||
})
|
||||
<
|
||||
• numhl: (table) A table mapping |diagnostic-severity|
|
||||
to the highlight group used for the line number where
|
||||
the sign is placed.
|
||||
• linehl: (table) A table mapping |diagnostic-severity|
|
||||
to the highlight group used for the whole line the
|
||||
sign is placed in.
|
||||
|
||||
• float: Options for floating windows. See
|
||||
|vim.diagnostic.open_float()|.
|
||||
|
@ -599,9 +599,13 @@ end
|
||||
--- for errors, warnings, information, and hints, respectively. Example:
|
||||
--- <pre>lua
|
||||
--- vim.diagnostic.config({
|
||||
--- sign = { text = { [vim.diagnostic.severity.ERROR] = 'E', ... } }
|
||||
--- signs = { text = { [vim.diagnostic.severity.ERROR] = 'E', ... } }
|
||||
--- })
|
||||
--- </pre>
|
||||
--- * numhl: (table) A table mapping |diagnostic-severity| to the highlight
|
||||
--- group used for the line number where the sign is placed.
|
||||
--- * linehl: (table) A table mapping |diagnostic-severity| to the highlight group
|
||||
--- used for the whole line the sign is placed in.
|
||||
--- - float: Options for floating windows. See |vim.diagnostic.open_float()|.
|
||||
--- - update_in_insert: (default false) Update diagnostics in Insert mode (if false,
|
||||
--- diagnostics are updated on InsertLeave)
|
||||
@ -885,11 +889,16 @@ M.handlers.signs = {
|
||||
end
|
||||
end
|
||||
|
||||
local numhl = opts.signs.numhl or {}
|
||||
local linehl = opts.signs.linehl or {}
|
||||
|
||||
for _, diagnostic in ipairs(diagnostics) do
|
||||
if api.nvim_buf_is_loaded(diagnostic.bufnr) then
|
||||
api.nvim_buf_set_extmark(bufnr, ns.user_data.sign_ns, diagnostic.lnum, 0, {
|
||||
sign_text = text[diagnostic.severity] or text[M.severity[diagnostic.severity]] or 'U',
|
||||
sign_hl_group = sign_highlight_map[diagnostic.severity],
|
||||
number_hl_group = numhl[diagnostic.severity],
|
||||
line_hl_group = linehl[diagnostic.severity],
|
||||
priority = get_priority(diagnostic.severity),
|
||||
})
|
||||
end
|
||||
@ -897,7 +906,7 @@ M.handlers.signs = {
|
||||
end,
|
||||
hide = function(namespace, bufnr)
|
||||
local ns = M.get_namespace(namespace)
|
||||
if ns.user_data.sign_group and api.nvim_buf_is_valid(bufnr) then
|
||||
if ns.user_data.sign_ns and api.nvim_buf_is_valid(bufnr) then
|
||||
api.nvim_buf_clear_namespace(bufnr, ns.user_data.sign_ns, 0, -1)
|
||||
end
|
||||
end,
|
||||
|
@ -1495,7 +1495,8 @@ end)
|
||||
]])
|
||||
end)
|
||||
|
||||
it('sets signs', function()
|
||||
it('sets and clears signs #26193 #26555', function()
|
||||
do
|
||||
local result = exec_lua [[
|
||||
vim.diagnostic.config({
|
||||
signs = true,
|
||||
@ -1521,6 +1522,20 @@ end)
|
||||
|
||||
eq({2, 'DiagnosticSignError'}, {result[1].lnum, result[1].name})
|
||||
eq({4, 'DiagnosticSignWarn'}, {result[2].lnum, result[2].name})
|
||||
end
|
||||
|
||||
do
|
||||
local result = exec_lua [[
|
||||
vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, {})
|
||||
|
||||
local ns = vim.diagnostic.get_namespace(diagnostic_ns)
|
||||
local sign_ns = ns.user_data.sign_ns
|
||||
|
||||
return vim.api.nvim_buf_get_extmarks(diagnostic_bufnr, sign_ns, 0, -1, {type ='sign', details = true})
|
||||
]]
|
||||
|
||||
eq({}, result)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user