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

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

Open braindevices opened this issue 1 year ago • 6 comments

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 avatar Sep 26 '24 18:09 braindevices

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

HighCommander4 avatar Sep 26 '24 21:09 HighCommander4

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

braindevices avatar Sep 27 '24 13:09 braindevices

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)

HighCommander4 avatar Oct 01 '24 04:10 HighCommander4

  • 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 avatar Oct 21 '24 19:10 braindevices

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"
		]
	}
}

braindevices avatar Oct 21 '24 19:10 braindevices

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

HighCommander4 avatar Oct 22 '24 04:10 HighCommander4