Home > Enterprise >  VS Code Extension Settings
VS Code Extension Settings

Time:01-30

I have created a working VS Code extension. The extension allows someone teaching code to provide students with real-time access to the teacher's code.

I want to add one more feature to the extension to allow the teacher to connect the VS Code extension to an account form a separate web application. The teacher would login to their account on the web application, generate a token, and place that token in the VS Code extension settings.

I have spent hours looking for documentation or examples on how to add settings to a VS Code extension but can't find anything.

Is this possible? Does anyone know how to do this? Or aware of any good documentation/examples?

CodePudding user response:

Yes a little tricky as what you are looking for are configurations - which can be created by an extension and set by a user.

Configuration docs (settings)

Contribute configuration keys that will be exposed to the user. The user will be able to set these configuration options as User Settings or as Workspace Settings, either by using the Settings editor or by editing the JSON settings file directly.

There are examples and extensive docs at that link above.

Here is sample code from an extension I wrote which creates 2 settings:

 "configuration": [
   {
    "title": "Find and Transform",
    "properties": {
     "find-and-transform.enableContextMenus": {
      "type": "boolean",
      "scope": "machine",
      "default": true,
      "markdownDescription": "Show `Search in this File`, `Search in this Folder` and `Search in the Results Files` in the context menus."
     },
     "find-and-transform.enableWarningDialog": {
      "type": "boolean",
      "scope": "machine",
      "default": true,
      "markdownDescription": "Enable a warning dialog if there are bad argument keys or values in settings and keybindings."
     }
    }
   }
  ]

CodePudding user response:

Maybe you looking for that extension : https://code.visualstudio.com/learn/collaboration/live-share, it acts like google docs, with live share.

  •  Tags:  
  • Related