aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua
diff options
context:
space:
mode:
authorGregory Anders <8965202+gpanders@users.noreply.github.com>2023-12-18 11:04:44 -0600
committerGitHub <noreply@github.com>2023-12-18 11:04:44 -0600
commit3a4aa3fc58f87a295a075fe457bc78805eef7c4d (patch)
tree7ef5c5cf35ed57de116b0ddfbfd260506b6c2ff9 /runtime/lua
parentcd1b14f027f375a9de17fdf106016470f52035f7 (diff)
downloadrneovim-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 'runtime/lua')
-rw-r--r--runtime/lua/vim/diagnostic.lua49
1 files changed, 47 insertions, 2 deletions
diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua
index e4f694b8a2..6d2c212dfc 100644
--- a/runtime/lua/vim/diagnostic.lua
+++ b/runtime/lua/vim/diagnostic.lua
@@ -588,7 +588,7 @@ end
--- return diagnostic.message
--- end
--- </pre>
---- - signs: (default true) Use signs for diagnostics. Options:
+--- - signs: (default true) Use signs for diagnostics |diagnostic-signs|. Options:
--- * severity: Only show signs for diagnostics matching the given
--- severity |diagnostic-severity|
--- * priority: (number, default 10) Base priority to use for signs. When
@@ -883,7 +883,52 @@ M.handlers.signs = {
api.nvim_create_namespace(string.format('%s/diagnostic/signs', ns.name))
end
- local text = {}
+ --- Handle legacy diagnostic sign definitions
+ --- These were deprecated in 0.10 and will be removed in 0.12
+ if opts.signs and not opts.signs.text and not opts.signs.numhl and not opts.signs.texthl then
+ for _, v in ipairs({ 'Error', 'Warn', 'Info', 'Hint' }) do
+ local name = string.format('DiagnosticSign%s', v)
+ local sign = vim.fn.sign_getdefined(name)[1]
+ if sign then
+ local severity = M.severity[v:upper()]
+ if vim.fn.has('nvim-0.11') == 1 then
+ vim.deprecate(
+ 'Defining diagnostic signs with :sign-define or sign_define()',
+ 'vim.diagnostic.config()',
+ '0.12',
+ nil,
+ false
+ )
+ end
+
+ if not opts.signs.text then
+ opts.signs.text = {}
+ end
+
+ if not opts.signs.numhl then
+ opts.signs.numhl = {}
+ end
+
+ if not opts.signs.linehl then
+ opts.signs.linehl = {}
+ end
+
+ if opts.signs.text[severity] == nil then
+ opts.signs.text[severity] = sign.text or ''
+ end
+
+ if opts.signs.numhl[severity] == nil then
+ opts.signs.numhl[severity] = sign.numhl
+ end
+
+ if opts.signs.linehl[severity] == nil then
+ opts.signs.linehl[severity] = sign.linehl
+ end
+ end
+ end
+ end
+
+ local text = {} ---@type table<string, string>
for k in pairs(M.severity) do
if opts.signs.text and opts.signs.text[k] then
text[k] = opts.signs.text[k]