autoload/lsp/diag.vim | 37 +++++++++++++------------------------ diff --git a/autoload/lsp/diag.vim b/autoload/lsp/diag.vim index 821c091c7f3241f6df378d7fc66babe5b2af17b3..b6daa3e16fd9e50e7a5a7ef6457a6fbdb9724f46 100644 --- a/autoload/lsp/diag.vim +++ b/autoload/lsp/diag.vim @@ -129,10 +129,8 @@ endif return typeMap[severity - 1] enddef -# Refresh the placed diagnostics in buffer 'bnr' -# This inline signs, inline props, and virtual text diagnostics -def DiagsRefresh(bnr: number) - bnr->bufload() +# Remove signs and text properties for diagnostics in buffer +def RemoveDiagVisualsForBuffer(bnr: number) # Remove all the existing diagnostic signs sign_unplace('LSPDiag', {buffer: bnr}) @@ -148,6 +146,14 @@ prop_remove({type: 'LspDiagInlineWarning', bufnr: bnr, all: true}) prop_remove({type: 'LspDiagInlineInfo', bufnr: bnr, all: true}) prop_remove({type: 'LspDiagInlineHint', bufnr: bnr, all: true}) endif +enddef + +# Refresh the placed diagnostics in buffer 'bnr' +# This inline signs, inline props, and virtual text diagnostics +def DiagsRefresh(bnr: number) + bnr->bufload() + + RemoveDiagVisualsForBuffer(bnr) if !diagsMap->has_key(bnr) || diagsMap[bnr].sortedDiagnostics->empty() @@ -639,26 +645,9 @@ # Disable the LSP diagnostics highlighting in all the buffers export def DiagsHighlightDisable() # turn off all diags highlight opt.lspOptions.autoHighlightDiags = false - - # Remove the diganostics virtual text in all the buffers. - if opt.lspOptions.showDiagWithVirtualText - || opt.lspOptions.highlightDiagInline - for binfo in getbufinfo({bufloaded: true}) - # Remove all virtual text - if opt.lspOptions.showDiagWithVirtualText - prop_remove({type: 'LspDiagVirtualText', bufnr: binfo.bufnr, all: true}) - endif - if opt.lspOptions.highlightDiagInline - prop_remove({type: 'LspDiagInlineError', bufnr: binfo.bufnr, all: true}) - prop_remove({type: 'LspDiagInlineWarning', bufnr: binfo.bufnr, all: true}) - prop_remove({type: 'LspDiagInlineInfo', bufnr: binfo.bufnr, all: true}) - prop_remove({type: 'LspDiagInlineHint', bufnr: binfo.bufnr, all: true}) - endif - endfor - endif - - # Remove all the existing diagnostic signs in all the buffers - sign_unplace('LSPDiag') + for binfo in getbufinfo({bufloaded: true}) + RemoveDiagVisualsForBuffer(binfo.bufnr) + endfor enddef # Enable the LSP diagnostics highlighting