Skip to content

Conversation

@scarf005
Copy link
Contributor

@scarf005 scarf005 commented Jan 9, 2026

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.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 9, 2026

Hey! Your PR title Fix clangd compile_commands detection doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 9, 2026

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

@scarf005 scarf005 changed the title Fix clangd compile_commands detection fix: add better clangd compile_commands detection Jan 9, 2026
@scarf005 scarf005 changed the title fix: add better clangd compile_commands detection feat: add better clangd compile_commands detection Jan 9, 2026
@scarf005 scarf005 marked this pull request as ready for review January 9, 2026 02:18
@github-actions
Copy link
Contributor

github-actions bot commented Jan 9, 2026

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@scarf005 scarf005 changed the title feat: add better clangd compile_commands detection fix(lsp): add better clangd compile_commands detection Jan 9, 2026
@fwang fwang requested a review from adamdotdevin as a code owner January 9, 2026 06:32
@scarf005 scarf005 force-pushed the fix/clangd-compile-commands branch from 4b8bc43 to 56511a8 Compare January 9, 2026 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant