alefragnani / vscode-project-manager

Project Manager Extension for Visual Studio Code
GNU General Public License v3.0
1.9k stars 226 forks source link

[FEATURE] - Support for variable substitution #550

Open depascalis opened 2 years ago

depascalis commented 2 years ago

It would be great with support for variable substitutions in paths, especially when working with the same projects on multiple machines. I don't know how it's implemented, if the API supports adding all variables in one swoop, or if they have to be implement one by one. If the latter, I believe the ${env:} variable would be most useful, with it you can access your system environment variables like ${env:PATH}, ${env:USERPROFILE}, and ${env:WHATEVER}.

This kind of solves this request also https://github.com/alefragnani/vscode-project-manager/issues/65 with ${env:APPDATA}${pathSeparator}Code${pathSeparator}User which points to vscode user directory on Windows.

alefragnani commented 2 years ago

Hi @depascalis ,

There is no support for variable substitution, at first, because there is no API available for that. Any desired variable needs to be manually supported.

But, what variables do you miss, in order to use the same projects on multiple machines?

I mean, you can use ~ or $home as a replacement for your home folder, even if you use different OS on each machine.

Hope this helps

depascalis commented 2 years ago

I should have read the docs more closely, I just assumed that variables were evaluated everywhere. I found this library though with some predefined variables if you want to proceed https://www.npmjs.com/package/vscode-variables ${env:} is included eg.

I have small "projects" everywhere on my systems, like overrides, tweaks, and hacks of stuff. But depending on the machine, a project can be under local in one case, and roaming in another, some directories aren't even under $home. Also, some projects through work are set up using system environment variables (don't ask) and it would be nice to be able to reference those, especially if and when you get the paths property out to the masses 🚀 It would also just make the config be a bit easier on the eyes :)

This request is more of a nice-to-have in my case atm, so don't bother if it is too much hassle.

alefragnani commented 2 years ago

Well, with such a complex scenario, neither if you have projects synced via Settings Sync would be enough 😄

Thanks for the additional info.

depascalis commented 2 years ago

@alefragnani If you missed it, vscode introduced the platform independent ${userHome} for tasks.json. Maybe add it to mirror the ${home} variable to avoid confusion.

https://code.visualstudio.com/updates/v1_65#_tasks

thakyZ commented 5 months ago

Would you also mind implementing ~ and $home as well as environment variables for options defined in the VSCode settings, such as:

"projectManager.git.baseFolders": [
  "~\\Development\\Git"
],

Because at the moment I have to include an absolute path, which isn't exactly a problem for me, but it would prove very useful for others.