Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add context menu with VSCode extension?

How do you add a context menu? (in the explorer and/or the editor)

I tried the following which doesn't work:

{
    "command": "extension.sayHello",
    "title": "Say Hello",
    "context": {
        "where": "explorer/context",
        "when": "json"
    }
}

That's based on:

https://github.com/Microsoft/vscode/issues/3192

https://github.com/Microsoft/vscode/pull/7704

like image 235
Manuel Avatar asked Dec 30 '16 17:12

Manuel


People also ask

Where is context menu in VS Code?

For those who don't know, the context menu is the little menu that opens when you click with the right button of the mouse on some empty space of the folder.

How do I add an extension to VS Code?

You can browse and install extensions from within VS Code. Bring up the Extensions view by clicking on the Extensions icon in the Activity Bar on the side of VS Code or the View: Extensions command (Ctrl+Shift+X). This will show you a list of the most popular VS Code extensions on the VS Code Marketplace.


1 Answers

The extensionAPI documentation has a working example: https://code.visualstudio.com/docs/extensionAPI/extension-points

  "contributes": {
    "commands": [
      {
          "command": "extension.sayHello",
          "title": "Say Hello"
      }
    ],
      "menus": {
        "explorer/context": [{
            "when": "resourceLangId == javascript",
            "command": "extension.sayHello",
            "group": "YourGroup@1"
      }]
    }
  },
like image 183
Manuel Avatar answered Oct 10 '22 20:10

Manuel