clangd / coc-clangd

clangd extension for coc.nvim
Apache License 2.0
757 stars 34 forks source link

inlayHints not working (anymore) #681

Closed themightyoarfish closed 2 months ago

themightyoarfish commented 2 months ago

I used to get useful inlay hints in C++ code, and recently I must have updated or reinstalled my plugins, with the result of this feature being no longer available. Neovim is still the same binary.

When I run

:CocCommand document.toggleInlayHint

inside an open c++ file, I get an error:

[coc.nvim] Inlay hint provider not found for current document

My coc config looks like this

{
    "diagnostic.virtualText": true,
    "diagnostic.virtualTextCurrentLineOnly": false,
    "clangd.arguments" : ["--log=verbose","-cross-file-rename"],
    "clangd.compilationDatabasePath": "${cwd}/build",
    "inlayHint.enable": true,
    "list.normalMappings": {
        "<C-c>": "do:exit"
    },
    "list.insertMappings": {
        "<C-c>": "do:exit"
    },
    "clangd.path": "~/.config/coc/extensions/coc-clangd-data/install/17.0.3/clangd_17.0.3/bin/clangd",
}

This is with a CMake project with a compilation database

Logs

It's curious that the log contains such a information:

… "inlayHintProvider":true, …

Full log here:

The flag `-cross-file-rename` is obsolete and ignored.
I[18:17:48.261] clangd version 17.0.3 (https://github.com/llvm/llvm-project 888437e1b60011b8a375dd30928ec925b448da57)
I[18:17:48.261] Features: mac+grpc+xpc
I[18:17:48.261] PID: 71319
I[18:17:48.261] Working directory: /Users/rasmus/Downloads/test
I[18:17:48.261] argv[0]: /Users/rasmus/.config/coc/extensions/coc-clangd-data/install/17.0.3/clangd_17.0.3/bin/clangd
I[18:17:48.261] argv[1]: --log=verbose
I[18:17:48.261] argv[2]: -cross-file-rename
V[18:17:48.261] User config file is /Users/rasmus/Library/Preferences/clangd/config.yaml
I[18:17:48.261] Starting LSP over stdin/stdout
V[18:17:48.261] <<< {"id":0,"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{"general":{"markdown":{"parser":"marked","version":"7.0.5"},"positionEncodings":["utf-16"],"regularExpressions":{"engine":"ECMAScript","version":"ES2020"},"staleRequestSupport":{"cancel":true,"retryOnContentModified":["textDocument/inlayHint","textDocument/semanticTokens/full","textDocument/semanticTokens/range","textDocument/semanticTokens/full/delta"]}},"textDocument":{"callHierarchy":{"dynamicRegistration":true},"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}},"dataSupport":true,"disabledSupport":true,"dynamicRegistration":true,"honorsChangeAnnotations":false,"isPreferredSupport":true,"resolveSupport":{"properties":["edit"]}},"codeLens":{"dynamicRegistration":true},"colorProvider":{"dynamicRegistration":true},"completion":{"completionItem":{"commitCharactersSupport":true,"deprecatedSupport":true,"documentationFormat":["markdown","plaintext"],"insertReplaceSupport":true,"insertTextModeSupport":{"valueSet":[1,2]},"labelDetailsSupport":true,"preselectSupport":true,"resolveSupport":{"properties":["documentation","detail","additionalTextEdits"]},"snippetSupport":true,"tagSupport":{"valueSet":[1]}},"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]},"completionList":{"itemDefaults":["commitCharacters","editRange","insertTextFormat","insertTextMode"]},"contextSupport":true,"dynamicRegistration":true,"editsNearCursor":true,"insertTextMode":2},"declaration":{"dynamicRegistration":true,"linkSupport":true},"definition":{"dynamicRegistration":true,"linkSupport":true},"diagnostic":{"dynamicRegistration":true,"relatedDocumentSupport":true},"documentHighlight":{"dynamicRegistration":true},"documentLink":{"dynamicRegistration":true,"tooltipSupport":true},"documentSymbol":{"dynamicRegistration":true,"hierarchicalDocumentSymbolSupport":true,"labelSupport":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]}},"foldingRange":{"dynamicRegistration":true,"foldingRange":{"collapsedText":false},"foldingRangeKind":{"valueSet":["comment","imports","region"]},"lineFoldingOnly":true,"rangeLimit":5000},"formatting":{"dynamicRegistration":true},"hover":{"contentFormat":["markdown","plaintext"],"dynamicRegistration":true},"implementation":{"dynamicRegistration":true,"linkSupport":true},"inlineValue":{"dynamicRegistration":true},"linkedEditingRange":{"dynamicRegistration":true},"onTypeFormatting":{"dynamicRegistration":true},"publishDiagnostics":{"codeDescriptionSupport":true,"dataSupport":true,"relatedInformation":true,"tagSupport":{"valueSet":[1,2]},"versionSupport":true},"rangeFormatting":{"dynamicRegistration":true},"references":{"dynamicRegistration":true},"rename":{"dynamicRegistration":true,"honorsChangeAnnotations":true,"prepareSupport":true,"prepareSupportDefaultBehavior":1},"selectionRange":{"dynamicRegistration":true},"semanticTokens":{"augmentsSyntaxTokens":true,"dynamicRegistration":true,"formats":["relative"],"multilineTokenSupport":false,"overlappingTokenSupport":false,"requests":{"full":{"delta":true},"range":true},"serverCancelSupport":true,"tokenModifiers":["declaration","definition","readonly","static","deprecated","abstract","async","modification","documentation","defaultLibrary"],"tokenTypes":["namespace","type","class","enum","interface","struct","typeParameter","parameter","variable","property","enumMember","event","function","method","macro","keyword","modifier","comment","string","number","regexp","decorator","operator"]},"signatureHelp":{"contextSupport":true,"dynamicRegistration":true,"signatureInformation":{"activeParameterSupport":true,"documentationFormat":["markdown","plaintext"],"parameterInformation":{"labelOffsetSupport":true}}},"synchronization":{"didSave":true,"dynamicRegistration":true,"willSave":true,"willSaveWaitUntil":true},"typeDefinition":{"dynamicRegistration":true,"linkSupport":true},"typeHierarchy":{"dynamicRegistration":true}},"window":{"showDocument":{"support":true},"showMessage":{"messageActionItem":{"additionalPropertiesSupport":true}},"workDoneProgress":true},"workspace":{"applyEdit":true,"codeLens":{"refreshSupport":true},"configuration":true,"diagnostics":{"refreshSupport":true},"didChangeConfiguration":{"dynamicRegistration":true},"didChangeWatchedFiles":{"dynamicRegistration":true,"relativePatternSupport":true},"executeCommand":{"dynamicRegistration":true},"fileOperations":{"didCreate":true,"didDelete":true,"didRename":true,"dynamicRegistration":true,"willCreate":true,"willDelete":true,"willRename":true},"inlineValue":{"refreshSupport":true},"semanticTokens":{"refreshSupport":true},"symbol":{"dynamicRegistration":true,"resolveSupport":{"properties":["location.range"]},"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]}},"workspaceEdit":{"changeAnnotationSupport":{"groupsOnLabel":false},"documentChanges":true,"failureHandling":"undo","normalizesLineEndings":true,"resourceOperations":["create","rename","delete"]},"workspaceFolders":true}},"clientInfo":{"name":"coc.nvim","version":"0.0.82"},"initializationOptions":{"clangdFileStatus":true,"compilationDatabasePath":"/Users/rasmus/Downloads/test/build","fallbackFlags":[]},"locale":"en_US","processId":71313,"rootPath":"/Users/rasmus/Downloads/test","rootUri":"file:///Users/rasmus/Downloads/test","trace":"off","workDoneToken":"57a85426-1913-42a9-b4eb-5eb9acd3d56f","workspaceFolders":[{"name":"test","uri":"file:///Users/rasmus/Downloads/test"}]}}

I[18:17:48.261] <-- initialize(0)
V[18:17:48.262] Invoking /usr/bin/xcrun to find clang installation
V[18:17:48.268] Invoking /usr/bin/xcrun to find clang installation
I[18:17:48.274] --> reply:initialize(0) 12 ms
V[18:17:48.274] >>> {"id":0,"jsonrpc":"2.0","result":{"capabilities":{"astProvider":true,"callHierarchyProvider":true,"clangdInlayHintsProvider":true,"codeActionProvider":{"codeActionKinds":["quickfix","refactor","info"]},"compilationDatabase":{"automaticReload":true},"completionProvider":{"resolveProvider":false,"triggerCharacters":[".","<",">",":","\"","/","*"]},"declarationProvider":true,"definitionProvider":true,"documentFormattingProvider":true,"documentHighlightProvider":true,"documentLinkProvider":{"resolveProvider":false},"documentOnTypeFormattingProvider":{"firstTriggerCharacter":"\n","moreTriggerCharacter":[]},"documentRangeFormattingProvider":true,"documentSymbolProvider":true,"executeCommandProvider":{"commands":["clangd.applyFix","clangd.applyTweak"]},"foldingRangeProvider":true,"hoverProvider":true,"implementationProvider":true,"inactiveRegionsProvider":true,"inlayHintProvider":true,"memoryUsageProvider":true,"referencesProvider":true,"renameProvider":{"prepareProvider":true},"selectionRangeProvider":true,"semanticTokensProvider":{"full":{"delta":true},"legend":{"tokenModifiers":["declaration","definition","deprecated","deduced","readonly","static","abstract","virtual","dependentName","defaultLibrary","usedAsMutableReference","usedAsMutablePointer","constructorOrDestructor","userDefined","functionScope","classScope","fileScope","globalScope"],"tokenTypes":["variable","variable","parameter","function","method","function","property","variable","class","interface","enum","enumMember","type","type","unknown","namespace","typeParameter","concept","type","macro","modifier","operator","bracket","label","comment"]},"range":false},"signatureHelpProvider":{"triggerCharacters":["(",")","{","}","<",">",","]},"standardTypeHierarchyProvider":true,"textDocumentSync":{"change":2,"openClose":true,"save":true},"typeDefinitionProvider":true,"typeHierarchyProvider":true,"workspaceSymbolProvider":true},"serverInfo":{"name":"clangd","version":"clangd version 17.0.3 (https://github.com/llvm/llvm-project 888437e1b60011b8a375dd30928ec925b448da57) mac+grpc+xpc arm64-apple-darwin21.6.0; target=x86_64-apple-darwin21.6.0"}}}

V[18:17:48.275] <<< {"jsonrpc":"2.0","method":"initialized","params":{}}

I[18:17:48.275] <-- initialized
V[18:17:48.278] <<< {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"cpp","text":"#include \"inc.hpp\"\nint main(int argc, char *argv[]) {\n  function(1, 2);\n  return 0;\n}\n","uri":"file:///Users/rasmus/Downloads/test/test.cpp","version":1}}}

I[18:17:48.278] <-- textDocument/didOpen
I[18:17:48.278] Loaded compilation database from /Users/rasmus/Downloads/test/build/compile_commands.json
V[18:17:48.278] Broadcasting compilation database from /Users/rasmus/Downloads/test/build
I[18:17:48.278] --> window/workDoneProgress/create(0)
V[18:17:48.278] >>> {"id":0,"jsonrpc":"2.0","method":"window/workDoneProgress/create","params":{"token":"backgroundIndexProgress"}}

I[18:17:48.278] Enqueueing 1 commands for indexing
I[18:17:48.278] ASTWorker building file /Users/rasmus/Downloads/test/test.cpp version 1 with command 
[/Users/rasmus/Downloads/test/build]
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ --driver-mode=g++ -I/Users/rasmus/Downloads/test -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk -mmacosx-version-min=12.6 -o CMakeFiles/test.dir/test.o -c -resource-dir=/Users/rasmus/.config/coc/extensions/coc-clangd-data/install/17.0.3/clangd_17.0.3/lib/clang/17 -- /Users/rasmus/Downloads/test/test.cpp
V[18:17:48.279] BackgroundIndex: building version 1 after loading index from disk
V[18:17:48.279] BackgroundIndex: serving version 1 (23024 bytes)
V[18:17:48.279] <<< {"id":0,"jsonrpc":"2.0","result":null}

I[18:17:48.279] <-- reply(0)
I[18:17:48.279] --> $/progress
V[18:17:48.279] >>> {"jsonrpc":"2.0","method":"$/progress","params":{"token":"backgroundIndexProgress","value":{"kind":"begin","percentage":0,"title":"indexing"}}}

I[18:17:48.279] --> $/progress
V[18:17:48.279] >>> {"jsonrpc":"2.0","method":"$/progress","params":{"token":"backgroundIndexProgress","value":{"kind":"end"}}}

V[18:17:48.279] Driver produced command: cc1 -cc1 -triple arm64-apple-macosx12.6.0 -Wundef-prefix=TARGET_OS_ -Werror=undef-prefix -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -fsyntax-only -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name test.cpp -mrelocation-model pic -pic-level 2 -mframe-pointer=non-leaf -ffp-contract=on -fno-rounding-math -funwind-tables=1 -target-sdk-version=13.1 -fcompatibility-qualified-id-block-type-checking -fvisibility-inlines-hidden-static-local-var -target-cpu apple-m1 -target-feature +v8.5a -target-feature +aes -target-feature +crc -target-feature +dotprod -target-feature +fp-armv8 -target-feature +fp16fml -target-feature +lse -target-feature +ras -target-feature +rcpc -target-feature +rdm -target-feature +sha2 -target-feature +sha3 -target-feature +neon -target-feature +zcm -target-feature +zcz -target-feature +fullfp16 -target-abi darwinpcs -debugger-tuning=lldb -target-linker-version 820.1 -fcoverage-compilation-dir=/Users/rasmus/Downloads/test/build -resource-dir /Users/rasmus/.config/coc/extensions/coc-clangd-data/install/17.0.3/clangd_17.0.3/lib/clang/17 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk -I /Users/rasmus/Downloads/test -internal-isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1 -internal-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/local/include -internal-isystem /Users/rasmus/.config/coc/extensions/coc-clangd-data/install/17.0.3/clangd_17.0.3/lib/clang/17/include -internal-externc-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk/usr/include -fdeprecated-macro -fdebug-compilation-dir=/Users/rasmus/Downloads/test/build -ferror-limit 19 -stack-protector 1 -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -fmax-type-align=16 -no-round-trip-args -D__GCC_HAVE_DWARF2_CFI_ASM=1 -x c++ /Users/rasmus/Downloads/test/test.cpp
I[18:17:48.279] --> textDocument/clangd.fileStatus
V[18:17:48.279] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"parsing includes, running Update","uri":"file:///Users/rasmus/Downloads/test/test.cpp"}}

V[18:17:48.279] Building first preamble for /Users/rasmus/Downloads/test/test.cpp version 1
I[18:17:48.286] Built preamble of size 528392 for file /Users/rasmus/Downloads/test/test.cpp version 1 in 0.01 seconds
I[18:17:48.286] --> workspace/semanticTokens/refresh(1)
V[18:17:48.286] >>> {"id":1,"jsonrpc":"2.0","method":"workspace/semanticTokens/refresh","params":null}

I[18:17:48.286] --> textDocument/clangd.fileStatus
V[18:17:48.286] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"parsing includes, running Build AST","uri":"file:///Users/rasmus/Downloads/test/test.cpp"}}

I[18:17:48.286] --> textDocument/clangd.fileStatus
V[18:17:48.286] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"parsing includes, parsing main file","uri":"file:///Users/rasmus/Downloads/test/test.cpp"}}

V[18:17:48.287] <<< {"id":1,"jsonrpc":"2.0","result":null}

I[18:17:48.287] <-- reply(1)
V[18:17:48.287] indexed preamble AST for /Users/rasmus/Downloads/test/test.cpp version 1:
  symbol slab: 1 symbols, 4448 bytes
  ref slab: 0 symbols, 0 refs, 128 bytes
  relations slab: 0 relations, 24 bytes
I[18:17:48.287] Indexing c++17 standard library in the context of /Users/rasmus/Downloads/test/test.cpp
V[18:17:48.287] Build dynamic index for header symbols with estimated memory usage of 7916 bytes
V[18:17:48.289] indexed file AST for /Users/rasmus/Downloads/test/test.cpp version 1:
  symbol slab: 1 symbols, 4448 bytes
  ref slab: 2 symbols, 2 refs, 4272 bytes
  relations slab: 0 relations, 24 bytes
V[18:17:48.289] Build dynamic index for main-file symbols with estimated memory usage of 11576 bytes
I[18:17:48.289] --> textDocument/publishDiagnostics
V[18:17:48.289] >>> {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[],"uri":"file:///Users/rasmus/Downloads/test/test.cpp","version":1}}

I[18:17:48.289] --> textDocument/clangd.fileStatus
V[18:17:48.289] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///Users/rasmus/Downloads/test/test.cpp"}}

V[18:17:48.478] <<< {"id":1,"jsonrpc":"2.0","method":"textDocument/documentLink","params":{"textDocument":{"uri":"file:///Users/rasmus/Downloads/test/test.cpp"}}}

I[18:17:48.478] <-- textDocument/documentLink(1)
V[18:17:48.478] ASTWorker running DocumentLinks on version 1 of /Users/rasmus/Downloads/test/test.cpp
I[18:17:48.478] --> reply:textDocument/documentLink(1) 0 ms
V[18:17:48.479] >>> {"id":1,"jsonrpc":"2.0","result":[{"range":{"end":{"character":18,"line":0},"start":{"character":9,"line":0}},"target":"file:///Users/rasmus/Downloads/test/inc.hpp"}]}

I[18:17:48.479] --> textDocument/clangd.fileStatus
V[18:17:48.479] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///Users/rasmus/Downloads/test/test.cpp"}}

I[18:17:48.870] Indexed c++17 standard library: 10764 symbols, 2108 filtered
V[18:17:48.889] Build dynamic index for header symbols with estimated memory usage of 6668084 bytes

System information Clangd version (from the log, or clangd --version): 17.0.3, installed by coc-clangd clangd extension version (from :CocInfo): CocInfo does not seem to include this. Operating system: macos Monterey

themightyoarfish commented 2 months ago

test.zip

small sample project attached.

fannheyward commented 2 months ago

Run CocUpdate to upgrade coc-clangd to v0.31.0.

themightyoarfish commented 2 months ago

Fixed, thanks.