为何coc.nvim配置Kythe语言服务器后未发自动补全请求,C++无补全窗口
Neovim中C++代码编辑时自动补全窗口无法弹出问题
配置与排查过程
在Neovim中编辑C++代码时,自动补全窗口始终无法弹出。我按照Coc的语言服务器调试流程排查,但未取得进展。在coc-settings.json中,我对Kythe语言服务器的配置如下:
{ "languageserver": { "kythe": { "command": "/full/path/omitted/kythe_languageserver", "filetypes": ["python", "go", "java", "cpp", "cc", "c++", "proto"], "trace.server" : "verbose" } } }
已观察到的运行状态
- 打开C文件后执行
:CocList services,可看到该语言服务器处于运行状态,关联支持的文件类型为python、go、java、cpp、cc、c、proto:languageserver.kythe [running] python, go, java, cpp, cc, c++, proto - 执行
:CocCommand workspace.showOutput查看服务输出,可看到标识语言服务器初始化成功的日志:[Trace - 4:45:05 PM] Received response 'initialize - (0)' in 264ms. Result: { "capabilities": { "textDocumentSync": 1, "hoverProvider": true, "definitionProvider": true, "referencesProvider": true } }
我的疑问与观察
我有个疑问:上述能力声明中,是否缺少自动补全功能必需的配置?
无论原因如何,我编辑文件时,比如输入std::期望弹出对应命名空间的补全选项,却没有任何反应。此时发往语言服务器的唯一消息如下:
[Trace - 4:45:47 PM] Sending notification 'textDocument/didChange'. Params: { "textDocument": { "uri": "[redacted]", "version": 4 }, "contentChanges": [ { "text": "[redacted]" } ] }
根据我的了解,自动补全功能应该需要向语言服务器发送其他类型的消息,对吗?textDocument/didChange通知仅用于同步文档状态。
补充说明:以下是Neovim侧Coc客户端声明的全部支持能力集
{ "capabilities": { "workspace": { "applyEdit": true, "workspaceEdit": { "documentChanges": true, "resourceOperations": [ "create", "rename", "delete" ], "failureHandling": "textOnlyTransactional" }, "didChangeConfiguration": { "dynamicRegistration": true }, "didChangeWatchedFiles": { "dynamicRegistration": true }, "symbol": { "dynamicRegistration": true, "symbolKind": { "valueSet": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 ] }, "tagSupport": { "valueSet": [ 1 ] } }, "executeCommand": { "dynamicRegistration": true }, "configuration": true, "workspaceFolders": true }, "textDocument": { "publishDiagnostics": { "relatedInformation": true, "versionSupport": false, "tagSupport": { "valueSet": [ 1, 2 ] } }, "synchronization": { "dynamicRegistration": true, "willSave": true, "willSaveWaitUntil": true, "didSave": true }, "completion": { "dynamicRegistration": true, "contextSupport": true, "completionItem": { "snippetSupport": true, "commitCharactersSupport": true, "documentationFormat": [ "markdown", "plaintext" ], "deprecatedSupport": true, "preselectSupport": true }, "completionItemKind": { "valueSet": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 ] } }, "hover": { "dynamicRegistration": true, "contentFormat": [ "markdown", "plaintext" ] }, "signatureHelp": { "dynamicRegistration": true, "signatureInformation": { "documentationFormat": [ "markdown", "plaintext" ], "parameterInformation": { "labelOffsetSupport": true } } }, "definition": { "dynamicRegistration": true }, "references": { "dynamicRegistration": true }, "documentHighlight": { "dynamicRegistration": true }, "documentSymbol": { "dynamicRegistration": true, "symbolKind": { "valueSet": [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 ] }, "hierarchicalDocumentSymbolSupport": true, "tagSupport": { "valueSet": [ 1 ] } }, "codeAction": { "dynamicRegistration": true, "isPreferredSupport": true, "codeActionLiteralSupport": { "codeActionKind": { "valueSet": [ "", "quickfix", "refactor", "refactor.extract", "refactor.inline", "refactor.rewrite", "source", "source.organizeImports" ] } } }, "codeLens": { "dynamicRegistration": true }, "formatting": { "dynamicRegistration": true }, "rangeFormatting": { "dynamicRegistration": true }, "onTypeFormatting": { "dynamicRegistration": true }, "rename": { "dynamicRegistration": true, "prepareSupport": true }, "documentLink": { "dynamicRegistration": true, "tooltipSupport": true }, "typeDefinition": { "dynamicRegistration": true }, "implementation": { "dynamicRegistration": true }, "declaration": { "dynamicRegistration": true }, "colorProvider": { "dynamicRegistration": true }, "foldingRange": { "dynamicRegistration": true, "rangeLimit": 5000, "lineFoldingOnly": true }, "selectionRange": { "dynamicRegistration": true } }, "window": { "workDoneProgress": true } } }
内容的提问来源于stack exchange,提问作者jeanluc
相关产品推荐
相关产品推荐

