clangd LSP plugin: all operations fail with 'trying to get AST for non-added document'
Description
The built-in clangd LSP plugin fails on every operation (hover, goToDefinition, documentSymbol, findReferences, workspaceSymbol) with:
LSP request 'textDocument/hover' failed for server 'plugin:clangd-lsp:clangd': trying to get AST for non-added document
Root Cause
The plugin does not send a textDocument/didOpen notification to clangd before issuing requests. Clangd requires documents to be explicitly opened before it will parse them and build an AST.
Environment
- Claude Code: latest (as of 2026-02-27)
- OS: Windows 11
- Project: C++ (TrinityCore), ~2M LOC
- clangd config:
.clangdfile present, pointing to correctCompilationDatabasepath - compile_commands.json: Present and valid (generated by CMake/Ninja)
Reproduction
- Open Claude Code in a C++ project with a valid
.clangdconfig andcompile_commands.json - Use the LSP tool with any operation on any file:
````
LSP hover on src/server/game/RolePlay/RolePlay.h line 13 char 10
- Every operation fails with the same "non-added document" error
- Repeated calls do not help — the plugin never opens the document
Expected Behavior
The plugin should send textDocument/didOpen for a file before (or as part of) making LSP requests against it, so clangd can parse the file and respond to queries.
Workaround
None found. Repeated calls, different operations, absolute vs relative paths, and workspaceSymbol (which shouldn't need a specific document) all fail or return empty results.
This issue has 10 comments on GitHub. Read the full discussion on GitHub ↗