notskm / vscode-clang-tidy

MIT License
49 stars 25 forks source link

Support variables in settings.json #39

Open notskm opened 4 years ago

notskm commented 4 years ago

Certain settings like clang-tidy.buildPath should support variables like ${workspaceFolder}.

photex commented 4 years ago

For projects that aren't using a compilation database, this would be very helpful. When setting up include paths, if I treated paths relative to the folder holding the *.code-workspace file then I'm able to get a working setup, or at least something that appears to work.

alepez commented 4 years ago

I'm using "-I${workspaceFolder}/some/path" in Windows and it seems to work

photex commented 4 years ago

I tried that at first but it didn't find any headers. Curious! I'll try it again.

alepez commented 4 years ago

That's interesting. For unkwon reason it was working, BUT the extension log shows:

C:/projects/tools/LLVM-8.0.1-win64/bin/clang-tidy c:\path\to\tests.h --export-fixes=- --extra-arg-before=-x --extra-arg-before=c++ --extra-arg-before=-I --extra-arg-before=${workspaceFolder}/some/path

As you can see, clang-tidy is called with the literal "${workspaceFolder}" and not the workspace path

So at this point I don't know what's happening

joelspadin commented 4 years ago

FYI, I don't believe I don't believe variables are resolved for you in settings. It looks like an API is in progress to allow extensions to resolve variables, but until that's done you can copy the needed bits from https://github.com/microsoft/vscode/blob/master/src/vs/workbench/services/configurationResolver/common/variableResolver.ts

chausner commented 4 years ago

For buildPath, it seems you can use relative paths as a workaround. So instead of ${workspaceFolder}/build you can use build.

rickstaa commented 2 years ago

A quick update It looks like the API change that @joelspadin mentioned has been completed (see https://github.com/microsoft/vscode/issues/81007#issuecomment-680034293).

mhier commented 1 year ago

Any update on this issue? Without this feature, I am essentially unable to use clang-tidy at all in my setup (cmake with build directories never below the source directory). It seems quite essential to me.