Skip to content

C_Cpp.clang_format_path won't accept environment variable #2344

Closed

Description

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!

Activity

  1. bobbrow commented on Aug 1, 2018

    @bobbrow
    Contributor

    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.

  2. added
    fixedCheck the Milestone for the release in which the fix is or will be available.
    on Aug 10, 2018
  3. sean-mcmanus commented on Aug 10, 2018

    @sean-mcmanus
    Contributor

    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).

  4. benlindsay commented on Aug 10, 2018

    @benlindsay
    Author

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

  5. smhc commented on Aug 12, 2018

    @smhc

    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.

  6. sean-mcmanus commented on Aug 13, 2018

    @sean-mcmanus
    Contributor

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

  7. sean-mcmanus commented on Aug 17, 2018

    @sean-mcmanus
    Contributor

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

  8. benlindsay commented on Aug 17, 2018

    @benlindsay
    Author

    Sean McManus (@sean-mcmanus) works great! Thanks!

  9. locked and limited conversation to collaborators on Oct 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Language ServicebugfixedCheck the Milestone for the release in which the fix is or will be available.quick fix

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions