@@ -185,7 +185,7 @@ function! s:get_diagnostics(uri) abort
185
185
endif
186
186
endif
187
187
endif
188
- return [0 , [] ]
188
+ return [0 , {} ]
189
189
endfunction
190
190
191
191
" Get diagnostics for the current buffer URI from all servers
@@ -219,4 +219,43 @@ function! s:compare_diagnostics(d1, d2) abort
219
219
return l: line1 > l: line2 ? 1 : -1
220
220
endif
221
221
endfunction
222
+
223
+ let s: diagnostic_kinds = {
224
+ \ 1 : ' error' ,
225
+ \ 2 : ' warning' ,
226
+ \ 3 : ' information' ,
227
+ \ 4 : ' hint' ,
228
+ \ }
229
+
230
+ function ! lsp#ui#vim#diagnostics#get_buffer_diagnostics_counts () abort
231
+ let l: counts = {
232
+ \ ' error' : 0 ,
233
+ \ ' warning' : 0 ,
234
+ \ ' information' : 0 ,
235
+ \ ' hint' : 0 ,
236
+ \ }
237
+ let l: uri = lsp#utils#get_buffer_uri ()
238
+ let [l: has_diagnostics , l: diagnostics ] = s: get_diagnostics (l: uri )
239
+ for [l: server_name , l: data ] in items (l: diagnostics )
240
+ for l: diag in l: data [' response' ][' params' ][' diagnostics' ]
241
+ let l: key = get (s: diagnostic_kinds , l: diag [' severity' ], ' error' )
242
+ let l: counts [l: key ] += 1
243
+ endfor
244
+ endfor
245
+ return l: counts
246
+ endfunction
247
+
248
+ function ! lsp#ui#vim#diagnostics#get_buffer_first_error_line () abort
249
+ let l: uri = lsp#utils#get_buffer_uri ()
250
+ let [l: has_diagnostics , l: diagnostics ] = s: get_diagnostics (l: uri )
251
+ let l: first_error_line = v: null
252
+ for [l: server_name , l: data ] in items (l: diagnostics )
253
+ for l: diag in l: data [' response' ][' params' ][' diagnostics' ]
254
+ if l: diag [' severity' ] == # 1 && (l: first_error_line == # v: null || l: first_error_line ># l: diag [' range' ][' start' ][' line' ])
255
+ let l: first_error_line = l: diag [' range' ][' start' ][' line' ]
256
+ endif
257
+ endfor
258
+ endfor
259
+ return l: first_error_line == # v: null ? v: null : l: first_error_line + 1
260
+ endfunction
222
261
" vim sw=4 ts=4 et
0 commit comments