@@ -6,22 +6,13 @@ local log = require("null-ls.logger")
6
6
7
7
local api = vim .api
8
8
9
- local should_use_diagnostic_api = function ()
10
- return vim .diagnostic and not c .get ()._use_lsp_handler
11
- end
12
-
13
9
local namespaces = {}
14
10
15
11
local M = {}
16
12
17
13
M .namespaces = namespaces
18
14
19
15
M .hide_source_diagnostics = function (id )
20
- if not vim .diagnostic then
21
- log :debug (" unable to clear diagnostics (not available on nvim < 0.6.0)" )
22
- return
23
- end
24
-
25
16
local ns = namespaces [id ]
26
17
if not ns then
27
18
return
48
39
local postprocess = function (diagnostic , _ , generator )
49
40
local range = convert_range (diagnostic )
50
41
-- the diagnostic API requires 0-indexing, so we can repurpose the LSP range
51
- if should_use_diagnostic_api () then
52
- diagnostic .lnum = range [" start" ].line
53
- diagnostic .end_lnum = range [" end" ].line
54
- diagnostic .col = range [" start" ].character
55
- diagnostic .end_col = range [" end" ].character
56
- else
57
- diagnostic .range = range
58
- end
42
+ diagnostic .lnum = range [" start" ].line
43
+ diagnostic .end_lnum = range [" end" ].line
44
+ diagnostic .col = range [" start" ].character
45
+ diagnostic .end_col = range [" end" ].character
59
46
60
47
diagnostic .source = diagnostic .source or generator .opts .name or generator .opts .command or " null-ls"
61
48
@@ -71,21 +58,11 @@ local postprocess = function(diagnostic, _, generator)
71
58
diagnostic .message = formatted
72
59
end
73
60
74
- local handle_diagnostics = function (diagnostics , uri , bufnr , client_id )
75
- if should_use_diagnostic_api () then
76
- for id , by_id in pairs (diagnostics ) do
77
- namespaces [id ] = namespaces [id ] or api .nvim_create_namespace (" NULL_LS_SOURCE_" .. id )
78
- vim .diagnostic .set (namespaces [id ], bufnr , by_id )
79
- end
80
- return
61
+ local handle_diagnostics = function (diagnostics , bufnr )
62
+ for id , by_id in pairs (diagnostics ) do
63
+ namespaces [id ] = namespaces [id ] or api .nvim_create_namespace (" NULL_LS_SOURCE_" .. id )
64
+ vim .diagnostic .set (namespaces [id ], bufnr , by_id )
81
65
end
82
-
83
- local handler = u .resolve_handler (methods .lsp .PUBLISH_DIAGNOSTICS )
84
- handler (nil , { diagnostics = diagnostics , uri = uri }, {
85
- method = methods .lsp .PUBLISH_DIAGNOSTICS ,
86
- client_id = client_id ,
87
- bufnr = bufnr ,
88
- })
89
66
end
90
67
91
68
-- track last changedtick to only send most recent diagnostics
@@ -135,7 +112,7 @@ M.handler = function(original_params)
135
112
method = methods .map [method ],
136
113
params = params ,
137
114
postprocess = postprocess ,
138
- index_by_id = should_use_diagnostic_api () ,
115
+ index_by_id = true ,
139
116
callback = function (diagnostics )
140
117
log :trace (" received diagnostics from generators" )
141
118
log :trace (diagnostics )
@@ -145,7 +122,7 @@ M.handler = function(original_params)
145
122
return
146
123
end
147
124
148
- handle_diagnostics (diagnostics , uri , bufnr , original_params . client_id )
125
+ handle_diagnostics (diagnostics , bufnr )
149
126
end ,
150
127
})
151
128
end
0 commit comments