clangd LSP plugin: all operations fail with 'trying to get AST for non-added document'

Resolved 💬 10 comments Opened Feb 28, 2026 by VoxCore84 Closed May 7, 2026

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: .clangd file present, pointing to correct CompilationDatabase path
  • compile_commands.json: Present and valid (generated by CMake/Ninja)

Reproduction

  1. Open Claude Code in a C++ project with a valid .clangd config and compile_commands.json
  2. Use the LSP tool with any operation on any file:

``
LSP hover on src/server/game/RolePlay/RolePlay.h line 13 char 10
``

  1. Every operation fails with the same "non-added document" error
  2. 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.

View original on GitHub ↗

This issue has 10 comments on GitHub. Read the full discussion on GitHub ↗