|
1 |
| -let s:is_win = has('win32') || has('win64') |
2 |
| -let s:diagnostics = {} " { uri: { 'server_name': response } } |
3 |
| - |
4 |
| -function! lsp#ui#vim#diagnostics#handle_text_document_publish_diagnostics(server_name, data) abort |
5 |
| - if lsp#client#is_error(a:data['response']) |
6 |
| - return |
7 |
| - endif |
8 |
| - let l:uri = a:data['response']['params']['uri'] |
9 |
| - let l:uri = lsp#utils#normalize_uri(l:uri) |
10 |
| - if !has_key(s:diagnostics, l:uri) |
11 |
| - let s:diagnostics[l:uri] = {} |
12 |
| - endif |
13 |
| - let s:diagnostics[l:uri][a:server_name] = a:data |
14 |
| - |
15 |
| - doautocmd <nomodeline> User lsp_diagnostics_updated |
16 |
| -endfunction |
17 |
| - |
18 | 1 | function! s:severity_of(diagnostic) abort
|
19 | 2 | return get(a:diagnostic, 'severity', 1)
|
20 | 3 | endfunction
|
21 | 4 |
|
22 |
| -function! lsp#ui#vim#diagnostics#next_error(...) abort |
| 5 | +function! lsp#internal#diagnostics#movement#_next_error(...) abort |
23 | 6 | let l:diagnostics = filter(s:get_all_buffer_diagnostics(),
|
24 | 7 | \ {_, diagnostic -> s:severity_of(diagnostic) ==# 1 })
|
25 | 8 | let l:options = lsp#utils#parse_command_options(a:000)
|
26 | 9 | call s:next_diagnostic(l:diagnostics, l:options)
|
27 | 10 | endfunction
|
28 | 11 |
|
29 |
| -function! lsp#ui#vim#diagnostics#next_warning(...) abort |
| 12 | +function! lsp#internal#diagnostics#movement#_next_warning(...) abort |
30 | 13 | let l:diagnostics = filter(s:get_all_buffer_diagnostics(),
|
31 | 14 | \ {_, diagnostic -> s:severity_of(diagnostic) ==# 2 })
|
32 | 15 | let l:options = lsp#utils#parse_command_options(a:000)
|
33 | 16 | call s:next_diagnostic(l:diagnostics, l:options)
|
34 | 17 | endfunction
|
35 | 18 |
|
36 |
| -function! lsp#ui#vim#diagnostics#next_diagnostic(...) abort |
| 19 | +function! lsp#internal#diagnostics#movement#_next_diagnostics(...) abort |
37 | 20 | let l:options = lsp#utils#parse_command_options(a:000)
|
38 | 21 | call s:next_diagnostic(s:get_all_buffer_diagnostics(), l:options)
|
39 | 22 | endfunction
|
@@ -87,21 +70,21 @@ function! s:next_diagnostic(diagnostics, options) abort
|
87 | 70 | call winrestview(l:view)
|
88 | 71 | endfunction
|
89 | 72 |
|
90 |
| -function! lsp#ui#vim#diagnostics#previous_error(...) abort |
| 73 | +function! lsp#internal#diagnostics#movement#_previous_error(...) abort |
91 | 74 | let l:diagnostics = filter(s:get_all_buffer_diagnostics(),
|
92 | 75 | \ {_, diagnostic -> s:severity_of(diagnostic) ==# 1 })
|
93 | 76 | let l:options = lsp#utils#parse_command_options(a:000)
|
94 | 77 | call s:previous_diagnostic(l:diagnostics, l:options)
|
95 | 78 | endfunction
|
96 | 79 |
|
97 |
| -function! lsp#ui#vim#diagnostics#previous_warning(...) abort |
| 80 | +function! lsp#internal#diagnostics#movement#_previous_warning(...) abort |
98 | 81 | let l:options = lsp#utils#parse_command_options(a:000)
|
99 | 82 | let l:diagnostics = filter(s:get_all_buffer_diagnostics(),
|
100 | 83 | \ {_, diagnostic -> s:severity_of(diagnostic) ==# 2 })
|
101 | 84 | call s:previous_diagnostic(l:diagnostics, l:options)
|
102 | 85 | endfunction
|
103 | 86 |
|
104 |
| -function! lsp#ui#vim#diagnostics#previous_diagnostic(...) abort |
| 87 | +function! lsp#internal#diagnostics#movement#_previous_diagnostics(...) abort |
105 | 88 | let l:options = lsp#utils#parse_command_options(a:000)
|
106 | 89 | call s:previous_diagnostic(s:get_all_buffer_diagnostics(), l:options)
|
107 | 90 | endfunction
|
@@ -175,23 +158,30 @@ endfunction
|
175 | 158 |
|
176 | 159 | " Get diagnostics for the current buffer URI from all servers
|
177 | 160 | function! s:get_all_buffer_diagnostics(...) abort
|
178 |
| - let l:target_server_name = get(a:000, 0, '') |
| 161 | + let l:server = get(a:000, 0, '') |
179 | 162 |
|
180 |
| - let l:uri = lsp#utils#get_buffer_uri() |
| 163 | + let l:bufnr = bufnr('%') |
| 164 | + let l:uri = lsp#utils#get_buffer_uri(l:bufnr) |
181 | 165 |
|
182 |
| - let [l:has_diagnostics, l:diagnostics] = s:get_diagnostics(l:uri) |
183 |
| - if !l:has_diagnostics |
| 166 | + if !lsp#internal#diagnostics#state#_is_enabled_for_buffer(l:bufnr) |
184 | 167 | return []
|
185 | 168 | endif
|
186 | 169 |
|
187 |
| - let l:all_diagnostics = [] |
188 |
| - for [l:server_name, l:data] in items(l:diagnostics) |
189 |
| - if empty(l:target_server_name) || l:server_name ==# l:target_server_name |
190 |
| - call extend(l:all_diagnostics, l:data['response']['params']['diagnostics']) |
| 170 | + let l:diagnostics_by_server = lsp#internal#diagnostics#state#_get_all_diagnostics_grouped_by_server_for_uri(l:uri) |
| 171 | + if empty(l:server) |
| 172 | + let l:diagnostics = [] |
| 173 | + for l:item in values(l:diagnostics_by_server) |
| 174 | + let l:diagnostics += l:item['params']['diagnostics'] |
| 175 | + endfor |
| 176 | + else |
| 177 | + if has_key(l:diagnostics_by_server, l:server) |
| 178 | + let l:diagnostics = l:diagnostics_by_server[l:server]['params']['diagnostics'] |
| 179 | + else |
| 180 | + let l:diagnostics = [] |
191 | 181 | endif
|
192 |
| - endfor |
| 182 | + endif |
193 | 183 |
|
194 |
| - return l:all_diagnostics |
| 184 | + return l:diagnostics |
195 | 185 | endfunction
|
196 | 186 |
|
197 | 187 | function! s:compare_diagnostics(d1, d2) abort
|
|
0 commit comments