Hide signs with lower priorities when using `maxwidth`
przepompownia opened this issue · comments
Branch: 0.10.
I started from explaining myself why do I get displayed two signs with the same priority if I use the example from :h diagnostic-handlers-example
and the new foldclosed
option. After looking into
statuscol.nvim/lua/statuscol.lua
Lines 171 to 178 in b9e87ca
maxwidth
value from 2
to 1
in my config. At the first glance it seemed for me that I can drop using :h diagnostic-handlers-example
in this case. It's not because the loop doesn't get the n+1
-th sign for the same line if maxwidth = n
.
Example independent of foldclosed
setting (and maybe 0.10
branch):
local ns = vim.api.nvim_create_namespace('example')
vim.diagnostic.reset(ns, 0)
vim.diagnostic.set(ns, 0, {
{
bufnr = 0,
col = 1,
lnum = 3,
message = 'Warn',
severity = vim.diagnostic.severity.WARN,
},
{
bufnr = 0,
col = 1,
lnum = 3,
message = 'Error',
severity = vim.diagnostic.severity.ERROR,
},
})
I don't fully understand your issue but we only sort by extmark priority, not diagnostic severity:
:=a.nvim_buf_get_extmarks(0, -1, 0, -1, {type='sign', details=true})
{ { 2, 3, 0, {
ns_id = 10,
priority = 10,
right_gravity = true,
sign_hl_group = "DiagnosticSignError",
sign_text = " "
} }, { 1, 3, 0, {
ns_id = 10,
priority = 10,
right_gravity = true,
sign_hl_group = "DiagnosticSignWarn",
sign_text = " "
} } }
I wonder why all diagnostic signs have the same priority, which sign gets shown is random/arbitrary it seems.
Ah, there is a "severity_sort"
key in vim.diagnostic.config()
, if you set that to true, the highest severity diagnostic sign will show.