aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/diagnostic.lua
diff options
context:
space:
mode:
authorLewis Russell <lewis6991@gmail.com>2023-03-30 14:49:58 +0100
committerGitHub <noreply@github.com>2023-03-30 14:49:58 +0100
commit226a6c3eaef2a7220841d3d5e69e1baf543b3d6f (patch)
tree394cafe6a57a124635941517b2acd94d9d850efa /runtime/lua/vim/diagnostic.lua
parent8fa7d833cf3a6c906c91c5acf9187b4544cf94be (diff)
downloadrneovim-226a6c3eaef2a7220841d3d5e69e1baf543b3d6f.tar.gz
rneovim-226a6c3eaef2a7220841d3d5e69e1baf543b3d6f.tar.bz2
rneovim-226a6c3eaef2a7220841d3d5e69e1baf543b3d6f.zip
feat(diagnostic): add support for tags
The LSP spec supports two tags that can be added to diagnostics: unnecessary and deprecated. Extend vim.diagnostic to be able to handle these.
Diffstat (limited to 'runtime/lua/vim/diagnostic.lua')
-rw-r--r--runtime/lua/vim/diagnostic.lua12
1 files changed, 12 insertions, 0 deletions
diff --git a/runtime/lua/vim/diagnostic.lua b/runtime/lua/vim/diagnostic.lua
index 56532d0184..714038f8e4 100644
--- a/runtime/lua/vim/diagnostic.lua
+++ b/runtime/lua/vim/diagnostic.lua
@@ -483,6 +483,7 @@ local function next_diagnostic(position, search_forward, bufnr, opts, namespace)
local diagnostics =
get_diagnostics(bufnr, vim.tbl_extend('keep', opts, { namespace = namespace }), true)
local line_diagnostics = diagnostic_lines(diagnostics)
+
for i = 0, line_count do
local offset = i * (search_forward and 1 or -1)
local lnum = position[1] + offset
@@ -752,6 +753,7 @@ end
---@field message string
---@field source nil|string
---@field code nil|string
+---@field _tags { deprecated: boolean, unnecessary: boolean}
---@field user_data nil|any arbitrary data plugins can add
--- Get current diagnostics.
@@ -948,6 +950,16 @@ M.handlers.underline = {
higroup = underline_highlight_map.Error
end
+ if diagnostic._tags then
+ -- TODO(lewis6991): we should be able to stack these.
+ if diagnostic._tags.unnecessary then
+ higroup = 'DiagnosticUnnecessary'
+ end
+ if diagnostic._tags.deprecated then
+ higroup = 'DiagnosticDeprecated'
+ end
+ end
+
vim.highlight.range(
bufnr,
underline_ns,