Skip to content

Default include path relative to .code-workspace file #2009

Closed

Description

@prsullivan

Is there to any way to set default include paths relative to the .code-workspace file? I am trying to use the "C_Cpp.default.includePath" propery to set common include paths for all the folders in my multi-root workspace, but some of the folders are at different depths so using "${workspaceFolder}/../../lib1" isn't resolving properly in only some of the folders.

Activity

  1. sean-mcmanus commented on May 18, 2018

    @sean-mcmanus
    Contributor

    Can you use something like the following?

        "env": {
            "Root": "..."
        },
        "configurations": [
            {
    
                "includePath": [
                    "${env:Root}/dir"
                ],
    
  2. prsullivan commented on May 18, 2018

    @prsullivan
    Author

    Is "env" available in for use in the workspace settings? I thought that could only be used in c_cpp_properties.json folder settings.

  3. sean-mcmanus commented on May 18, 2018

    @sean-mcmanus
    Contributor

    Oops, yeah, you're right. Can you use a hardcoded path to the workspace's folder?

  4. prsullivan commented on May 18, 2018

    @prsullivan
    Author

    I could, but I would prefer not to.

  5. sean-mcmanus commented on May 18, 2018

    @sean-mcmanus
    Contributor

    We support ${env:var} (uses environment variables) and ${config:var} (uses other settings.json), see https://code.visualstudio.com/docs/editor/variables-reference . I don't know of a VS Code defined variable that references the folder with .code-workspace file...it doesn't seem like we should add our own variable to support referencing that until VS Code adds such a variable.

  6. bobbrow commented on May 22, 2018

    @bobbrow
    Contributor

    VS Code also has a syntax for ${workspaceFolder:<folder_name>} that we don't support yet. Once we support it I think that would resolve this issue. See #1774. If you think that will work for you, let us know and we'll close this issue as a duplicate.

  7. sean-mcmanus commented on May 22, 2018

    @sean-mcmanus
    Contributor

    Bob Brown (@bobbrow) I don't think that would be sufficient. A particular workspace folder is different from the workspace "root".

  8. prsullivan commented on May 22, 2018

    @prsullivan
    Author

    In my specific situation the ${workspaceFolder:<folder_name>} syntax would work. Basically I am trying set every folder included in my workspace as a default include path. Unless vscode created another environment variable for the multiroot workspace path, I think this is my best option.

  9. bobbrow commented on May 22, 2018

    @bobbrow
    Contributor

    Sean McManus (@sean-mcmanus) the .code-workspace usually lives in one of the folders. ${workspaceFolder:<folder_name>} is constant, so it should be a sufficient anchor for a relative path.

  10. bobbrow commented on May 22, 2018

    @bobbrow
    Contributor

    Closing as duplicate of #1774

  11. bobbrow commented on May 22, 2018

    @bobbrow
    Contributor

    I opened a pull request for this.

  12. sean-mcmanus commented on May 22, 2018

    @sean-mcmanus
    Contributor

    prsullivan 0.17.3 supports ${workspaceFolder:folderName}.

  13. prsullivan commented on May 23, 2018

    @prsullivan
    Author

    Thank you!

  14. locked and limited conversation to collaborators on Oct 15, 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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions