clangd / vscode-clangd

Visual Studio Code extension for clangd
https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.vscode-clangd
MIT License
592 stars 97 forks source link

Add separate setting to set `--compile-commands-dir` #644

Open recursivenomad opened 5 days ago

recursivenomad commented 5 days ago

The directory that my compile_commands.json is located in varies per-project, and I would like to be able to set --compile-commands-dir in a per-project VSCode settings.json. The location of compilers varies per-user, and I am currently using the global "clangd.arguments" setting to define the location of my compilers with --query-driver. You cannot have "clangd.arguments" in your project and global settings, as the project settings will override the global settings, thus getting rid of the --query-driver arguments.

To solve this, it would be very helpful if I could define --compile-commands-dir with a separate settings.json entry, therefore enabling us to set the location of compile_commands.json per-project.

Technically, I think it would make sense to append this argument specifically after "clangd.arguments", so that if --compile-commands-dir is already declared in "clangd.arguments", then the project-level --compile-command-dir is supplied last and therefore would be the one clangd uses.

For additional context, please see this discussion in the clangd language server repository.