Skip to content

Commit 512d97d

Browse files
committed
lsp: use diagnostic options properly
Use the diagnostics level to determine whether to store the diagnostics with the buffer and the diagnostic highlight options to determine whether to highlight the relevent text. This will allow users to toggle highlighting to affect whether text is highlighted and adjust the level to determine whether there are any diagnostics stored at all.
1 parent dd59bfa commit 512d97d

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

autoload/go/lsp.vim

+10-6
Original file line numberDiff line numberDiff line change
@@ -1428,23 +1428,27 @@ function! s:highlightMatches(errorMatches, warningMatches) abort
14281428

14291429
if hlexists('goDiagnosticError')
14301430
" clear the old matches just before adding the new ones to keep flicker
1431-
" to a minimum.
1431+
" to a minimum and clear before checking the level so that if the user
1432+
" changed the level since the last highlighting, the highlighting will be
1433+
" be properly cleared.
14321434
call go#util#ClearHighlights('goDiagnosticError')
1433-
if go#config#HighlightDiagnosticErrors()
1435+
if go#config#DiagnosticsLevel() >= 2
14341436
let b:go_diagnostic_matches.errors = copy(a:errorMatches)
1435-
if go#config#DiagnosticsLevel() >= 2
1437+
if go#config#HighlightDiagnosticErrors()
14361438
call go#util#HighlightPositions('goDiagnosticError', a:errorMatches)
14371439
endif
14381440
endif
14391441
endif
14401442

14411443
if hlexists('goDiagnosticWarning')
14421444
" clear the old matches just before adding the new ones to keep flicker
1443-
" to a minimum.
1445+
" to a minimum and clear before checking the level so that if the user
1446+
" changed the level since the last highlighting, the highlighting will be
1447+
" be properly cleared.
14441448
call go#util#ClearHighlights('goDiagnosticWarning')
1445-
if go#config#HighlightDiagnosticWarnings()
1449+
if go#config#DiagnosticsLevel() >= 2
14461450
let b:go_diagnostic_matches.warnings = copy(a:warningMatches)
1447-
if go#config#DiagnosticsLevel() >= 2
1451+
if go#config#HighlightDiagnosticWarnings()
14481452
call go#util#HighlightPositions('goDiagnosticWarning', a:warningMatches)
14491453
endif
14501454
endif

0 commit comments

Comments
 (0)