vscode-clangd icon indicating copy to clipboard operation
vscode-clangd copied to clipboard

[Feature request]Request support for clangd's folder settings configuration in multi-root workspace

Open luckzylp opened this issue 2 years ago • 4 comments

Hello,

The clangd configuration of the 'folder settings' is unavailable in multi-root workspace

2

As the screenshot shows, clangd configuration is grey unavailable, there will be this prompt "This setting cannot be applied in this workspace. It will be applied when you open the containing workspace folder directly."

My current scenario is that the workspace has two separate projects (different toolchains) requiring different changd configurations. Refering to the cpptools extension of Microsoft, folder settings can take effect in the case of multi-root workspace. However, according to the log, clangd always uses the workspace setting(*.code-workspace).

Loading the compile_commands.json file in the directory where the *.code-workspace file resides causes the clangd extension's intellisaware functionality to be incorrect.

The expected result is to be able to load the compile_commands.json file in each Root folder of multi-root workspace.

The directory structure for the test is as follows, TestRootFolder1: . ├── .clang-format ├── workspace.code-workspace ├── .vscode │ ├── settings.json │ └── compile_commands.json ├── bin ├── include ├── lib ├── Makefile ├── src └── tests

TestRootFolder2: . ├── .clang-format ├── .vscode │ ├── settings.json │ └── compile_commands.json ├── bin ├── include ├── lib ├── Makefile ├── src └── tests

luckzylp avatar Jan 12 '23 07:01 luckzylp

在TestRootFolder1文件夹中和TestRootFolder2文件夹中增加.clangd 内容输入 CompileFlags:
CompilationDatabase: your path

lichjian avatar Apr 04 '23 09:04 lichjian

Problem is that "$(workspaceFolder}" is not parsed and substituted prior to passing the string in "--compile-commands-dir=".

mmanyen avatar Apr 27 '23 15:04 mmanyen

Problem is that "$(workspaceFolder}" is not parsed and substituted prior to passing the string in "--compile-commands-dir=".

It should be, we have support for doing that.

HighCommander4 avatar Apr 27 '23 21:04 HighCommander4

Currently, I have workspace 1, which contains four independent projects A,B,C and D. There is workspace 2, which contains four independent projects M,B,C and N, in which project B and C are shared dependencies of the two workspace. In addition, the two workspace cross-compile environments are different. It would be troublesome to configure the.clangd file

CompileFlags:
CompilationDatabase: your path

on project B and C. If we can use vscode workspace configuration to set "clangd.arguments": ["--compile-commands-dir=$(workspaceFolder)/Path"] and is automatically applied to every multi-root workspace root folder is a good solution to this problem.

"clangd.arguments": ["--compile-commands-dir=$(workspaceFolder)/Path"] 'only works for the directory where file *.code-workspace is located.

luckzylp avatar May 10 '23 15:05 luckzylp