File tree Expand file tree Collapse file tree 3 files changed +27
-15
lines changed Expand file tree Collapse file tree 3 files changed +27
-15
lines changed Original file line number Diff line number Diff line change @@ -1125,7 +1125,7 @@ endfunction
1125
1125
1126
1126
" Return first error line or v:null if there are no errors
1127
1127
function ! lsp#get_buffer_first_error_line () abort
1128
- return lsp#ui#vim# diagnostics#get_buffer_first_error_line ( )
1128
+ return lsp#internal# diagnostics#first_line#get_first_error_line ({ ' bufnr ' : bufnr ( ' % ' )} )
1129
1129
endfunction
1130
1130
1131
1131
" Return UI list with window/workDoneProgress
Original file line number Diff line number Diff line change
1
+ " Return first error line or v:null if there are no errors
2
+ " available.
3
+ " options = {
4
+ " 'bufnr': '', " optional
5
+ " }
6
+ function ! lsp#internal#diagnostics#first_line#get_first_error_line (options ) abort
7
+ let l: bufnr = get (a: options , ' bufnr' , bufnr (' %' ))
8
+
9
+ if ! lsp#internal#diagnostics#state#_is_enabled_for_buffer (l: bufnr )
10
+ return v: null
11
+ endif
12
+
13
+ let l: uri = lsp#utils#get_buffer_uri (l: bufnr )
14
+ let l: diagnostics_by_server = lsp#internal#diagnostics#state#_get_all_diagnostics_grouped_by_server_for_uri (l: uri )
15
+
16
+ let l: first_error_line = v: null
17
+ for l: diagnostics_response in values (l: diagnostics_by_server )
18
+ for l: diagnostics in l: diagnostics_response [' params' ][' diagnostics' ]
19
+ let l: severity = get (l: diagnostics , ' severity' , 1 )
20
+ if l: severity == # 1 && (l: first_error_line == # v: null || l: first_error_line ># l: diagnostics [' range' ][' start' ][' line' ])
21
+ let l: first_error_line = l: diagnostics [' range' ][' start' ][' line' ]
22
+ endif
23
+ endfor
24
+ endfor
25
+ return l: first_error_line == # v: null ? v: null : l: first_error_line + 1
26
+ endfunction
Original file line number Diff line number Diff line change @@ -208,18 +208,4 @@ function! s:compare_diagnostics(d1, d2) abort
208
208
return l: line1 > l: line2 ? 1 : -1
209
209
endif
210
210
endfunction
211
-
212
- function ! lsp#ui#vim#diagnostics#get_buffer_first_error_line () abort
213
- let l: uri = lsp#utils#get_buffer_uri ()
214
- let [l: has_diagnostics , l: diagnostics ] = s: get_diagnostics (l: uri )
215
- let l: first_error_line = v: null
216
- for [l: server_name , l: data ] in items (l: diagnostics )
217
- for l: diag in l: data [' response' ][' params' ][' diagnostics' ]
218
- if s: severity_of (l: diag ) == # 1 && (l: first_error_line == # v: null || l: first_error_line ># l: diag [' range' ][' start' ][' line' ])
219
- let l: first_error_line = l: diag [' range' ][' start' ][' line' ]
220
- endif
221
- endfor
222
- endfor
223
- return l: first_error_line == # v: null ? v: null : l: first_error_line + 1
224
- endfunction
225
211
" vim sw=4 ts=4 et
You can’t perform that action at this time.
0 commit comments