-
Notifications
You must be signed in to change notification settings - Fork 32.8k
Expose API for variable substitution in contributed configuration #46471
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
Comments
(Experimental duplicate detection) |
Sorry bot, not quite. |
Hopping in here just to create a link to #23738 which was higher up in google search results, but was closed as a duplicate of an irrelevant bug. Hopefully this will save someone else some time in finding this issue. |
How is this different from #2809? |
I'm looking at adding a variable resolving API that you would also be able to use in debug: #81007 (comment) Note that this API proposal doesn't open the door for contributing new substitutions, only for resolving ones that VS Code already supports in other places. |
What is the current status for the suggestion to expose API for variable substitution? Eagerly hoping for such API to be exposed, so that in future the developer using vscode-java extension might be able to use variable expansion when declaring the java home path in the workspace setting rather than having to hardcode the actual path. |
Hi, I created a package to use predefined variables within your settings: https://www.npmjs.com/package/vscode-variables I will add other options later |
Wau. Thanks a lot. Now many custom extensions could finally use this support variables in settings |
I added ${config:} as well, and recursive resolving. |
Just because I haven't commented here yet, throwing my vote out here for just how incredibly helpful this would be. Even just the basics of allowing us to opt in from I have at least five different issues in the PowerShell extension for VS Code stemming from the fact that users expect extension contributed settings to support the same variable expansions as built-in settings.
As an extension author, I don't need this. Maybe others will, but I don't think we should stall getting basic support in for this possibility.
I also think it would be quite reasonable to omit |
I am trying to understand the best course of action here. Are extensions supposed to copy https://github.com/microsoft/vscode-python/blob/b68facc42f684f26c5f83f3cfe895e7aa4bb2bee/src/client/common/variables/systemVariables.ts and friends into their source tree? |
is there any update on this? It's blocking bazel-contrib/vscode-bazel#132 , which i am quite anxious to see resolved |
As this bug is 6+ years old and I do not see any signs of being addressed... do we have that anyone managed to write some code that is flexible enough to be published as an npm package so extension authors can reuse it? Apparently https://github.com/DominicVonk/vscode-variables by @DominicVonk is the best bet but considering that it was not touched in 4 years, it would require forking it to ensure it stays maintained. |
Hi @ssbarnea, I updated the package and added the long-awaited feature: ${command:...}. The variables method has become awaitable because of this. Please ask for support when needed! |
Uh oh!
There was an error while loading. Please reload this page.
So now we have a bunch of variable substitutions we can use in
.vscode/tasks.json
But what if an extension wants to give the user the ability to use substitution for the configuration points it contributes, the extension developer has to implement that all themselves. While it is totally possible to support all of these substitutions, even inlined commands, from an extension the developer has to reinvent the wheel and maintain compatibility with future/past versions of VSCode.
It would be great if there was a way for an extension to make use of the existing variable substitution logic. Unfortunately, this is pretty deeply embedded into vscode and not something made readily accessible to extension developers.
I'm sure that there will be demand for custom substitutions and for limiting what kind of substitutions are allowed.
Really rough, but this is how something like this could look.
./package.json
./src/extension.ts
Obviously
vscode.workspace.getConfiguration().get('prompt-debug.autoResolveScript');
would have to be async because substitutions with commands can take a while to evaluate.. I have a few good ideas, but I'm tired of typing so we can bikeshed later if anyone is actually interested in this.. lolThe text was updated successfully, but these errors were encountered: