diff options
author | Gregory Anders <8965202+gpanders@users.noreply.github.com> | 2023-12-18 11:04:44 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-18 11:04:44 -0600 |
commit | 3a4aa3fc58f87a295a075fe457bc78805eef7c4d (patch) | |
tree | 7ef5c5cf35ed57de116b0ddfbfd260506b6c2ff9 /test/functional/lua/diagnostic_spec.lua | |
parent | cd1b14f027f375a9de17fdf106016470f52035f7 (diff) | |
download | rneovim-3a4aa3fc58f87a295a075fe457bc78805eef7c4d.tar.gz rneovim-3a4aa3fc58f87a295a075fe457bc78805eef7c4d.tar.bz2 rneovim-3a4aa3fc58f87a295a075fe457bc78805eef7c4d.zip |
refactor: soft-deprecate diagnostic signs configured with :sign-define (#26618)
Diagnostic signs should now be configured with vim.diagnostic.config(),
but "legacy" sign definitions should go through the standard deprecation
process to minimize the impact from breaking changes.
Diffstat (limited to 'test/functional/lua/diagnostic_spec.lua')
-rw-r--r-- | test/functional/lua/diagnostic_spec.lua | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/test/functional/lua/diagnostic_spec.lua b/test/functional/lua/diagnostic_spec.lua index 76963cc69e..688118a085 100644 --- a/test/functional/lua/diagnostic_spec.lua +++ b/test/functional/lua/diagnostic_spec.lua @@ -1537,6 +1537,61 @@ end) eq({}, result) end end) + + it('respects legacy signs placed with :sign define or sign_define #26618', function() + -- Legacy signs for diagnostics were deprecated in 0.10 and will be removed in 0.12 + eq(0, helpers.funcs.has('nvim-0.12')) + + helpers.command('sign define DiagnosticSignError text= texthl= linehl=ErrorMsg numhl=ErrorMsg') + helpers.command('sign define DiagnosticSignWarn text= texthl= linehl=WarningMsg numhl=WarningMsg') + helpers.command('sign define DiagnosticSignInfo text= texthl= linehl=Underlined numhl=Underlined') + helpers.command('sign define DiagnosticSignHint text= texthl= linehl=Underlined numhl=Underlined') + + local result = exec_lua [[ + vim.diagnostic.config({ + signs = true, + }) + + local diagnostics = { + make_error('Error', 1, 1, 1, 2), + make_warning('Warning', 3, 3, 3, 3), + } + + vim.diagnostic.set(diagnostic_ns, diagnostic_bufnr, diagnostics) + + local ns = vim.diagnostic.get_namespace(diagnostic_ns) + local sign_ns = ns.user_data.sign_ns + + local signs = vim.api.nvim_buf_get_extmarks(diagnostic_bufnr, sign_ns, 0, -1, {type ='sign', details = true}) + local result = {} + for _, s in ipairs(signs) do + result[#result + 1] = { + lnum = s[2] + 1, + name = s[4].sign_hl_group, + text = s[4].sign_text or '', + numhl = s[4].number_hl_group, + linehl = s[4].line_hl_group, + } + end + return result + ]] + + eq({ + lnum = 2, + name = 'DiagnosticSignError', + text = '', + numhl = 'ErrorMsg', + linehl = 'ErrorMsg', + }, result[1]) + + eq({ + lnum = 4, + name = 'DiagnosticSignWarn', + text = '', + numhl = 'WarningMsg', + linehl = 'WarningMsg', + }, result[2]) + end) end) describe('open_float()', function() |