Create VSCode Extensions with python
Project description
vscode-ext
This package allows you to create vscode extensions with python.
Installation
Stable version:
pip install vscode-ext
Working version: pip install git+https://github.com/CodeWithSwastik/vscode-ext
Why use this?
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.
Tutorial
Step 1:
Create a python file inside a folder.
Step 2:
Write the code for your extension. For this tutorial we have used the Example Extension
Step 3:
Run the python file. It will build the files.
Step 4:
Press F5. This will run the extension and open a new vscode window in development mode.
Step 5:
Finally, test your command.
- Open the command palette with Ctrl+P
- Type
>Hello World
- It should show a popup like this in the bottem right corner
Example 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()
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)
Documentation
Coming soon!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file vscode-ext-1.2.2.tar.gz
.
File metadata
- Download URL: vscode-ext-1.2.2.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.10.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 50572a0fda47a5765b8057feebc92dcb67047be5daa7066da252371963a56a87 |
|
MD5 | 0ebff5bddbfc90136d07888e3215b28f |
|
BLAKE2b-256 | 9d55bf7338fc15adedb035e117ce6cbf413c7b23f18b4aa552076eef95e8233f |