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

How do I expand VS Code variables used in settings? #7

Open
brobeson opened this issue Aug 26, 2022 · 1 comment
Open

How do I expand VS Code variables used in settings? #7

brobeson opened this issue Aug 26, 2022 · 1 comment
Labels
help wanted Extra attention is needed question Further information is requested

Comments

@brobeson
Copy link
Owner

It's possible for VS Code settings to use variables:

{
  "cmake.buildDirectory": "${workspaceFolder}/../build"
}

When I fetch the setting value, I get the literal text ${workspaceFolder}:

const build_directory = vscode.workspace.getConfiguration("cmake")
  .get("buildDirectory");
// build_directory === "${workspaceFolder}/../build"

How can I ask VS Code to evaluate the variable? I haven't found anything in the extension API. I did find the vscode-variables package, but I couldn't get it to work.

@brobeson brobeson added help wanted Extra attention is needed question Further information is requested labels Aug 26, 2022
@brobeson brobeson modified the milestone: Version 0.1 Aug 29, 2022
@default-writer
Copy link

Please take a look of how you can parse and process environment varialbles as well as visual studio code default variables:

Predefined Variables in test commands

The following predefined variables are supported:

${workspaceFolder} - the path of the folder opened in VS Code
${workspaceFolderBasename} - the name of the folder opened in VS Code without any slashes (/)
${file} - the current opened file
${fileWorkspaceFolder} - the current opened file's workspace folder
${relativeFile} - the current opened file relative to workspaceFolder
${relativeFileDirname} - the current opened file's dirname relative to workspaceFolder
${fileBasename} - the current opened file's basename
${fileBasenameNoExtension} - the current opened file's basename with no file extension
${fileExtname} - the current opened file's extension
${fileDirname} - the current opened file's folder path
${fileDirnameBasename} - the current opened file's folder name
${env:NAME} - reference environment variables through the ${env:Name} syntax

https://github.com/default-writer/filetestonsave/blob/main/src/extension.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed question Further information is requested
Projects
Status: Backlog
Development

No branches or pull requests

2 participants