Create vscode extensions and color themes with python.
Stable version:
pip install vscode-ext
Why should you use this for building VScode extensions when you can use typescript? Here are some reasons:
- vscode-ext builds the package.json for you! No need to switch between your extension.py and package.json in order to add commands. It also handles adding Activity Bars, Keybinds and Views.
- vscode-ext provides a more pythonic way of creating the extension. Python also has some powerful modules that Javascript doesn't and you can include these with vscode-ext
- vscode-ext extensions work perfectly with vsce and you can publish your extensions just like you would publish any other extension.
import vscode
ext = vscode.Extension(name = "testpy", display_name = "Test Py", version = "0.0.1")
@ext.event
def on_activate():
return f"The Extension '{ext.name}' has started"
@ext.command()
def hello_world():
vscode.window.show_info_message(f'Hello World from {ext.name}')
@ext.command(keybind="ALT+5")
def ask_question():
res = vscode.window.show_info_message('How are you?', 'Great', 'Meh')
if res == "Great":
vscode.window.show_info_message('Woah nice!!')
elif res == "Meh":
vscode.window.show_info_message('Sorry to hear that :(')
vscode.build(ext)
Create a python file inside a folder.
Write the code for your extension. For this tutorial we have used the Example Extension
Run the python file. It will build the files.
Press F5. This will run the extension and open a new vscode window in development mode.
Finally, test your command.
- Open the command palette with Ctrl+P in the development window.
- Type
>Hello World
- It should show a popup like this in the bottom right corner
import vscode
theme = vscode.ColorTheme(name='my-theme', display_name='My Theme', version='0.0.1')
theme.set_colors(
background='#12171F',
foreground='#EFEFEF',
accent_colors=['#399EF4', '#DA6771', '#4EB071', '#FFF099']
)
vscode.build_theme(theme)
Here's a list of some extensions built using vscode-ext. If you'd like to include your extension here feel free to create a PR.
The docs are coming soon! In the meantime you can look at the examples in order to learn how vscode-ext works and what it offers!