autoload/lsp/completion.vim | 8 ++++---- autoload/lsp/diag.vim | 4 ++-- autoload/lsp/inlayhints.vim | 6 +++--- autoload/lsp/lsp.vim | 30 +++++++++++++++--------------- autoload/lsp/lspserver.vim | 19 ++++++++++--------- autoload/lsp/util.vim | 4 ++-- doc/lsp.txt | 15 ++++++++------- diff --git a/autoload/lsp/completion.vim b/autoload/lsp/completion.vim index 93a2ad58187e028033bbb1be110cd3d51b766c98..3088dac9b747e73721c0a832f2e6068c120b8f76 100644 --- a/autoload/lsp/completion.vim +++ b/autoload/lsp/completion.vim @@ -103,7 +103,7 @@ var valid = str->matchstr('^[^"'' (<{\[\t\r\n]\+') if valid->empty() return str endif - if valid =~# ':$' + if valid =~ ':$' return valid[: -2] endif return valid @@ -268,7 +268,7 @@ 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 @@ -309,7 +309,7 @@ || !cInfo.pum_visible || 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 @@ -358,7 +358,7 @@ || !cInfo.pum_visible || 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 diff --git a/autoload/lsp/diag.vim b/autoload/lsp/diag.vim index 4478fcb9cd998289a565aa710449b84c21ab8c28..821c091c7f3241f6df378d7fc66babe5b2af17b3 100644 --- a/autoload/lsp/diag.vim +++ b/autoload/lsp/diag.vim @@ -159,11 +159,11 @@ var diag_align: string = 'above' 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>' diff --git a/autoload/lsp/inlayhints.vim b/autoload/lsp/inlayhints.vim index 9b07343bf66cf920de543cd47131bc4c4c2f6ef5..3d3384b8d352ca9c3298a982ad7c44ec5f0e3064 100644 --- a/autoload/lsp/inlayhints.vim +++ b/autoload/lsp/inlayhints.vim @@ -29,7 +29,7 @@ endif InlayHintsClear(lspserver) - if mode() !=# 'n' + if mode() != 'n' # Update inlay hints only in normal mode return endif @@ -44,10 +44,10 @@ label = hint.label 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 diff --git a/autoload/lsp/lsp.vim b/autoload/lsp/lsp.vim index ebfc63e0010833a9cc3d62c9d0e57e1f00d0cee4..b2f6dd3e0bc4bbd57be11389573395d95f4ede18 100644 --- a/autoload/lsp/lsp.vim +++ b/autoload/lsp/lsp.vim @@ -98,13 +98,13 @@ return 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) @@ -194,7 +194,7 @@ endif var windowName: string = '' var lines: list = [] - if arg == '' || arg ==# 'status' + if arg == '' || arg == 'status' windowName = $'LangServer-Status' for lspserver in lspservers if !lines->empty() @@ -208,7 +208,7 @@ msg ..= 'not running' endif lines->add(msg) endfor - elseif arg ==# 'capabilities' + elseif arg == 'capabilities' windowName = $'LangServer-Capabilities' for lspserver in lspservers if !lines->empty() @@ -216,7 +216,7 @@ lines->extend(['', repeat('=', &columns), '']) endif lines->extend(lspserver.getCapabilities()) endfor - elseif arg ==# 'initializeRequest' + elseif arg == 'initializeRequest' windowName = $'LangServer-InitializeRequest' for lspserver in lspservers if !lines->empty() @@ -224,7 +224,7 @@ lines->extend(['', repeat('=', &columns), '']) endif lines->extend(lspserver.getInitializeRequest()) endfor - elseif arg ==# 'messages' + elseif arg == 'messages' windowName = $'LangServer-Messages' for lspserver in lspservers if !lines->empty() @@ -1124,12 +1124,12 @@ return filter(l, (_, val) => val =~ $'^{arglead}') 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 @@ -1139,23 +1139,23 @@ # ":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 diff --git a/autoload/lsp/lspserver.vim b/autoload/lsp/lspserver.vim index 69af662bb7a921a9852ab8a038be795d97f01398..b229fdecbde41e02887b3f6954b61aaf40170d27 100644 --- a/autoload/lsp/lspserver.vim +++ b/autoload/lsp/lspserver.vim @@ -170,7 +170,7 @@ # bufDir is within cwd var bufDirPrefix = bufDir[0 : cwd->strcharlen() - 1] if &fileignorecase ? bufDirPrefix ==? cwd - : bufDirPrefix ==# cwd + : bufDirPrefix == cwd rootPath = cwd else rootPath = bufDir @@ -667,11 +667,11 @@ cmdmods: string, count: number) 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' @@ -688,11 +688,11 @@ # When there are multiple symbol locations, and a specific one isn't # 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' @@ -904,8 +904,9 @@ end_col: util.GetLineByteFromPos(bnr, docHL.range.end) + 1, 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 diff --git a/autoload/lsp/util.vim b/autoload/lsp/util.vim index 558b82c50f603f6053fe8007f291d10426ad6cfd..548856131ff8471f9db0ababb8a24ac9cf3b43aa 100644 --- a/autoload/lsp/util.vim +++ b/autoload/lsp/util.vim @@ -104,7 +104,7 @@ # 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://) @@ -248,7 +248,7 @@ for file in files 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};') diff --git a/doc/lsp.txt b/doc/lsp.txt index 53e44d71fa125411a059139d4825e983b5e69ef1..0e9f3fdd3aa75b6f50833616faaa9a996e1e4bf9 100644 --- a/doc/lsp.txt +++ b/doc/lsp.txt @@ -1012,21 +1012,22 @@ By default, in insert mode, the LSP plugin automatically displays the matches 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 = [ \ {