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 to enable / disable extension from API or commands #15466

Closed
shanalikhan opened this issue Nov 14, 2016 · 22 comments
Closed

How to enable / disable extension from API or commands #15466

shanalikhan opened this issue Nov 14, 2016 · 22 comments
Assignees
Labels
api extensions Issues concerning extensions feature-request Request for new features or functionality *out-of-scope Posted issue is not in scope of VS Code

Comments

@shanalikhan
Copy link

shanalikhan commented Nov 14, 2016

is there any way to disable some specific extension through API ?

installExtension and uninstallExtension commands were recently added in vscode.

@ramya-rao-a
Copy link
Contributor

what is your scenario?

@ramya-rao-a ramya-rao-a added extensions Issues concerning extensions *question Issue represents a question, should be posted to StackOverflow (VS Code) labels Nov 15, 2016
@shanalikhan
Copy link
Author

shanalikhan commented Nov 15, 2016

Settings Sync needs this. If one extension is installed in one code, it installs on second code instance on work PC.

But when user disables the extension and make a backup and when it downloads the extension it enables that extension, i need to disable it from API

Ref : shanalikhan/code-settings-sync#143

@MartinSGill
Copy link

Isn't it a bit more involved than that?

When syncing extensions you need to know every extension that's installed (regardless of disabled or not) then you need to also somehow get information on which extension is disabled for which workspace.

That way you can also sync the workspace settings, essentially providing a backup, it might even be possible to share the workspace settings across installs, e.g. if two copies of a workspace are on exactly the same path on both computers.

Just my initial thoughts on how I'd expect the sync to work.

@sandy081
Copy link
Member

I agree with @MartinSGill with the approach. While syncing you should be able to have the information about installed, enabled, disabled extensions. This would lead to the issue of how we store some state/settings which we are doing in Local storage. It would be helpful if we are able to share this too.

@sandy081 sandy081 added this to the Backlog milestone Nov 16, 2016
@sandy081 sandy081 added feature-request Request for new features or functionality api and removed *question Issue represents a question, should be posted to StackOverflow (VS Code) labels Apr 7, 2017
@shanalikhan shanalikhan changed the title How to disable extension from API How to enable / disable extension from API May 29, 2017
@richarddavenport
Copy link

richarddavenport commented Sep 25, 2017

Does anyone have any updates on how we can achieve this? I have sooo many extensions installed because I work on multiple types of projects. I can always disable them for a certain workspace, but every time I pull down a new project I have to go through the tedious process of disabling multiple extensions. For example I have plenty of angular extensions and plenty of vue.js extensions, I have typescript extensions, redux extensions, extensions for c#, python, powershell, prettier/beautify, snippets, and on and on it goes.

We need a better way to manage this. If there was a way to put an extensions manifest file of some kind in the .vscode folder, then this would solve all of my problems. The next time I load up a project/workspace, then the file could enable and/or disable the extensions. This would be good because I work on a team with multiple people. The next time someone adds or removes an extension then we will all get that update. It helps with code/workspace uniformity. Also onboarding would be simplified too. I know a recommended extensions thing exists, but that honestly doesn't help at all when really we need it to automatically install/uninstall/enable/disable extensions.

@sandy081
Copy link
Member

@richarddavenport Here is the issue you are looking for - #15611

@jcrben
Copy link

jcrben commented Mar 10, 2018

@sandy081 that issue only stores the enabling into local storage - #18386 gets it all the way so that it is persisted into version control - otherwise if we end up pulling down the project again on a new machine we still run into the issue @richarddavenport mentioned of tediously having to enable extensions

@sandy081
Copy link
Member

@jcrben Yes project based extension profiles is different to #15611

@alexweininger
Copy link
Member

Any updates on adding the ability to disable extensions through the API?

I believe it would be a valuable addition to the API. It would make useful extension management extensions possible, making configuring per workspace extensions more efficient.

@shanalikhan
Copy link
Author

#73309

As installing and Uninstalling extension gets API interface.
We need similar API command to disable or enable the certain extension?

Settings Sync needs enable/disable the extension based on workspace settings.

@bashfulrobot
Copy link

This would be huge with setting sync. Then you can disable all secondary languages and tools that are not used daily. Then combined with the option to enable extensions per workspace... You can keep the editor lean for daily use. And well targeted use.

@aniforprez
Copy link

YES it would be amazing if this feature was added. I code in Python for work and in JS for my hobby and personal projects. It would be excellent if I was able to disable ALL my Vue and other JS extensions for my Python projects and all my Python extensions for my JS projects. This would SIGNIFICANTLY make the experience leaner and smoother overall. I really like this idea

@shanalikhan
Copy link
Author

@sandy081 is there any update on this ?
As installextension and uninstallextension commands were being added in last vscode releases.

@sandy081
Copy link
Member

No plans but a command similar to install extension can be thought of.

@sandy081 sandy081 modified the milestones: Backlog, On Deck Jun 25, 2019
@shanalikhan
Copy link
Author

sure, looking forward.

@shanalikhan shanalikhan changed the title How to enable / disable extension from API How to enable / disable extension from API or commands Jul 3, 2019
@bmewburn
Copy link

bmewburn commented Jul 4, 2019

I'd like to see this. My use case is to disable the built-in PHP Language Features when using https://marketplace.visualstudio.com/items?itemName=bmewburn.vscode-intelephense-client

@alexeychikk
Copy link

Also it would be great to have the API to list disabled extensions, because right now vscode.extensions.all returns only enabled and built-in extensions.

I made an extension to create and switch between extension presets in different workspaces. The only last thing I need is to be able to actually enable/disable extensions through the API and the ability to list disabled/enabled extensions.

@evald24
Copy link

evald24 commented Jun 19, 2021

I wrote a plugin that allows you to quickly apply the necessary extensions to the project on pre-prepared profiles.

The essence is very simple, you create a profile, select extensions and apply the profile.

Even after restarting VSCode, extensions remain assigned to projects.

Demo

The extension is already available on the marketplace

Who is interested here is the repository

PS: This is my first extension 🚀, if someone likes it, thank me with a star in the repository or rate me on the marketplace 😊

@evald24
Copy link

evald24 commented Jun 19, 2021

Also it would be great to have the API to list disabled extensions, because right now vscode.extensions.all returns only enabled and built-in extensions.

I made an extension to create and switch between extension presets in different workspaces. The only last thing I need is to be able to actually enable/disable extensions through the API and the ability to list disabled/enabled extensions.

I also ran into this problem, you can see how I implemented it in my repository.

Initially selected disabled extensions:
The list of globally disabled extensions I found in
${process.env.HOME}/Library/Application Support/Code/User/globalStorage/state.vscdb field extensionsIdentifiers/disabled But here it shows extensions that are disabled globally.

Initially selected the enabled extensions:

export function getEnabledExtensions() {
  return  vscode.extensions.all
    .filter((e) =>  !/.*(?:\\\\|\/)resources(?:\\\\|\/)app(?:\\\\|\/)extensions(?:\\\\|\/).*/i.test(e.extensionPath)) // ignore internal extensions
    .map(item =>({
      id: item.id,
      uuid: item?.packageJSON.uuid,
      label: item?.packageJSON.displayName,
      description: item?.packageJSON.description
    }) as ExtensionValue);
}

But it was inconvenient and wrong, and I started scanning the extensions folder, excluding the unnecessary folders listed in .obsolete

@daiyam
Copy link
Contributor

daiyam commented Jul 29, 2021

@evald24 Updating User/globalStorage/state.vscdb isn't working (the db is updated but the extensions...). Maybe it's working for workspace which your code seems to only do, but I've not tested that.

@daiyam
Copy link
Contributor

daiyam commented Aug 24, 2021

@evald24 My bad. Your code is working. I just need to restart VSCode so it can reload the updated state.vscdb.

@kosude
Copy link

kosude commented May 4, 2024

Any updates on this feature?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api extensions Issues concerning extensions feature-request Request for new features or functionality *out-of-scope Posted issue is not in scope of VS Code
Projects
None yet
Development

No branches or pull requests

16 participants