Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
braindevices opened this issue Sep 26, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@braindevices
Copy link

braindevices commented Sep 26, 2024

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)

@braindevices braindevices added the bug Something isn't working label Sep 26, 2024
@HighCommander4
Copy link
Contributor

HighCommander4 commented Sep 26, 2024

${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
Copy link
Author

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

@HighCommander4
Copy link
Contributor

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?

  • vscode-clangd version
  • vscode version
  • path to the file containing the "clangd.path" setting
  • contents of the file contianing the "clangd.path" setting
  • contents of clangd.sh (assuming it's a script)

@braindevices
Copy link
Author

  • vscode-clangd v0.1.29
  • vscode Version: 1.94.2
    Commit: 384ff7382de624fb94dbaf6da11977bba1ecd427
    Date: 2024-10-09T16:08:44.566Z
    Electron: 30.5.1
    ElectronBuildId: 10262041
    Chromium: 124.0.6367.243
    Node.js: 20.16.0
    V8: 12.4.254.20-electron.0
    OS: Linux x64 6.8.0-47-generic

@braindevices
Copy link
Author

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 HighCommander4 changed the title clangd config does not expand user (~), or ${workspaceFolder} at all Support "variables scoped per workspace folder" (e.g. ${workspaceFolder:Project1}) in config values Oct 22, 2024
@HighCommander4
Copy link
Contributor

${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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants