clangd / vscode-clangd

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

Support "variables scoped per workspace folder" (e.g. `${workspaceFolder:Project1}`) in config values #696

Open braindevices opened 1 month ago

braindevices commented 1 month ago

Please describe the problem. For hints on what information is helpful, see: https://clangd.llvm.org/troubleshooting.html

If you can, provide a minimal chunk of code that shows the problem (either inline, or attach it if larger).

settings:

"clangd.trace": "~/clangd.log",
"clangd.path": "${workspaceFolder:cpp-project}/clangd.sh"

It will report cannot find '/path/to/workspace/${workspaceFolder:cpp-project}/clangd.sh' cannot be found. Log file is also missing.

Logs related log:

Error while opening trace file ~/clangd.log: No such file or directory

System information Clangd version (from the log, or clangd --version): clangd extension version: clangd version 18.1.3 Operating system: AlmaLinux 9.4 (Seafoam Ocelot)

HighCommander4 commented 1 month ago

${workspaceFolder} should work, its substitution is implemented here.

~ is not supported but looking further up in the same function, ${userHome} should work as an alternative.

braindevices commented 1 month ago

Hmm, but at least it doesn't expand the workspacefolder in my example when I put it in clangd.path

HighCommander4 commented 1 month ago

Hmm, but at least it doesn't expand the workspacefolder in my example when I put it in clangd.path

I can't reproduce this, it seems to be expanded fine for me.

Can you provide some more details?

braindevices commented 1 month ago
braindevices commented 1 month ago

Hmm, but at least it doesn't expand the workspacefolder in my example when I put it in clangd.path

I can't reproduce this, it seems to be expanded fine for me.

Sorry, since I modify the settings too many times for testing, I actually mixed up things. ${workspaceFolder} works fine, but the Variables scoped per workspace folder ${workspaceFolder:<one of the workspace root folder name>} does not work.

I have to use ${workspaceFolder:cpp-project} to identify the path, since clangd only starts in the root1.

{
    "folders": [
        {
            "name": "non-cpp-project",
            "path": "../root1"
        },
        {
            "name": "cpp-project",
            "path": "../root2"
        }
    ],
    "settings": {
        "python.defaultInterpreterPath": "${workspaceFolder}/venv/bin/python",
        "cmake.cmakePath": "${workspaceFolder}/cmake.sh",
        "cmake.configureArgs": [
            "--fresh"
        ],
        "cmake.useCMakePresets": "always",
        "clangd.arguments": [
            "--log=verbose",
            "--suggest-missing-includes",
            "--pretty"
        ]
    }
}
HighCommander4 commented 1 month ago

${workspaceFolder} works fine, but the Variables scoped per workspace folder ${workspaceFolder:<one of the workspace root folder name>} does not work.

Thanks. I revised the issue title to be about this latter case.