aboutsummaryrefslogtreecommitdiff
path: root/test/functional/lua/diagnostic_spec.lua
diff options
context:
space:
mode:
authorDonatas <contactdonatas@gmail.com>2024-10-27 18:36:39 +0200
committerGitHub <noreply@github.com>2024-10-27 11:36:39 -0500
commita9e725b26e08f494a9300d8f63acd3efa9c2da82 (patch)
tree7bf42fdc4aa47f20865db5ec66242ca104340300 /test/functional/lua/diagnostic_spec.lua
parentadf7c98d607b362dd3b25d6d0bee0d1212c472dd (diff)
downloadrneovim-a9e725b26e08f494a9300d8f63acd3efa9c2da82.tar.gz
rneovim-a9e725b26e08f494a9300d8f63acd3efa9c2da82.tar.bz2
rneovim-a9e725b26e08f494a9300d8f63acd3efa9c2da82.zip
feat(diagnostics)!: sort underline severity_sort (#30898)
feat(diagnostics)!: sort underline with severity_sort BREAKING CHANGE: underline will be applied with a higher value than `vim.hl.priorities.diagnostics`
Diffstat (limited to 'test/functional/lua/diagnostic_spec.lua')
-rw-r--r--test/functional/lua/diagnostic_spec.lua34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/functional/lua/diagnostic_spec.lua b/test/functional/lua/diagnostic_spec.lua
index 4ae1146703..eb1ac3e6a1 100644
--- a/test/functional/lua/diagnostic_spec.lua
+++ b/test/functional/lua/diagnostic_spec.lua
@@ -111,6 +111,19 @@ describe('vim.diagnostic', function()
{ details = true }
)
end
+
+ ---@param ns integer
+ function _G.get_underline_extmarks(ns)
+ ---@type integer
+ local underline_ns = vim.diagnostic.get_namespace(ns).user_data.underline_ns
+ return vim.api.nvim_buf_get_extmarks(
+ _G.diagnostic_bufnr,
+ underline_ns,
+ 0,
+ -1,
+ { details = true }
+ )
+ end
end)
exec_lua(function()
@@ -1813,6 +1826,21 @@ describe('vim.diagnostic', function()
_G.make_info('Info', 4, 4, 4, 4),
})
+ function _G.get_highest_underline_hl(severity_sort)
+ vim.diagnostic.config({
+ underline = true,
+ severity_sort = severity_sort,
+ })
+
+ local extmarks = _G.get_underline_extmarks(_G.diagnostic_ns)
+
+ table.sort(extmarks, function(a, b)
+ return a[4].priority > b[4].priority
+ end)
+
+ return extmarks[1][4].hl_group
+ end
+
function _G.get_virt_text_and_signs(severity_sort)
vim.diagnostic.config({
severity_sort = severity_sort,
@@ -1864,6 +1892,12 @@ describe('vim.diagnostic', function()
result = exec_lua [[return _G.get_virt_text_and_signs({ reverse = true })]]
eq({ 'Error', 'Warn', 'Info' }, result[1])
eq({ 'Info', 'Warn', 'Error' }, result[2])
+
+ local underline_hl = exec_lua [[return _G.get_highest_underline_hl(true)]]
+ eq('DiagnosticUnderlineError', underline_hl)
+
+ underline_hl = exec_lua [[return _G.get_highest_underline_hl({ reverse = true })]]
+ eq('DiagnosticUnderlineInfo', underline_hl)
end)
it('can show diagnostic sources in virtual text', function()