if valid->empty()
return str
endif
- if valid =~# ':$'
+ if valid =~ ':$'
return valid[: -2]
endif
return valid
if opt.lspOptions.completionMatcher != 'fuzzy'
# Lexographical sort (case-insensitive).
completeItems->sort((a, b) =>
- a.score ==# b.score ? 0 : a.score >? b.score ? 1 : -1)
+ a.score == b.score ? 0 : a.score >? b.score ? 1 : -1)
endif
if opt.lspOptions.autoComplete && !lspserver.omniCompletePending
|| cInfo.selected == -1
|| cInfo.items[cInfo.selected]->type() != v:t_dict
|| cInfo.items[cInfo.selected].user_data->type() != v:t_dict
- || cInfo.items[cInfo.selected].user_data.label !=# cItem.label
+ || cInfo.items[cInfo.selected].user_data.label != cItem.label
return
endif
|| cInfo.selected == -1
|| cInfo.items[cInfo.selected]->type() != v:t_dict
|| cInfo.items[cInfo.selected].user_data->type() != v:t_dict
- || cInfo.items[cInfo.selected].user_data.label !=# cItem.label
+ || cInfo.items[cInfo.selected].user_data.label != cItem.label
return
endif
var diag_wrap: string = 'truncate'
var diag_symbol: string = '┌─'
- if opt.lspOptions.diagVirtualTextAlign ==# 'below'
+ if opt.lspOptions.diagVirtualTextAlign == 'below'
diag_align = 'below'
diag_wrap = 'truncate'
diag_symbol = '└─'
- elseif opt.lspOptions.diagVirtualTextAlign ==# 'after'
+ elseif opt.lspOptions.diagVirtualTextAlign == 'after'
diag_align = 'after'
diag_wrap = 'wrap'
diag_symbol = 'E>'
InlayHintsClear(lspserver)
- if mode() !=# 'n'
+ if mode() != 'n'
# Update inlay hints only in normal mode
return
endif
endif
var kind = hint->has_key('kind') ? hint.kind->string() : '1'
- if kind ==# "'type'" || kind ==# '1'
+ if kind == "'type'" || kind == '1'
prop_add(hint.position.line + 1, hint.position.character + 1,
{type: 'LspInlayHintsType', text: label, bufnr: bufnum})
- elseif kind ==# "'parameter'" || kind ==# '2'
+ elseif kind == "'parameter'" || kind == '2'
prop_add(hint.position.line + 1, hint.position.character + 1,
{type: 'LspInlayHintsParam', text: label, bufnr: bufnum})
endif
endif
for lspserver in lspservers
- if arg ==# 'on'
+ if arg == 'on'
util.ClearTraceLogs(lspserver.logfile)
util.ClearTraceLogs(lspserver.errfile)
lspserver.debug = true
- elseif arg ==# 'off'
+ elseif arg == 'off'
lspserver.debug = false
- elseif arg ==# 'messages'
+ elseif arg == 'messages'
util.ServerMessagesShow(lspserver.logfile)
else
util.ServerMessagesShow(lspserver.errfile)
var windowName: string = ''
var lines: list<string> = []
- if arg == '' || arg ==# 'status'
+ if arg == '' || arg == 'status'
windowName = $'LangServer-Status'
for lspserver in lspservers
if !lines->empty()
endif
lines->add(msg)
endfor
- elseif arg ==# 'capabilities'
+ elseif arg == 'capabilities'
windowName = $'LangServer-Capabilities'
for lspserver in lspservers
if !lines->empty()
endif
lines->extend(lspserver.getCapabilities())
endfor
- elseif arg ==# 'initializeRequest'
+ elseif arg == 'initializeRequest'
windowName = $'LangServer-InitializeRequest'
for lspserver in lspservers
if !lines->empty()
endif
lines->extend(lspserver.getInitializeRequest())
endfor
- elseif arg ==# 'messages'
+ elseif arg == 'messages'
windowName = $'LangServer-Messages'
for lspserver in lspservers
if !lines->empty()
endif
var cmd = cmdline->strpart(wordBegin, wordEnd - wordBegin)
- if cmd ==# 'debug'
+ if cmd == 'debug'
return LspServerDebugComplete(arglead, cmdline, wordEnd)
- elseif cmd ==# 'restart'
- elseif cmd ==# 'show'
+ elseif cmd == 'restart'
+ elseif cmd == 'show'
return LspServerShowComplete(arglead, cmdline, wordEnd)
- elseif cmd ==# 'trace'
+ elseif cmd == 'trace'
return LspServerTraceComplete(arglead, cmdline, wordEnd)
endif
# ":LspServer" command handler
export def LspServerCmd(args: string)
if args->stridx('debug') == 0
- if args[5] ==# ' '
+ if args[5] == ' '
var subcmd = args[6 : ]->trim()
ServerDebug(subcmd)
else
util.ErrMsg('Argument required')
endif
- elseif args ==# 'restart'
+ elseif args == 'restart'
RestartServer()
elseif args->stridx('show') == 0
- if args[4] ==# ' '
+ if args[4] == ' '
var subcmd = args[5 : ]->trim()
ShowServer(subcmd)
else
util.ErrMsg('Argument required')
endif
elseif args->stridx('trace') == 0
- if args[5] ==# ' '
+ if args[5] == ' '
var subcmd = args[6 : ]->trim()
ServerTraceSet(subcmd)
else
var bufDirPrefix = bufDir[0 : cwd->strcharlen() - 1]
if &fileignorecase
? bufDirPrefix ==? cwd
- : bufDirPrefix ==# cwd
+ : bufDirPrefix == cwd
rootPath = cwd
else
rootPath = bufDir
var reply = lspserver.rpc(msg, GetLspTextDocPosition(true), false)
if reply->empty() || reply.result->empty()
var emsg: string
- if msg ==# 'textDocument/declaration'
+ if msg == 'textDocument/declaration'
emsg = 'symbol declaration is not found'
- elseif msg ==# 'textDocument/typeDefinition'
+ elseif msg == 'textDocument/typeDefinition'
emsg = 'symbol type definition is not found'
- elseif msg ==# 'textDocument/implementation'
+ elseif msg == 'textDocument/implementation'
emsg = 'symbol implementation is not found'
else
emsg = 'symbol definition is not found'
# requested with 'count', display the locations in a location list.
if reply.result->len() > 1
var title: string = ''
- if msg ==# 'textDocument/declaration'
+ if msg == 'textDocument/declaration'
title = 'Declarations'
- elseif msg ==# 'textDocument/typeDefinition'
+ elseif msg == 'textDocument/typeDefinition'
title = 'Type Definitions'
- elseif msg ==# 'textDocument/implementation'
+ elseif msg == 'textDocument/implementation'
title = 'Implementations'
else
title = 'Definitions'
bufnr: bnr,
type: propName})
catch /E966\|E964/ # Invalid lnum | Invalid col
- # Highlight arrive asynchronous and the document changed while they wore
- # send.
+ # Highlight replies arrive asynchronously and the document might have
+ # been modified in the mean time. As the reply is stale, ignore invalid
+ # line number and column number errors.
endtry
endfor
enddef
# Returns if the URI refers to a remote file (e.g. ssh://)
# Credit: vim-lsp plugin
export def LspUriRemote(uri: string): bool
- return uri =~# '^\w\+::' || uri =~# '^[a-z][a-z0-9+.-]*://'
+ return uri =~ '^\w\+::' || uri =~ '^[a-z][a-z0-9+.-]*://'
enddef
# Convert a Vim filename to an LSP URI (file://<absolute_path>)
if file->type() != v:t_string || file == ''
continue
endif
- var isDir = file[-1 : ] ==# '/' || file[-1 : ] ==# '\'
+ var isDir = file[-1 : ] == '/' || file[-1 : ] == '\'
var relPath: string
if isDir
relPath = finddir(file, $'{startDir};')
for the symbol under the cursor in an insert-completion popup menu. You can
use the keys described in |popupmenu-keys| with this menu.
-To disable the auto-compeltion, you can set the autoComplete option to v:false
-in your .vimrc file: >
+To disable the auto-completion for all the files, you can set the
+'autoComplete' option to v:false in your .vimrc file: >
call LspOptionsSet({'autoComplete': v:false})
<
-If this variable is set, then the LSP plugin doesn't automatically start
+If this variable is set, then the LSP plugin will not automatically start
completion in insert mode and instead supports omni-completion (|compl-omni|).
It sets the 'omnifunc' option for the buffers which have a registered language
server. To complete a symbol in insert mode manually, you can press CTRL-X
CTRL-O to invoke completion using the items suggested by the language server.
-You can also enable or disable omni-completion based on a file type by setting
-the 'omnicompl' item to 'false' when registering a lsp server for the
-filetype. If this item is not specified, then omni-completion is enabled by
-default. The following example disables omni-completion for python: >
+You can also enable or disable omni-completion for a specific language
+server by setting the 'omnicompl' item to 'false' when registering a lsp
+server for the filetype. If this item is not specified, then omni-completion
+is enabled by default. The following example disables omni-completion for
+python: >
let lspServers = [
\ {