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

C_Cpp.clang_format_path won't accept environment variable #2344

Closed
benlindsay opened this issue Aug 1, 2018 · 7 comments
Closed

C_Cpp.clang_format_path won't accept environment variable #2344

benlindsay opened this issue Aug 1, 2018 · 7 comments
Labels
bug fixed Check the Milestone for the release in which the fix is or will be available. Language Service quick fix
Milestone

Comments

@benlindsay
Copy link

Type: LanguageService

Describe the bug

  • OS and Version: Mac OSX 10.12.6
  • VS Code Version: 1.25.1
  • C/C++ Extension Version: 0.17.7
  • A clear and concise description of what the bug is.

I have my clang-format in a custom path, specifically $HOME/.local/bin/clang-format. I have this on two different computers, both of which I use to edit some code via sshfs. I want to be able to specify something like this in my user settings:

{
    "C_Cpp.clang_format_path": "${env:HOME}/.local/bin/clang-format",
}

so that I get the same formatting functionality on both computers. Formatting works fine if I put in the absolute path with no variables, but all my attempts to use a variable have disabled the formatting functionality. I've tried "${env:HOME}/.local/bin/clang-format", "${env.HOME}/.local/bin/clang-format", "~/.local/bin/clang-format", and "$HOME/.local/bin/clang-format", all with no success. After any of these attempts if I replace the path with the absolute path it immediately works again.

Is there a way to use a variable here, or some other way to fix my problem?

Thanks in advance!

@bobbrow bobbrow added this to the August 2018 milestone Aug 1, 2018
@bobbrow bobbrow added bug Language Service quick fix help wanted Can be fixed in the public (open source) repo. labels Aug 1, 2018
@bobbrow
Copy link
Member

bobbrow commented Aug 1, 2018

There is no workaround right now (besides maybe editing the extension JavaScript yourself), but this is easy enough to fix. We should have it for the next update.

@sean-mcmanus sean-mcmanus self-assigned this Aug 2, 2018
@sean-mcmanus sean-mcmanus removed the help wanted Can be fixed in the public (open source) repo. label Aug 2, 2018
@sean-mcmanus sean-mcmanus added the fixed Check the Milestone for the release in which the fix is or will be available. label Aug 10, 2018
@sean-mcmanus sean-mcmanus removed their assignment Aug 10, 2018
@sean-mcmanus
Copy link
Collaborator

sean-mcmanus commented Aug 10, 2018

The fix I added will pick up the env in the clang_format_path when the extension starts, but any changes to the clang_format_path that has an env won't be picked up until a Reload Window is done...which seems okay to me (it'll fall back to the previous clang_format_path before the settings change).

@benlindsay
Copy link
Author

@sean-mcmanus Awesome, thanks so much! This will be a great feature to have :)

@smhc
Copy link

smhc commented Aug 12, 2018

Would this also fix the ability to use '${workspaceFolder}' in compilerPath?

I would like to use a 'dummy/proxy' compiler to return the include/defines to enable me to work cross-platform and need access to workspaceFolder in the path.

@sean-mcmanus
Copy link
Collaborator

sean-mcmanus commented Aug 13, 2018

@smhc Yes -- ${workspaceFolder} should work as well with our next release.

@sean-mcmanus
Copy link
Collaborator

0.18.0 should have the fix (it doesn't need a Reload Window either, as mentioned previously).

@benlindsay
Copy link
Author

@sean-mcmanus works great! Thanks!

@github-actions github-actions bot locked and limited conversation to collaborators Oct 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug fixed Check the Milestone for the release in which the fix is or will be available. Language Service quick fix
Projects
None yet
Development

No branches or pull requests

4 participants