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.
Properties
An Event which fires when the global set of diagnostics changes. This is newly added and removed diagnostics.
Functions
Create a diagnostics collection.
Creates a new language status item.
Get all diagnostics.
Get all diagnostics for a given resource.
Return the identifiers of all known languages.
Compute the match between a document selector and a document. Values greater than zero mean the selector matches the document.
Register a call hierarchy provider.
Register a code action provider.
Register a code lens provider.
Register a color provider.
Register a completion provider.
Register a declaration provider.
Register a definition provider.
Registers a new DocumentDropEditProvider.
Register a formatting provider for a document.
Register a document highlight provider.
Register a document link provider.
Registers a new {@linkcode DocumentPasteEditProvider}.
Register a formatting provider for a document range.
Register a semantic tokens provider for a document range.
Register a semantic tokens provider for a whole document.
Register a document symbol provider.
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.
Register a folding range provider.
Register a hover provider.
Register an implementation provider.
Register a inlay hints provider.
Registers an inline completion provider.
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.
Register a linked editing range provider.
Register a formatting provider that works on type. The provider is active when the user enables the setting editor.formatOnType
.
Register a reference provider.
Register a rename provider.
Register a selection range provider.
Register a signature help provider.
Register a type definition provider.
Register a type hierarchy provider.
Register a workspace symbol provider.
Set a language configuration for a language.
Set (and change) the language that is associated with the given document.