[FEATURE]: LSP support for choosing between multiple build directories (c++ / clangd) #4721

Open
opened 2026-02-16 17:45:10 -05:00 by yindo · 1 comment
Owner

Originally created by @alcroito on GitHub (Jan 11, 2026).

Originally assigned to: @thdxr on GitHub.

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Hi,

C++ projects have one source directory, but they usually have multiple build directories, and the build directories might not be located in the root of the the source directory.

For the LSP (clangd) to give correct information, it needs to be told which build directory to use (in thi.

As far as I can tell, opencode currently just starts up clangd in the source directory, and there is no documented way in opencode to tell it which build directory to use.

It would be great if this was configurable in opencode, without having to fully override / add a new LSP entry config.

Or even better, it if it would be automatically discoverable / adjustable depending on which build dir the LLM created and is using, without having to manually track / modify this as a user.

For clangd, this can be specified either via a command line --compile-commands-dir to the clangd invocation , or via env var

"CLANGD_FLAGS": "--compile-commands-dir=<build_dir>"
Originally created by @alcroito on GitHub (Jan 11, 2026). Originally assigned to: @thdxr on GitHub. ### Feature hasn't been suggested before. - [x] I have verified this feature I'm about to request hasn't been suggested before. ### Describe the enhancement you want to request Hi, C++ projects have one source directory, but they usually have multiple build directories, and the build directories might not be located in the root of the the source directory. For the LSP (clangd) to give correct information, it needs to be told which build directory to use (in thi. As far as I can tell, opencode currently just starts up clangd in the source directory, and there is no documented way in opencode to tell it which build directory to use. It would be great if this was configurable in opencode, without having to fully override / add a new LSP entry config. Or even better, it if it would be automatically discoverable / adjustable depending on which build dir the LLM created and is using, without having to manually track / modify this as a user. For clangd, this can be specified either via a command line `--compile-commands-dir` to the `clangd` invocation , or via env var ``` "CLANGD_FLAGS": "--compile-commands-dir=<build_dir>" ```
yindo added the discussion label 2026-02-16 17:45:10 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 11, 2026):

This issue might be a duplicate of or related to existing issues. Please check:

  • #7405: How to configure LSP? - Discusses LSP configuration for C++ projects reporting false errors
  • #6131: Pyright LSP virtual environment configuration - Details about LSP configuration/initialization not handling workspace configuration correctly
  • #7184: Connect to running LSP process - Related feature request for LSP management
  • #7477: Allow configurable timeouts to be set on LSPs - Related feature about LSP customization
  • #7690: LSP detection in monorepo not working - Related to LSP configuration in complex project setups

These issues all relate to improving LSP configurability and environment handling. You might find solutions or discussion in these related issues that could help with your specific clangd build directory configuration needs.

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Jan 11, 2026): This issue might be a duplicate of or related to existing issues. Please check: - #7405: How to configure LSP? - Discusses LSP configuration for C++ projects reporting false errors - #6131: Pyright LSP virtual environment configuration - Details about LSP configuration/initialization not handling workspace configuration correctly - #7184: Connect to running LSP process - Related feature request for LSP management - #7477: Allow configurable timeouts to be set on LSPs - Related feature about LSP customization - #7690: LSP detection in monorepo not working - Related to LSP configuration in complex project setups These issues all relate to improving LSP configurability and environment handling. You might find solutions or discussion in these related issues that could help with your specific clangd build directory configuration needs. Feel free to ignore if none of these address your specific case.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#4721