aaronpowell / vscode-profile-switcher

A VS Code extension for switching settings easily
https://marketplace.visualstudio.com/items?itemName=aaronpowell.vscode-profile-switcher&wt.mc_id=profileswitcher-github-aapowell
MIT License
177 stars 19 forks source link

[Question] Loading extensions by profile #2

Closed thienlhh closed 5 years ago

thienlhh commented 5 years ago

Can we adjust which extension to be loaded per profile along with other settings?

aaronpowell commented 5 years ago

It's a really good question, I'm going to investigate it (as I'd like that feature too, but settings was top priority).

One thing that may be a challenge with extensions is that some could require a reload of VSCode if you enable/disable it. Would it be acceptable to have that happen?

Also, I'd look to just programmatically disable the extensions rather than install/uninstall, as that should speed things up. Again, would that be an acceptable user experience?

aaronpowell commented 5 years ago

I've spent a bit of time digging into this today, it looks like it's a bit trickier than I was hoping for.

It looks like it might not be possible to programmatically enable/disable extensions, and there's also not an API that I can lean on. I'd have to employ an approach similar the way Settings Sync works.

I'll have a look at that tomorrow.

mburleigh commented 5 years ago

Would it be possible to swap out the extensions directory and/or the user data directory at runtime? I've set up different VS Code shortcuts in the past to launch Code with different sets of extensions for different workloads using '--extensions-dir' & '--user-data-dir' on the command line and it works great. (gotta believe that would require a reload though)

aaronpowell commented 5 years ago

@mburleigh I'll do some investigation into the source, but I highly doubt that at run time I can interact with Code at such a low level. I know there's a bunch of APIs that would be useful for me to access but they don't get exposed to the extension host (as far as I can tell at least).

aaronpowell commented 5 years ago

I've made some progress on this today, and it's in this commit: https://github.com/aaronpowell/vscode-profile-switcher/commit/dc1d39bb2d75ec20c8083cac564d1736f64bbd20

It's not complete, so I won't release it (if you want to test it you can grab it off the build job).

The way it works is:

~I'd love someone to test it for me if you're brave enough! You can side-load the extension with https://code.visualstudio.com/api/working-with-extensions/publishing-extension#packaging-extensions~

Edit: Ok, looks like the artifact isn't publicly accessible, so if you want to test it for me you can clone the repo and run the extension.

aaronpowell commented 5 years ago

🎉

Release 0.3.0 is out with extension load/unload support: https://marketplace.visualstudio.com/items?itemName=aaronpowell.vscode-profile-switcher&wt.mc_id=profileswitcher-github-aapowell