mirror of
https://github.com/neovim/neovim.git
synced 2026-06-19 18:12:35 +00:00
fix(diagnostic): stack _tags hl-groups in a single extmark #38654
Problem: Diagnostic highlight groups were applied by iterating and calling `vim.hl.range` for each group individually. That resulted in multiple extmarks with the same priority being created separately, which does not allow `DiagnosticUnnecessary` and `DiagnosticDeprecated` with matching options override `Diagnostic*` styling. Solution: Pass the list of hl-groups to `vim.hl.range` so they are applied together in the correct order.
This commit is contained in:
@@ -280,16 +280,14 @@ function M.underline.show(namespace, bufnr, diagnostics, opts)
|
||||
local lines =
|
||||
api.nvim_buf_get_lines(diagnostic0.bufnr, diagnostic0.lnum, diagnostic0.lnum + 1, true)
|
||||
|
||||
for _, higroup in ipairs(higroups) do
|
||||
vim.hl.range(
|
||||
bufnr,
|
||||
underline_ns,
|
||||
higroup,
|
||||
{ diagnostic0.lnum, math.min(diagnostic0.col, #lines[1] - 1) },
|
||||
{ diagnostic0.end_lnum, diagnostic0.end_col },
|
||||
{ priority = get_priority(diagnostic0.severity) }
|
||||
)
|
||||
end
|
||||
vim.hl.range(
|
||||
bufnr,
|
||||
underline_ns,
|
||||
higroups,
|
||||
{ diagnostic0.lnum, math.min(diagnostic0.col, #lines[1] - 1) },
|
||||
{ diagnostic0.end_lnum, diagnostic0.end_col },
|
||||
{ priority = get_priority(diagnostic0.severity) }
|
||||
)
|
||||
end
|
||||
|
||||
save_extmarks(underline_ns, bufnr)
|
||||
|
||||
@@ -40,7 +40,8 @@ M.priorities = {
|
||||
---
|
||||
---@param buf integer Buffer number to apply highlighting to
|
||||
---@param ns integer Namespace to add highlight to
|
||||
---@param higroup string Highlight group to use for highlighting
|
||||
---@param higroup integer|integer[]|string|string[] Highlight group used for the text range.
|
||||
--- See the `hl_group` option in |nvim_buf_set_extmark()|.
|
||||
---@param start [integer,integer]|string Start of region as a (line, column) tuple or string accepted by |getpos()|
|
||||
---@param finish [integer,integer]|string End of region as a (line, column) tuple or string accepted by |getpos()|
|
||||
---@param opts? vim.hl.range.Opts
|
||||
|
||||
Reference in New Issue
Block a user