{name: 'LspDiagHint', text: 'H>', texthl: 'Question',
linehl: lineHL}])
- if has('patch-9.0.1157') && opt.lspOptions.showDiagWithVirtualText
+ if opt.lspOptions.showDiagWithVirtualText
if !hlexists('LspDiagVirtualText')
hlset([{name: 'LspDiagVirtualText',
linksto: opt.lspOptions.diagVirtualTextHL}])
# Remove all the existing diagnostic signs
sign_unplace('LSPDiag', {buffer: bnr})
- if has('patch-9.0.1157') && opt.lspOptions.showDiagWithVirtualText
+ if opt.lspOptions.showDiagWithVirtualText
# Remove all the existing virtual text
prop_remove({type: 'LspDiagVirtualText', bufnr: bnr, all: true})
endif
lnum: lnum,
name: DiagSevToSignName(diag.severity)})
- if has('patch-9.0.1157') && opt.lspOptions.showDiagWithVirtualText
+ if opt.lspOptions.showDiagWithVirtualText
prop_add(lnum, 0, {bufnr: bnr,
type: 'LspDiagVirtualText',
text: $'┌─ {diag.message}',
if which == 'first'
setcursorcharpos(diags[0].range.start.line + 1, diags[0].range.start.character + 1)
- :redraw
- DisplayDiag(diags[0])
+ if !opt.lspOptions.showDiagWithVirtualText
+ :redraw
+ DisplayDiag(diags[0])
+ endif
return
endif
&& col < curcol))
|| (which == 'here' && (lnum == curlnum && col >= curcol))
setcursorcharpos(lnum, col)
- :redraw
- DisplayDiag(diag)
+ if !opt.lspOptions.showDiagWithVirtualText
+ :redraw
+ DisplayDiag(diag)
+ endif
return
endif
endfor
opt.lspOptions.autoHighlightDiags = false
# Remove the diganostics virtual text in all the buffers.
- for binfo in getbufinfo({bufloaded: true})
- if has('patch-9.0.1157') && opt.lspOptions.showDiagWithVirtualText
+ if opt.lspOptions.showDiagWithVirtualText
+ for binfo in getbufinfo({bufloaded: true})
# Remove all virtual text
prop_remove({type: 'LspDiagVirtualText', bufnr: binfo.bufnr, all: true})
- endif
- endfor
+ endfor
+ endif
# Remove all the existing diagnostic signs in all the buffers
sign_unplace('LSPDiag')
endif
# Displaying inlay hints needs the Vim virtual text support.
- if has('patch-9.0.0178') && opt.lspOptions.showInlayHints
- && (lspserver.isInlayHintProvider
- || lspserver.isClangdInlayHintsProvider)
+ if opt.lspOptions.showInlayHints && (lspserver.isInlayHintProvider
+ || lspserver.isClangdInlayHintsProvider)
inlayhints.BufferInit(bnr)
endif
# Restart the LSP server for the current buffer
export def RestartServer()
- var lspserver: dict<any> = buf.CurbufGetServerChecked()
+ var lspserver: dict<any> = buf.CurbufGetServer()
if lspserver->empty()
return
endif
- # Stop the server
- lspserver.stopServer()
+ # Stop the server (if running)
+ if lspserver.running
+ lspserver.stopServer()
+ endif
# Remove all the buffers with the same file type as the current buffer
var ftype: string = &filetype
# LSP server exit callback
def Exit_cb(lspserver: dict<any>, job: job, status: number): void
- util.WarnMsg($'LSP server exited with status {status}')
+ util.WarnMsg($'[{strftime("%m/%d/%y %T")}]: LSP server exited with status {status}')
lspserver.running = false
lspserver.ready = false
lspserver.requests = {}
# Send a request message to LSP server
def SendMessage(lspserver: dict<any>, content: dict<any>): void
- var ch = lspserver.job->job_getchannel()
- if ch->ch_status() != 'open'
+ var job = lspserver.job
+ if job->job_status() != 'run'
# LSP server has exited
return
endif
- ch->ch_sendexpr(content)
+ job->ch_sendexpr(content)
if content->has_key('id')
util.TraceLog(false, $'Sent [{strftime("%m/%d/%y %T")}]: {content->string()}')
endif
req.params = {}
req.params->extend(params)
- var ch = lspserver.job->job_getchannel()
- if ch->ch_status() != 'open'
+ var job = lspserver.job
+ if job->job_status() != 'run'
# LSP server has exited
return {}
endif
util.TraceLog(false, $'Sent [{strftime("%m/%d/%y %T")}]: {req->string()}')
# Do the synchronous RPC call
- var reply = ch->ch_evalexpr(req)
+ var reply = job->ch_evalexpr(req)
util.TraceLog(false, $'Received [{strftime("%m/%d/%y %T")}]: {reply->string()}')
req.params = {}
req.params->extend(params)
- var ch = lspserver.job->job_getchannel()
- if ch->ch_status() != 'open'
+ var job = lspserver.job
+ if job->job_status() != 'run'
# LSP server has exited
return -1
endif
Fn(test_null_channel(), reply)
else
# Otherwise, make an asynchronous RPC call
- reply = ch->ch_sendexpr(req, {callback: Fn})
+ reply = job->ch_sendexpr(req, {callback: Fn})
endif
if reply->empty()
return -1
# set the LSP plugin options from the user provided option values
export def OptionsSet(opts: dict<any>)
lspOptions->extend(opts)
+ if !has('patch-9.0.0178')
+ lspOptions.showInlayHints = false
+ endif
+ if !has('patch-9.0.1157')
+ lspOptions.showDiagWithVirtualText = false
+ endif
enddef
# return a copy of the LSP plugin options