You can contribute commands to several menus in vscode. Here is a list to which parts you can contribute your command items.
For example, if you want to add an item to the debug toolbar, you can do so by adding it to the related menu:
{
"contributes": {
"menus": {
"debug/toolBar": [
{
"command": "yourExtension.yourCommand",
"when": "inDebugMode",
}
]
}
}
}
Note, that you have to register your command in your extension.ts/extension.js and and also in your package.json first, e.g.:
extension.ts:
vscode.commands.registerCommand('yourExtension.yourCommand', () => {
console.log("Hello World");
});
and in your package.json
"commands": [
{
"command": "yourExtension.yourCommand",
"title": "Hello World"
}
]
If you want to specify conditions, when the command should be shown, you can do so by adding when conditions. In the given example, the item is only shown, while debugMode is active.
Here is a list of possible arguments in your when clause:
link