@@ -248,6 +248,9 @@ function! s:newlsp() abort
248
248
endif
249
249
250
250
for l: diag in l: data .diagnostics
251
+ " TODO(bc): cache the raw diagnostics when they're not for the
252
+ " current buffer so that they can be processed when it is the
253
+ " current buffer and highlight the areas of concern.
251
254
let [l: error , l: matchpos ] = s: errorFromDiagnostic (l: diag , l: bufname , l: fname )
252
255
let l: diagnostics = add (l: diagnostics , l: error )
253
256
@@ -1189,45 +1192,42 @@ function! s:errorFromDiagnostic(diagnostic, bufname, fname) abort
1189
1192
endfunction
1190
1193
1191
1194
function ! s: highlightMatches (errorMatches, warningMatches) abort
1192
- " TODO(bc): use text properties instead of matchaddpos
1193
- if exists (" *matchaddpos" )
1194
- " set buffer variables for errors and warnings to zero values
1195
- let b: go_diagnostic_matches = {' errors' : [], ' warnings' : []}
1196
-
1197
- if hlexists (' goDiagnosticError' )
1198
- " clear the old matches just before adding the new ones to keep flicker
1199
- " to a minimum.
1200
- call go#util#ClearGroupFromMatches (' goDiagnosticError' )
1201
- if go#config#HighlightDiagnosticErrors ()
1202
- let b: go_diagnostic_matches .errors = copy (a: errorMatches )
1203
- call go#util#MatchAddPos (' goDiagnosticError' , a: errorMatches )
1204
- endif
1195
+ " set buffer variables for errors and warnings to zero values
1196
+ let b: go_diagnostic_matches = {' errors' : [], ' warnings' : []}
1197
+
1198
+ if hlexists (' goDiagnosticError' )
1199
+ " clear the old matches just before adding the new ones to keep flicker
1200
+ " to a minimum.
1201
+ call go#util#ClearHighlights (' goDiagnosticError' )
1202
+ if go#config#HighlightDiagnosticErrors ()
1203
+ let b: go_diagnostic_matches .errors = copy (a: errorMatches )
1204
+ call go#util#HighlightPositions (' goDiagnosticError' , a: errorMatches )
1205
1205
endif
1206
+ endif
1206
1207
1207
- if hlexists (' goDiagnosticWarning' )
1208
- " clear the old matches just before adding the new ones to keep flicker
1209
- " to a minimum.
1210
- call go#util#ClearGroupFromMatches (' goDiagnosticWarning' )
1211
- if go#config#HighlightDiagnosticWarnings ()
1212
- let b: go_diagnostic_matches .warnings = copy (a: warningMatches )
1213
- call go#util#MatchAddPos (' goDiagnosticWarning' , a: warningMatches )
1214
- endif
1208
+ if hlexists (' goDiagnosticWarning' )
1209
+ " clear the old matches just before adding the new ones to keep flicker
1210
+ " to a minimum.
1211
+ call go#util#ClearHighlights (' goDiagnosticWarning' )
1212
+ if go#config#HighlightDiagnosticWarnings ()
1213
+ let b: go_diagnostic_matches .warnings = copy (a: warningMatches )
1214
+ call go#util#HighlightPositions (' goDiagnosticWarning' , a: warningMatches )
1215
1215
endif
1216
-
1217
- " re-apply matches at the time the buffer is displayed in a new window or
1218
- " redisplayed in an existing window: e.g. :edit,
1219
- augroup vim - go - diagnostics
1220
- autocmd ! * <buffer>
1221
- autocmd BufWinEnter <buffer> nested call s: highlightMatches (b: go_diagnostic_matches .errors, b: go_diagnostic_matches .warnings)
1222
- augroup end
1223
1216
endif
1217
+
1218
+ " re-apply matches at the time the buffer is displayed in a new window or
1219
+ " redisplayed in an existing window: e.g. :edit,
1220
+ augroup vim - go - diagnostics
1221
+ autocmd ! * <buffer>
1222
+ autocmd BufWinEnter <buffer> nested call s: highlightMatches (b: go_diagnostic_matches .errors, b: go_diagnostic_matches .warnings)
1223
+ augroup end
1224
1224
endfunction
1225
1225
1226
- " ClearDiagnosticsMatches removes all goDiagnosticError and
1226
+ " ClearDiagnosticsHighlights removes all goDiagnosticError and
1227
1227
" goDiagnosticWarning matches.
1228
- function ! go#lsp#ClearDiagnosticMatches () abort
1229
- call go#util#ClearGroupFromMatches (' goDiagnosticError' )
1230
- call go#util#ClearGroupFromMatches (' goDiagnosticWarning' )
1228
+ function ! go#lsp#ClearDiagnosticHighlights () abort
1229
+ call go#util#ClearHighlights (' goDiagnosticError' )
1230
+ call go#util#ClearHighlights (' goDiagnosticWarning' )
1231
1231
endfunction
1232
1232
1233
1233
" restore Vi compatibility settings
0 commit comments