From b3edbdf94ff927519d9a06fc06d35ac16fa005f4 Mon Sep 17 00:00:00 2001 From: Yegappan Lakshmanan Date: Fri, 1 Jan 2021 20:02:45 -0800 Subject: [PATCH] Fix errors with latest Vim9 changes --- autoload/handlers.vim | 22 +++++++++++++++------- autoload/util.vim | 4 ++-- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/autoload/handlers.vim b/autoload/handlers.vim index b0d75ff..d79efcb 100644 --- a/autoload/handlers.vim +++ b/autoload/handlers.vim @@ -137,23 +137,29 @@ def s:processCompletionReply(lspserver: dict, req: dict, reply: dict = {} - if item->has_key('insertText') - d.word = item.insertText - elseif item->has_key('textEdit') + if item->has_key('textEdit') && item.textEdit->has_key('newText') d.word = item.textEdit.newText + elseif item->has_key('insertText') + d.word = item.insertText else d.word = item.label endif + d.abbr = item.label if item->has_key('kind') # namespace CompletionItemKind # map LSP kind to complete-item-kind d.kind = LspCompleteItemKindChar(item.kind) endif if item->has_key('detail') - d.info = item.detail + d.menu = item.detail endif if item->has_key('documentation') - d.menu = item.documentation + if item.documentation->type() == v:t_string && item.documentation != '' + d.info = item.documentation + elseif item.documentation->type() == v:t_dict + && item.documentation.value->type() == v:t_string + d.info = item.documentation.value + endif endif lspserver.completeItems->add(d) endfor @@ -223,6 +229,8 @@ def s:processReferencesReply(lspserver: dict, req: dict, reply: dictbufnr() if bnr == -1 bnr = fname->bufadd() + endif + if !bnr->bufloaded() bnr->bufload() endif var text: string = bnr->getbufline(loc.range.start.line + 1)[0] @@ -543,7 +551,7 @@ def s:applyTextEdits(bnr: number, text_edits: list>): void updated_edits->sort('s:edit_sort_func') var lines: list = bnr->getbufline(start_line + 1, finish_line + 1) - var fix_eol: number = bnr->getbufvar('&fixeol') + var fix_eol: bool = bnr->getbufvar('&fixeol') var set_eol = fix_eol && bnr->getbufinfo()[0].linecount <= finish_line + 1 if set_eol && lines[-1]->len() != 0 lines->add('') @@ -887,7 +895,7 @@ export def ProcessMessages(lspserver: dict): void return endif - var len = str2nr(lspserver.data[idx + 16:]) + var len = str2nr(lspserver.data[idx + 16 : ]) if len == 0 ErrMsg("Error: Content length is zero") return diff --git a/autoload/util.vim b/autoload/util.vim index fd63aab..27c54ea 100644 --- a/autoload/util.vim +++ b/autoload/util.vim @@ -54,10 +54,10 @@ export def LspUriToFile(uri: string): string # File URIs on MS-Windows start with file:///[a-zA-Z]:' if uri_decoded =~? '^file:///\a:' # MS-Windows URI - uri_decoded = uri_decoded[8:] + uri_decoded = uri_decoded[8 : ] uri_decoded = uri_decoded->substitute('/', '\\', 'g') else - uri_decoded = uri_decoded[7:] + uri_decoded = uri_decoded[7 : ] endif return uri_decoded -- 2.48.1