Skip to content

34j/vscode-python-extension-core

Repository files navigation

vscode-python-extension-core

npm package Build Status Downloads Issues Code Coverage Commitizen Friendly Semantic Release

Core package to create VSCode Python extension. Use 34j/vscode-python-extension-cookiecutter to create a new extension.

See the above package for usage.

Install

npm install vscode-python-extension-core

Usage

// The module 'vscode' contains the VS Code extensibility API
// Import the module and reference it with the alias vscode in your code below
import * as vscode from "vscode";
import * as core from "vscode-python-extension-core";
import { PackageInfo } from "vscode-python-extension-core";

// this method is called when your extension is activated
// your extension is activated the very first time the command is executed
export function activate(context: vscode.ExtensionContext) {
  const packageInfo: PackageInfo = {
    packageName: "{{cookiecutter.module_name}}",
    packageDisplayName: "{{cookiecutter.module_name}}",
    extensionName: "{{cookiecutter.ext_name}}",
    runCommandName: "{{cookiecutter.ext_name}}.run",
    runForWorkspaceCommandName: "{{cookiecutter.ext_name}}.runForWorkspace",
    packageConfigurationSection: "{{cookiecutter.ext_name}}.settings",
    useIntegratedTerminalConfigurationSectionFullName:
      "{{cookiecutter.ext_name}}.useIntegratedTerminal",
  };
  const disp = new core.commandDispatcher.EasyCommandDispatcher(
    context,
    packageInfo,
    new core.packageRunner.EasyOptionsBuilder(
      packageInfo,
      [], [], [], []
    )
  );
  disp.activate();
}

// this method is called when your extension is deactivated
export function deactivate() {}

API

commandDispatcher

Helper class to dispatch VSCode commands.

packageRunner

Helper class to run Python packages.

pythonTerminal

Helper class to run Python commands in VSCode terminal or child_process.

PackageInfo

Information about the Python package to run. This class is used everywhere.