Static variables

staticread onlyauthentication:VscodeAuthentication

Namespace for authentication.

staticread onlycommands:VscodeCommands

Namespace for dealing with commands. In short, a command is a function with a unique identifier. The function is sometimes also called command handler.

Commands can be added to the editor using the {@link commands.registerCommand registerCommand} and {@link commands.registerTextEditorCommand registerTextEditorCommand} functions. Commands can be executed {@link commands.executeCommand manually} or from a UI gesture. Those are:

  • palette - Use the commands-section in package.json to make a command show in the command palette.
  • keybinding - Use the keybindings-section in package.json to enable keybindings for your extension.

Commands from other extensions and from the editor itself are accessible to an extension. However, when invoking an editor command not all argument types are supported.

This is a sample that registers a command handler and adds an entry for that command to the palette. First register a command handler with the identifier extension.sayHello.

commands.registerCommand('extension.sayHello', () => {
	window.showInformationMessage('Hello World!');
});

Second, bind the command identifier to a title under which it will show in the palette (package.json).

{
	"contributes": {
		"commands": [{
			"command": "extension.sayHello",
			"title": "Hello World"
		}]
	}
}

staticread onlycomments:VscodeComments

staticread onlydebug:VscodeDebug

Namespace for debug functionality.

staticread onlyenv:VscodeEnv

Namespace describing the environment the editor runs in.

staticread onlyextensions:VscodeExtensions

Namespace for dealing with installed extensions. Extensions are represented by an {@link Extension}-interface which enables reflection on them.

Extension writers can provide APIs to other extensions by returning their API public surface from the activate-call.

export function activate(context: vscode.ExtensionContext) {
	let api = {
		sum(a, b) {
			return a + b;
		},
		mul(a, b) {
			return a * b;
		}
	};
	// 'export' public api-surface
	return api;
}

When depending on the API of another extension add an extensionDependencies-entry to package.json, and use the {@link extensions.getExtension getExtension}-function and the {@link Extension.exports exports}-property, like below:

let mathExt = extensions.getExtension('genius.math');
let importedApi = mathExt.exports;

console.log(importedApi.mul(42, 1));

staticread onlylanguages:VscodeLanguages

Namespace for participating in language-specific editor features, like IntelliSense, code actions, diagnostics etc.

Many programming languages exist and there is huge variety in syntaxes, semantics, and paradigms. Despite that, features like automatic word-completion, code navigation, or code checking have become popular across different tools for different programming languages.

The editor provides an API that makes it simple to provide such common features by having all UI and actions already in place and by allowing you to participate by providing data only. For instance, to contribute a hover all you have to do is provide a function that can be called with a {@link TextDocument} and a {@link Position} returning hover info. The rest, like tracking the mouse, positioning the hover, keeping the hover stable etc. is taken care of by the editor.

languages.registerHoverProvider('javascript', {
	provideHover(document, position, token) {
		return new Hover('I am a hover!');
	}
});

Registration is done using a {@link DocumentSelector document selector} which is either a language id, like javascript or a more complex {@link DocumentFilter filter} like { language: 'typescript', scheme: 'file' }. Matching a document against such a selector will result in a {@link languages.match score} that is used to determine if and how a provider shall be used. When scores are equal the provider that came last wins. For features that allow full arity, like {@link languages.registerHoverProvider hover}, the score is only checked to be >0, for other features, like {@link languages.registerCompletionItemProvider IntelliSense} the score is used for determining the order in which providers are asked to participate.

staticread onlynotebooks:VscodeNotebooks

Namespace for notebooks.

The notebooks functionality is composed of three loosely coupled components:

  1. {@link NotebookSerializer} enable the editor to open, show, and save notebooks
  2. {@link NotebookController} own the execution of notebooks, e.g they create output from code cells.
  3. NotebookRenderer present notebook output in the editor. They run in a separate context.

staticread onlyscm:VscodeScm

staticread onlytasks:VscodeTasks

Namespace for tasks functionality.

staticread onlytests:VscodeTests

Namespace for testing functionality. Tests are published by registering {@link TestController} instances, then adding {@link TestItem TestItems}. Controllers may also describe how to run tests by creating one or more {@link TestRunProfile} instances.

staticread onlyversion:String

The version of the editor.

staticread onlywindow:VscodeWindow

Namespace for dealing with the current window of the editor. That is visible and active editors, as well as, UI elements to show messages, selections, and asking for user input.

staticread onlyworkspace:VscodeWorkspace

Namespace for dealing with the current workspace. A workspace is the collection of one or more folders that are opened in an editor window (instance).

It is also possible to open an editor without a workspace. For example, when you open a new editor window by selecting a file from your platform's File menu, you will not be inside a workspace. In this mode, some of the editor's capabilities are reduced but you can still open text files and edit them.

Refer to https://code.visualstudio.com/docs/editor/workspaces for more information on the concept of workspaces.

The workspace offers support for {@link workspace.createFileSystemWatcher listening} to fs events and for {@link workspace.findFiles finding} files. Both perform well and run outside the editor-process so that they should be always used instead of nodejs-equivalents.