autoload/handlers.vim | 22 +++++++++++++++------- autoload/util.vim | 4 ++-- diff --git a/autoload/handlers.vim b/autoload/handlers.vim index b0d75ffe01f06610d4bd7a31c79444d3ad81678a..d79efcba025850a54c7db4e1871ee26f5e3a0300 100644 --- a/autoload/handlers.vim +++ b/autoload/handlers.vim @@ -137,23 +137,29 @@ endif for item in items var d: 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 @@ var fname: string = LspUriToFile(loc.uri) var bnr: number = fname->bufnr() 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 @@ # that they can be applied without interfering with each other. 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 @@ if idx == -1 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 fd63aab9170c03ef659da24f596323d93c2a9d88..27c54eac6d389e848c711b793ac8b9dc1fa0f127 100644 --- a/autoload/util.vim +++ b/autoload/util.vim @@ -54,10 +54,10 @@ # 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