How can i extend the menu bar of visual studio code by adding my own menu?

Viewed 280

I would like to develop a debugger extension in visual studio code so that new menu in the menu bar is created when the debugger is launched for my c code.

Is it possible to create such a plugin extension in visual studio code?

Is it possible to extend menu bar at all in visual studio code ?

1 Answers

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

Related