A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/neovim/neovim/commit/5d6006f9bfc2f1f064adbcfa974da6976e867450 below:

add "code" to the diagnostic structure (#17510) · neovim/neovim@5d6006f · GitHub

File tree Expand file treeCollapse file tree 3 files changed

+12

-5

lines changed

Filter options

Expand file treeCollapse file tree 3 files changed

+12

-5

lines changed Original file line number Diff line number Diff line change

@@ -39,16 +39,18 @@ modify the diagnostics for a buffer (e.g. |vim.diagnostic.set()|) then it

39 39

requires a namespace.

40 40 41 41

*diagnostic-structure*

42 -

A diagnostic is a Lua table with the following keys:

42 +

A diagnostic is a Lua table with the following keys. Required keys are

43 +

indicated with (*):

43 44 44 45

bufnr: Buffer number

45 -

lnum: The starting line of the diagnostic

46 +

lnum(*): The starting line of the diagnostic

46 47

end_lnum: The final line of the diagnostic

47 -

col: The starting column of the diagnostic

48 +

col(*): The starting column of the diagnostic

48 49

end_col: The final column of the diagnostic

49 50

severity: The severity of the diagnostic |vim.diagnostic.severity|

50 -

message: The diagnostic text

51 +

message(*): The diagnostic text

51 52

source: The source of the diagnostic

53 +

code: The diagnostic code

52 54

user_data: Arbitrary data plugins or users can add

53 55 54 56

Diagnostics use the same indexing as the rest of the Nvim API (i.e. 0-based

Original file line number Diff line number Diff line change

@@ -104,8 +104,10 @@ local function diagnostic_lsp_to_vim(diagnostics, bufnr, client_id)

104 104

severity = severity_lsp_to_vim(diagnostic.severity),

105 105

message = diagnostic.message,

106 106

source = diagnostic.source,

107 +

code = diagnostic.code,

107 108

user_data = {

108 109

lsp = {

110 +

-- usage of user_data.lsp.code is deprecated in favor of the top-level code field

109 111

code = diagnostic.code,

110 112

codeDescription = diagnostic.codeDescription,

111 113

tags = diagnostic.tags,

@@ -120,7 +122,8 @@ end

120 122

---@private

121 123

local function diagnostic_vim_to_lsp(diagnostics)

122 124

return vim.tbl_map(function(diagnostic)

123 -

return vim.tbl_extend("error", {

125 +

return vim.tbl_extend("keep", {

126 +

-- "keep" the below fields over any duplicate fields in diagnostic.user_data.lsp

124 127

range = {

125 128

start = {

126 129

line = diagnostic.lnum,

@@ -134,6 +137,7 @@ local function diagnostic_vim_to_lsp(diagnostics)

134 137

severity = severity_vim_to_lsp(diagnostic.severity),

135 138

message = diagnostic.message,

136 139

source = diagnostic.source,

140 +

code = diagnostic.code,

137 141

}, diagnostic.user_data and (diagnostic.user_data.lsp or {}) or {})

138 142

end, diagnostics)

139 143

end

Original file line number Diff line number Diff line change

@@ -110,6 +110,7 @@ describe('vim.lsp.diagnostic', function()

110 110

}

111 111

]]

112 112

eq({code = 42, tags = {"foo", "bar"}, data = "Hello world"}, result[1].user_data.lsp)

113 +

eq(42, result[1].code)

113 114

eq(42, result[2].code)

114 115

eq({"foo", "bar"}, result[2].tags)

115 116

eq("Hello world", result[2].data)

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4