{name: 'LspDiagHint', text: 'H>', texthl: 'Question',
linehl: lineHL}])
+ if opt.lspOptions.highlightDiagInline
+ if !hlexists('LspDiagInlineError')
+ hlset([{name: 'LspDiagInlineError', linksto: opt.lspOptions.diagInlineErrorHL}])
+ endif
+ if !hlexists('LspDiagInlineWarning')
+ hlset([{name: 'LspDiagInlineWarning', linksto: opt.lspOptions.diagInlineWarningHL}])
+ endif
+ if !hlexists('LspDiagInlineInfo')
+ hlset([{name: 'LspDiagInlineInfo', linksto: opt.lspOptions.diagInlineInfoHL}])
+ endif
+ if !hlexists('LspDiagInlineHint')
+ hlset([{name: 'LspDiagInlineHint', linksto: opt.lspOptions.diagInlineHintHL}])
+ endif
+ prop_type_add('LspDiagInlineError', { highlight: 'LspDiagInlineError', override: true })
+ prop_type_add('LspDiagInlineWarning', { highlight: 'LspDiagInlineWarning', override: true })
+ prop_type_add('LspDiagInlineInfo', { highlight: 'LspDiagInlineInfo', override: true })
+ prop_type_add('LspDiagInlineHint', { highlight: 'LspDiagInlineHint', override: true })
+ endif
+
if opt.lspOptions.showDiagWithVirtualText
if !hlexists('LspDiagVirtualText')
hlset([{name: 'LspDiagVirtualText',
return typeMap[severity - 1]
enddef
+def DiagSevToInlineHLName(severity: number): string
+ var typeMap: list<string> = [
+ 'LspDiagInlineError',
+ 'LspDiagInlineWarning',
+ 'LspDiagInlineInfo',
+ 'LspDiagInlineHint'
+ ]
+ if severity > 4
+ return 'LspDiagInlineHint'
+ endif
+ return typeMap[severity - 1]
+enddef
+
# Refresh the signs placed in buffer 'bnr' on lines with a diagnostic message.
def DiagsRefreshSigns(lspserver: dict<any>, bnr: number)
bnr->bufload()
prop_remove({type: 'LspDiagVirtualText', bufnr: bnr, all: true})
endif
+ if opt.lspOptions.highlightDiagInline
+ # Remove all the existing virtual text
+ prop_remove({type: 'LspDiagInlineError', bufnr: bnr, all: true})
+ 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
+
if !lspserver.diagsMap->has_key(bnr) ||
lspserver.diagsMap[bnr].sortedDiagnostics->empty()
return
lnum: lnum,
name: DiagSevToSignName(diag.severity)})
+ if opt.lspOptions.highlightDiagInline
+ prop_add(diag.range.start.line + 1,
+ util.GetLineByteFromPos(bnr, diag.range.start) + 1,
+ {end_lnum: diag.range.end.line + 1,
+ end_col: util.GetLineByteFromPos(bnr, diag.range.end) + 1,
+ bufnr: bnr,
+ type: DiagSevToInlineHLName(diag.severity)})
+ endif
+
if opt.lspOptions.showDiagWithVirtualText
prop_add(lnum, 0, {bufnr: bnr,
type: 'LspDiagVirtualText',
showDiagWithVirtualText: false,
# The highlight group used for a diagnostics virtual text
diagVirtualTextHL: 'LineNr',
+ # Highlight diagnostics inline
+ highlightDiagInline: false,
+ # The highlight group used inline Error diagnostics
+ diagInlineErrorHL: 'SpellBad',
+ # The highlight group used inline Warning diagnostics
+ diagInlineWarningHL: 'SpellCap',
+ # The highlight group used inline Info diagnostics
+ diagInlineInfoHL: 'SpellRare',
+ # The highlight group used inline Hint diagnostics
+ diagInlineHintHL: 'SpellLocal',
# Don't print message when a configured language server is missing.
ignoreMissingServer: false,
# Use a floating menu to show the code action menu instead of asking for input
command to display the code action for the current
line, use a popup menu instead of echoing.
By default this is set to false.
+highlightDiagInline |Boolean| option. Highlight the diagnostics inline
+ By default this is set to false.
+diagInlineErrorHL |String| option. The highlight group used for
+ inline error highlight. By default uses "SpellBad"
+diagInlineWarningHL |String| option. The highlight group used for
+ inline warning highlight. By default uses "SpellCap"
+diagInlineInfoHL |String| option. The highlight group used for
+ inline info highlight. By default uses "SpellRare"
+diagInlineHintHL |String| option. The highlight group used for
+ inline hint highlight. By default uses "SpellLocal"
For example, to disable the automatic placement of signs for the LSP
diagnostic messages, you can add the following line to your .vimrc file: >