Skip to content

Commit 5626e70

Browse files
authored
Merge pull request #3119 from bhcleek/diagnostics/highlighting-correctly
correct and extend use of g:go_diagnostics_level
2 parents dd59bfa + a390813 commit 5626e70

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

autoload/go/lsp.vim

+13-6
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,9 @@ function! s:newlsp() abort
259259
endif
260260

261261
for l:diag in l:data.diagnostics
262+
if l:level < l:diag.severity
263+
continue
264+
endif
262265
let [l:error, l:matchpos] = s:errorFromDiagnostic(l:diag, l:bufname, l:fname)
263266
let l:diagnostics = add(l:diagnostics, l:error)
264267

@@ -1428,23 +1431,27 @@ function! s:highlightMatches(errorMatches, warningMatches) abort
14281431

14291432
if hlexists('goDiagnosticError')
14301433
" clear the old matches just before adding the new ones to keep flicker
1431-
" to a minimum.
1434+
" to a minimum and clear before checking the level so that if the user
1435+
" changed the level since the last highlighting, the highlighting will be
1436+
" be properly cleared.
14321437
call go#util#ClearHighlights('goDiagnosticError')
1433-
if go#config#HighlightDiagnosticErrors()
1438+
if go#config#DiagnosticsLevel() >= 2
14341439
let b:go_diagnostic_matches.errors = copy(a:errorMatches)
1435-
if go#config#DiagnosticsLevel() >= 2
1440+
if go#config#HighlightDiagnosticErrors()
14361441
call go#util#HighlightPositions('goDiagnosticError', a:errorMatches)
14371442
endif
14381443
endif
14391444
endif
14401445

14411446
if hlexists('goDiagnosticWarning')
14421447
" clear the old matches just before adding the new ones to keep flicker
1443-
" to a minimum.
1448+
" to a minimum and clear before checking the level so that if the user
1449+
" changed the level since the last highlighting, the highlighting will be
1450+
" be properly cleared.
14441451
call go#util#ClearHighlights('goDiagnosticWarning')
1445-
if go#config#HighlightDiagnosticWarnings()
1452+
if go#config#DiagnosticsLevel() >= 2
14461453
let b:go_diagnostic_matches.warnings = copy(a:warningMatches)
1447-
if go#config#DiagnosticsLevel() >= 2
1454+
if go#config#HighlightDiagnosticWarnings()
14481455
call go#util#HighlightPositions('goDiagnosticWarning', a:warningMatches)
14491456
endif
14501457
endif

0 commit comments

Comments
 (0)