opencode icon indicating copy to clipboard operation
opencode copied to clipboard

fix(lsp): add better clangd compile_commands detection

Open scarf005 opened this issue 5 days ago • 3 comments

Problem

clangd sometimes reports bogus STL include errors (e.g. <string> not found) even when a project provides a CMake-generated compile_commands.json (often via a symlink).

Fix

  • Make LSP root discovery search up to the git top-level (Instance.worktree), so compile_commands.json can be found even if opencode is started from a subdirectory.
  • Start clangd with --query-driver (covers common compiler wrappers like ccache/sccache) so clangd can discover system include paths reliably.
  • If compile_commands.json exists at the chosen root, pass --compile-commands-dir explicitly.

scarf005 avatar Jan 09 '26 02:01 scarf005