autoload/handlers.vim | 16 +++++++++++----- autoload/lsp.vim | 3 ++- autoload/lspserver.vim | 31 +++++++++++++++++++++++++------ diff --git a/autoload/handlers.vim b/autoload/handlers.vim index 2b2a31e61b93a12013039ed65a16ebc362b044aa..b0d75ffe01f06610d4bd7a31c79444d3ad81678a 100644 --- a/autoload/handlers.vim +++ b/autoload/handlers.vim @@ -84,9 +84,9 @@ startcol = text->stridx(label) endif endif var popupID = popup_atcursor(text, {}) - prop_type_add('signature', {bufnr: popupID->winbufnr(), highlight: 'Title'}) + prop_type_add('signature', {bufnr: winbufnr(popupID), highlight: 'Title'}) if hllen > 0 - prop_add(1, startcol + 1, {bufnr: popupID->winbufnr(), length: hllen, type: 'signature'}) + prop_add(1, startcol + 1, {bufnr: winbufnr(popupID), length: hllen, type: 'signature'}) endif enddef @@ -150,10 +150,10 @@ # map LSP kind to complete-item-kind d.kind = LspCompleteItemKindChar(item.kind) endif if item->has_key('detail') - d.menu = item.detail + d.info = item.detail endif if item->has_key('documentation') - d.info = item.documentation + d.menu = item.documentation endif lspserver.completeItems->add(d) endfor @@ -733,8 +733,14 @@ return endif # result: FoldingRange[] + var end_lnum: number + var last_lnum: number = line('$') for foldRange in reply.result - exe ':' .. (foldRange.startLine + 1) .. ',' .. (foldRange.endLine + 2) .. 'fold' + end_lnum = foldRange.endLine + 1 + if end_lnum < foldRange.startLine + 2 + end_lnum = foldRange.startLine + 2 + endif + exe ':' .. (foldRange.startLine + 2) .. ',' .. end_lnum .. 'fold' :foldopen! endfor diff --git a/autoload/lsp.vim b/autoload/lsp.vim index 7806aa07d3c8fcbb341576f8648cbade05a025e3..0309dd36222fccce60082864f9ca4b423516c122 100644 --- a/autoload/lsp.vim +++ b/autoload/lsp.vim @@ -215,7 +215,8 @@ # add a listener to track changes to this buffer listener_add(function('lsp#bufchange_listener'), bnr) setbufvar(bnr, '&completefunc', 'lsp#completeFunc') - setbufvar(bnr, '&completeopt', 'menuone,preview,noinsert') + setbufvar(bnr, '&completeopt', 'menuone,popup,noinsert,noselect') + setbufvar(bnr, '&completepopup', 'border:off') # map characters that trigger signature help if lspserver.caps->has_key('signatureHelpProvider') diff --git a/autoload/lspserver.vim b/autoload/lspserver.vim index 42faec8b11f6b1702d5c7089e4a87f525f8052cb..218aa7d047461c2e6b647d6d0fc6df9b59a8450a 100644 --- a/autoload/lspserver.vim +++ b/autoload/lspserver.vim @@ -72,16 +72,31 @@ # Send a "initialize" LSP request def s:initServer(lspserver: dict) var req = lspserver.createRequest('initialize') + # client capabilities (ClientCapabilities) var clientCaps: dict = { workspace: { workspaceFolders: v:true, applyEdit: v:true, }, textDocument: { - foldingRange: {lineFoldingOnly: v:true} + foldingRange: {lineFoldingOnly: v:true}, + completion: { + snippetSupport: v:true, + completionItem: { + documentationFormat: ['plaintext', 'markdown'], + }, + completionItemKind: {valueSet: range(1, 25)} + }, + documentSymbol: { + hierarchicalDocumentSymbolSupport: v:true, + symbolKind: {valueSet: range(1, 25)} + }, + hover: { + contentFormat: ['plaintext', 'markdown'] + } }, window: {}, - general: {} + general: {}, } # interface 'InitializeParams' @@ -91,12 +106,14 @@ initparams.clientInfo = { name: 'Vim', version: string(v:versionlong), } - initparams.rootPath = getcwd() - initparams.rootUri = LspFileToUri(getcwd()) + var curdir: string = getcwd() + initparams.rootPath = curdir + initparams.rootUri = LspFileToUri(curdir) initparams.workspaceFolders = { - uri: LspFileToUri(getcwd()), - name: getcwd() + name: fnamemodify(curdir, ':t'), + uri: LspFileToUri(curdir) } + initparams.trace = 'off' initparams.capabilities = clientCaps req.params->extend(initparams) @@ -332,6 +349,8 @@ # interface CompletionParams # interface TextDocumentPositionParams req.params->extend(s:getLspTextDocPosition()) + # interface CompletionContext + req.params->extend({context: {triggerKind: 1}}) lspserver.sendMessage(req) enddef