languages

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 TextDocument and a 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 document selector which is either a language id, like javascript or a more complex [filter} like { language: 'typescript', scheme: 'file' ][DocumentFilter]. Matching a document against such a selector will result in a 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 hover, the score is only checked to be >0, for other features, like IntelliSense the score is used for determining the order in which providers are asked to participate.

Online Documentation

Properties

Link copied to clipboard

An Event which fires when the global set of diagnostics changes. This is newly added and removed diagnostics.

Functions

Link copied to clipboard

Create a diagnostics collection.

Link copied to clipboard

Get all diagnostics.

Get all diagnostics for a given resource.

Link copied to clipboard

Return the identifiers of all known languages.

Link copied to clipboard
fun match(selector: DocumentSelector, document: TextDocument): Int

Compute the match between a document selector and a document. Values greater than zero mean the selector matches the document.

Link copied to clipboard

Register a call hierarchy provider.

Link copied to clipboard
fun registerCodeActionsProvider(selector: DocumentSelector, provider: CodeActionProvider<*>, metadata: CodeActionProviderMetadata = definedExternally): Disposable

Register a code action provider.

Link copied to clipboard

Register a code lens provider.

Link copied to clipboard

Register a color provider.

Link copied to clipboard
fun registerCompletionItemProvider(selector: DocumentSelector, provider: CompletionItemProvider<*>, vararg triggerCharacters: String): Disposable

Register a completion provider.

Link copied to clipboard

Register a declaration provider.

Link copied to clipboard

Register a definition provider.

Link copied to clipboard

Register a formatting provider for a document.

Link copied to clipboard

Register a document highlight provider.

Link copied to clipboard

Register a document link provider.

Link copied to clipboard

Registers a new {@linkcode DocumentPasteEditProvider}.

Register a formatting provider for a document range.

Register a semantic tokens provider for a document range.

Link copied to clipboard

Register a semantic tokens provider for a whole document.

Link copied to clipboard

Register a document symbol provider.

Link copied to clipboard

Register a provider that locates evaluatable expressions in text documents. The editor will evaluate the expression in the active debug session and will show the result in the debug hover.

Link copied to clipboard

Register a folding range provider.

Link copied to clipboard

Register a hover provider.

Link copied to clipboard

Register an implementation provider.

Link copied to clipboard

Register a inlay hints provider.

Link copied to clipboard

Registers an inline completion provider.

Link copied to clipboard

Register a provider that returns data for the debugger's 'inline value' feature. Whenever the generic debugger has stopped in a source file, providers registered for the language of the file are called to return textual data that will be shown in the editor at the end of lines.

Link copied to clipboard

Register a linked editing range provider.

Link copied to clipboard
fun registerOnTypeFormattingEditProvider(selector: DocumentSelector, provider: OnTypeFormattingEditProvider, firstTriggerCharacter: String, vararg moreTriggerCharacter: String): Disposable

Register a formatting provider that works on type. The provider is active when the user enables the setting editor.formatOnType.

Link copied to clipboard

Register a reference provider.

Link copied to clipboard

Register a rename provider.

Link copied to clipboard

Register a selection range provider.

Link copied to clipboard
fun registerSignatureHelpProvider(selector: DocumentSelector, provider: SignatureHelpProvider, vararg triggerCharacters: String): Disposable

Register a signature help provider.

Link copied to clipboard

Register a type definition provider.

Link copied to clipboard

Register a type hierarchy provider.

Link copied to clipboard

Register a workspace symbol provider.

Link copied to clipboard

Set a language configuration for a language.

Link copied to clipboard

Set (and change) the language that is associated with the given document.