aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/lsp/diagnostic.lua
diff options
context:
space:
mode:
authorDavid Shen <17462095+mxteries@users.noreply.github.com>2022-03-02 20:42:27 -0500
committerGitHub <noreply@github.com>2022-03-02 18:42:27 -0700
commit5d6006f9bfc2f1f064adbcfa974da6976e867450 (patch)
treed8591aedcdf6652e4b4d3e3f3223f817a56d7f21 /runtime/lua/vim/lsp/diagnostic.lua
parent051a0514dc62f675a3c63761b9bef1721f7cf695 (diff)
downloadrneovim-5d6006f9bfc2f1f064adbcfa974da6976e867450.tar.gz
rneovim-5d6006f9bfc2f1f064adbcfa974da6976e867450.tar.bz2
rneovim-5d6006f9bfc2f1f064adbcfa974da6976e867450.zip
feat(diagnostic): add "code" to the diagnostic structure (#17510)
Diffstat (limited to 'runtime/lua/vim/lsp/diagnostic.lua')
-rw-r--r--runtime/lua/vim/lsp/diagnostic.lua6
1 files changed, 5 insertions, 1 deletions
diff --git a/runtime/lua/vim/lsp/diagnostic.lua b/runtime/lua/vim/lsp/diagnostic.lua
index 68942ae11a..614d83f565 100644
--- a/runtime/lua/vim/lsp/diagnostic.lua
+++ b/runtime/lua/vim/lsp/diagnostic.lua
@@ -104,8 +104,10 @@ local function diagnostic_lsp_to_vim(diagnostics, bufnr, client_id)
severity = severity_lsp_to_vim(diagnostic.severity),
message = diagnostic.message,
source = diagnostic.source,
+ code = diagnostic.code,
user_data = {
lsp = {
+ -- usage of user_data.lsp.code is deprecated in favor of the top-level code field
code = diagnostic.code,
codeDescription = diagnostic.codeDescription,
tags = diagnostic.tags,
@@ -120,7 +122,8 @@ end
---@private
local function diagnostic_vim_to_lsp(diagnostics)
return vim.tbl_map(function(diagnostic)
- return vim.tbl_extend("error", {
+ return vim.tbl_extend("keep", {
+ -- "keep" the below fields over any duplicate fields in diagnostic.user_data.lsp
range = {
start = {
line = diagnostic.lnum,
@@ -134,6 +137,7 @@ local function diagnostic_vim_to_lsp(diagnostics)
severity = severity_vim_to_lsp(diagnostic.severity),
message = diagnostic.message,
source = diagnostic.source,
+ code = diagnostic.code,
}, diagnostic.user_data and (diagnostic.user_data.lsp or {}) or {})
end, diagnostics)
end