import './buffer.vim' as buf
import './util.vim'
+# Initialize the signs and the text property type used for diagnostics.
+export def InitOnce()
+ var lineHL: string = opt.lspOptions.diagLineHL
+ # Signs used for LSP diagnostics
+ sign_define([{name: 'LspDiagError', text: 'E>', texthl: 'ErrorMsg',
+ linehl: lineHL},
+ {name: 'LspDiagWarning', text: 'W>', texthl: 'Search',
+ linehl: lineHL},
+ {name: 'LspDiagInfo', text: 'I>', texthl: 'Pmenu',
+ linehl: lineHL},
+ {name: 'LspDiagHint', text: 'H>', texthl: 'Question',
+ linehl: lineHL}])
+
+ if has('patch-9.0.1157') && opt.lspOptions.showDiagWithVirtualText
+ if !hlexists('LspDiagVirtualText')
+ hlset([{name: 'LspDiagVirtualText',
+ linksto: opt.lspOptions.diagVirtualTextHL}])
+ endif
+ prop_type_add('LspDiagVirtualText', {highlight: 'LspDiagVirtualText',
+ override: true})
+ endif
+enddef
+
# Remove the diagnostics stored for buffer 'bnr'
export def DiagRemoveFile(lspserver: dict<any>, bnr: number)
if lspserver.diagsMap->has_key(bnr)
# Remove all the existing diagnostic signs
sign_unplace('LSPDiag', {buffer: bnr})
- if has('patch-9.0.1157') && opt.lspOptions.showDiagWithVirtualText && opt.lspOptions.autoHighlightDiags
- # Remove all virtual text
- prop_remove({type: 'LspDiagVirtualText', bufnr: bnr, all: true})
- endif
-
- # remove add virtual text in all bufs if auto highlight digs off
- if !opt.lspOptions.autoHighlightDiags
- for binfo in getbufinfo({bufloaded: true})
- prop_remove({type: 'LspDiagVirtualText', bufnr: binfo.bufnr, all: true})
- endfor
+ if has('patch-9.0.1157') && opt.lspOptions.showDiagWithVirtualText
+ # Remove all the existing virtual text
+ prop_remove({type: 'LspDiagVirtualText', bufnr: bnr, all: true})
endif
if !lspserver.diagsMap->has_key(bnr) ||
lnum: lnum,
name: DiagSevToSignName(diag.severity)})
- if has('patch-9.0.1157') && opt.lspOptions.showDiagWithVirtualText && opt.lspOptions.autoHighlightDiags
- prop_add( lnum, 0, {
- bufnr: bnr,
- type: 'LspDiagVirtualText',
- text: '┌─ ' .. diag.message,
- text_align: 'above',
- text_padding_left: diag.range.start.character})
+ if has('patch-9.0.1157') && opt.lspOptions.showDiagWithVirtualText
+ prop_add(lnum, 0, {bufnr: bnr,
+ type: 'LspDiagVirtualText',
+ text: $'┌─ {diag.message}',
+ text_align: 'above',
+ text_padding_left: diag.range.start.character})
endif
endfor
var LspQfId: number = 0
if bnr->getbufvar('LspQfId', 0) != 0 &&
- getloclist(0, {id: b:LspQfId}).id == b:LspQfId
+ getloclist(0, {id: b:LspQfId}).id == b:LspQfId
LspQfId = b:LspQfId
endif
export def DiagsHighlightDisable()
# turn off all diags highlight
opt.lspOptions.autoHighlightDiags = false
- # refresh for removing diagnostic virtual text
+
+ # Remove the diganostics virtual text in all the buffers.
for binfo in getbufinfo({bufloaded: true})
- var lspserver: dict<any> = buf.BufLspServerGet(binfo.bufnr)
- if !lspserver->empty() && lspserver.running
- DiagsRefreshSigns(lspserver, binfo.bufnr)
+ if has('patch-9.0.1157') && opt.lspOptions.showDiagWithVirtualText
+ # Remove all virtual text
+ prop_remove({type: 'LspDiagVirtualText', bufnr: binfo.bufnr, all: true})
endif
endfor
+
# Remove all the existing diagnostic signs in all the buffers
sign_unplace('LSPDiag')
enddef
var lspInitializedOnce = false
def LspInitOnce()
- var lineHL: string = opt.lspOptions.diagLineHL
- # Signs used for LSP diagnostics
- sign_define([{name: 'LspDiagError', text: 'E>', texthl: 'ErrorMsg',
- linehl: lineHL},
- {name: 'LspDiagWarning', text: 'W>', texthl: 'Search',
- linehl: lineHL},
- {name: 'LspDiagInfo', text: 'I>', texthl: 'Pmenu',
- linehl: lineHL},
- {name: 'LspDiagHint', text: 'H>', texthl: 'Question',
- linehl: lineHL}])
-
prop_type_add('LspTextRef', {highlight: 'Search', override: true})
prop_type_add('LspReadRef', {highlight: 'DiffChange', override: true})
prop_type_add('LspWriteRef', {highlight: 'DiffDelete', override: true})
- if has('patch-9.0.1157') && opt.lspOptions.showDiagWithVirtualText
- if !hlexists('LspDiagVirtualText')
- hlset([{name: 'LspDiagVirtualText', linksto: opt.lspOptions.diagVirtualTextHL}])
- endif
- prop_type_add('LspDiagVirtualText', {highlight: 'LspDiagVirtualText', override: true})
- endif
-
+ diag.InitOnce()
inlayhints.InitOnce()
:set ballooneval balloonevalterm
server. By default this is set to false. The inlay
hint text is displayed as a virtual text. Needs Vim
version 9.0.0178 or later.
-showDiagWithVirtualText |Boolean| option. Show diagnostic messages text from the language
- server with virtual text. By default this is set to false.
- Needs autoHighlightDiags == true
- Needs Vim version 9.0.1157 or later.
-diagVirtualTextHL |String| option.
- The highlight group used for a diagnostics virtual text.
- By default uses "LineNr".
+showDiagWithVirtualText |Boolean| option. Show diagnostic message text from
+ the language server with virtual text. By default
+ this is set to false. The "autoHighlightDiags" option
+ should be set to true.
+ Needs Vim version 9.0.1157 or later.
+diagVirtualTextHL |String| option. The highlight group used for a
+ diagnostics virtual text. By default uses "LineNr".
showSignature |Boolean| option. In insert mode, automatically show
the current symbol signature in a popup.
By default this is set to true.