Creating your first extension¶
Getting Started¶
Create a folder and place a Python file inside it.
Write Extension Code¶
import vscode
from vscode import InfoMessage
ext = vscode.Extension(name="Test Extension")
@ext.event
async def on_activate():
vscode.log(f"The Extension '{ext.name}' has started")
@ext.command()
async def hello_world(ctx):
return await ctx.show(InfoMessage(f"Hello World from {ext.name}"))
ext.run()
Run the Python File¶
Execute the Python file. This action will build the necessary files.
Run the Extension¶
Press F5. This will initiate the extension and open a new VSCode window in development mode.
Test Your Command¶
Open the command palette in the development window with Ctrl+P.
Type
>Hello World
in the command palette.The popup message should appear in the bottom right corner.