Activation Events - package.json

Extensions are activated lazily in VS Code. As a result you need to provide VS Code with context as to when your extension should be activated. We support the following activation events:

We also provide an overview of the package.json extension manifest and the minimum required fields.

activationEvents.onLanguage

This activation event is emitted and interested extensions will be activated whenever a file that resolves to a certain language gets opened.

...
"activationEvents": [
    "onLanguage:python"
]
...

activationEvents.onCommand

This activation event is emitted and interested extensions will be activated whenever a command is being invoked:

...
"activationEvents": [
    "onCommand:extension.sayHello"
]
...

activationEvents.onDebug

This activation event is emitted and interested extensions will be activated whenever a debug session of the specified type is started:

...
"activationEvents": [
    "onDebug:node"
]
...

activationEvents.workspaceContains

This activation event is emitted and interested extensions will be activated whenever a folder is opened and the folder contains at least one file that matches a glob pattern.

...
"activationEvents": [
    "workspaceContains:**/.editorconfig"
]
...

activationEvents.onView

This activation event is emitted and interested extensions will be activated whenever a view of the specified id is expanded:

...
"activationEvents": [
    "onView:nodeDependencies"
]
...

activationEvents.*

This activation event is emitted and interested extensions will be activated whenever VS Code starts up. To ensure a great end user experience, please use this activation event in your extension only when no other activation events combination works in your use-case.

...
"activationEvents": [
    "*"
]
...

Note: An extension can listen to multiple activation events, and that is preferable to listening to "*".

Note: An extension must export an activate() function from its main module and it will be invoked only once by VS Code when any of the specified activation events is emitted. Also, an extension should export a deactivate() function from its main module to perform cleanup tasks on VS Code shutdown. Extension must return a Promise from deactivate() if the cleanup process is asynchronous. An extension may return undefined from deactivate() if the cleanup runs synchronously.

Next Steps

To learn more about VS Code extensibility model, try these topic: