Return the identifiers of all known languages.
Promise resolving to an array of identifier strings.
Set (and change) the language that is associated with the given document.
Note that calling this function will trigger the onDidCloseTextDocument
event
followed by the onDidOpenTextDocument
event.
The document which language is to be changed
The new language identifier.
A thenable that resolves with the updated document.
Compute the match between a document selector and a document. Values greater than zero mean the selector matches the document.
A match is computed according to these rules:
DocumentSelector
is an array, compute the match for each contained DocumentFilter
or language identifier and take the maximum value.language
-part of a DocumentFilter
, so "fooLang"
is like { language: "fooLang" }
.DocumentFilter
will be matched against the document by comparing its parts with the document. The following rules apply:DocumentFilter
is empty ({}
) the result is 0
scheme
, language
, pattern
, or notebook
are defined but one doesn't match, the result is 0
*
gives a score of 5
, matching via equality or via a glob-pattern gives a score of 10
Samples:
// default document from disk (file-scheme)
doc.uri; //'file:///my/file.js'
doc.languageId; // 'javascript'
match('javascript', doc); // 10;
match({ language: 'javascript' }, doc); // 10;
match({ language: 'javascript', scheme: 'file' }, doc); // 10;
match('*', doc); // 5
match('fooLang', doc); // 0
match(['fooLang', '*'], doc); // 5
// virtual document, e.g. from git-index
doc.uri; // 'git:/my/file.js'
doc.languageId; // 'javascript'
match('javascript', doc); // 10;
match({ language: 'javascript', scheme: 'git' }, doc); // 10;
match('*', doc); // 5
// notebook cell document
doc.uri; // `vscode-notebook-cell:///my/notebook.ipynb#gl65s2pmha`;
doc.languageId; // 'python'
match({ notebookType: 'jupyter-notebook' }, doc) // 10
match({ notebookType: 'fooNotebook', language: 'python' }, doc) // 0
match({ language: 'python' }, doc) // 10
match({ notebookType: '*' }, doc) // 5
A document selector.
A text document.
A number >0
when the selector matches and 0
when the selector does not match.
An Event which fires when the global set of diagnostics changes. This is newly added and removed diagnostics.
Get all diagnostics for a given resource.
A resource
An array of diagnostics objects or an empty array.
Get all diagnostics.
An array of uri-diagnostics tuples or an empty array.
Create a diagnostics collection.
The name of the collection.
A new diagnostic collection.
Creates a new language status item.
The identifier of the item.
The document selector that defines for what editors the item shows.
A new language status item.
Register a completion provider.
Multiple providers can be registered for a language. In that case providers are sorted by their score and groups of equal score are sequentially asked for completion items. The process stops when one or many providers of a group return a result. A failing provider (rejected promise or exception) will not fail the whole operation.
A completion item provider can be associated with a set of triggerCharacters
. When trigger
characters are being typed, completions are requested but only from providers that registered
the typed character. Because of that trigger characters should be different than word characters,
a common trigger character is .
to trigger member completions.
A selector that defines the documents this provider is applicable to.
A completion provider.
Trigger completion when the user types one of the characters.
A Disposable that unregisters this provider when being disposed.
Registers an inline completion provider.
Multiple providers can be registered for a language. In that case providers are asked in parallel and the results are merged. A failing provider (rejected promise or exception) will not cause a failure of the whole operation.
A selector that defines the documents this provider is applicable to.
An inline completion provider.
A Disposable that unregisters this provider when being disposed.
Register a code action provider.
Multiple providers can be registered for a language. In that case providers are asked in parallel and the results are merged. A failing provider (rejected promise or exception) will not cause a failure of the whole operation.
A selector that defines the documents this provider is applicable to.
A code action provider.
Metadata about the kind of code actions the provider provides.
A Disposable that unregisters this provider when being disposed.
Register a code lens provider.
Multiple providers can be registered for a language. In that case providers are asked in parallel and the results are merged. A failing provider (rejected promise or exception) will not cause a failure of the whole operation.
A selector that defines the documents this provider is applicable to.
A code lens provider.
A Disposable that unregisters this provider when being disposed.
Register a definition provider.
Multiple providers can be registered for a language. In that case providers are asked in parallel and the results are merged. A failing provider (rejected promise or exception) will not cause a failure of the whole operation.
A selector that defines the documents this provider is applicable to.
A definition provider.
A Disposable that unregisters this provider when being disposed.
Register an implementation provider.
Multiple providers can be registered for a language. In that case providers are asked in parallel and the results are merged. A failing provider (rejected promise or exception) will not cause a failure of the whole operation.
A selector that defines the documents this provider is applicable to.
An implementation provider.
A Disposable that unregisters this provider when being disposed.
Register a type definition provider.
Multiple providers can be registered for a language. In that case providers are asked in parallel and the results are merged. A failing provider (rejected promise or exception) will not cause a failure of the whole operation.
A selector that defines the documents this provider is applicable to.
A type definition provider.
A Disposable that unregisters this provider when being disposed.
Register a declaration provider.
Multiple providers can be registered for a language. In that case providers are asked in parallel and the results are merged. A failing provider (rejected promise or exception) will not cause a failure of the whole operation.
A selector that defines the documents this provider is applicable to.
A declaration provider.
A Disposable that unregisters this provider when being disposed.
Register a hover provider.
Multiple providers can be registered for a language. In that case providers are asked in parallel and the results are merged. A failing provider (rejected promise or exception) will not cause a failure of the whole operation.
A selector that defines the documents this provider is applicable to.
A hover provider.
A Disposable that unregisters this provider when being disposed.
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.
If multiple providers are registered for a language an arbitrary provider will be used.
A selector that defines the documents this provider is applicable to.
An evaluatable expression provider.
A Disposable that unregisters this provider when being disposed.
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.
Multiple providers can be registered for a language. In that case providers are asked in parallel and the results are merged. A failing provider (rejected promise or exception) will not cause a failure of the whole operation.
A selector that defines the documents this provider is applicable to.
An inline values provider.
A Disposable that unregisters this provider when being disposed.
Register a document highlight provider.
Multiple providers can be registered for a language. In that case providers are sorted
by their score and groups sequentially asked for document highlights.
The process stops when a provider returns a non-falsy
or non-failure
result.
A selector that defines the documents this provider is applicable to.
A document highlight provider.
A Disposable that unregisters this provider when being disposed.
Register a document symbol provider.
Multiple providers can be registered for a language. In that case providers are asked in parallel and the results are merged. A failing provider (rejected promise or exception) will not cause a failure of the whole operation.
A selector that defines the documents this provider is applicable to.
A document symbol provider.
metadata about the provider
A Disposable that unregisters this provider when being disposed.
Register a workspace symbol provider.
Multiple providers can be registered. In that case providers are asked in parallel and the results are merged. A failing provider (rejected promise or exception) will not cause a failure of the whole operation.
A workspace symbol provider.
A Disposable that unregisters this provider when being disposed.
Register a reference provider.
Multiple providers can be registered for a language. In that case providers are asked in parallel and the results are merged. A failing provider (rejected promise or exception) will not cause a failure of the whole operation.
A selector that defines the documents this provider is applicable to.
A reference provider.
A Disposable that unregisters this provider when being disposed.
Register a rename provider.
Multiple providers can be registered for a language. In that case providers are sorted by their score and asked in sequence. The first provider producing a result defines the result of the whole operation.
A selector that defines the documents this provider is applicable to.
A rename provider.
A Disposable that unregisters this provider when being disposed.
Register a semantic tokens provider for a whole document.
Multiple providers can be registered for a language. In that case providers are sorted by their score and the best-matching provider is used. Failure of the selected provider will cause a failure of the whole operation.
A selector that defines the documents this provider is applicable to.
A document semantic tokens provider.
A Disposable that unregisters this provider when being disposed.
Register a semantic tokens provider for a document range.
Note: If a document has both a DocumentSemanticTokensProvider
and a DocumentRangeSemanticTokensProvider
,
the range provider will be invoked only initially, for the time in which the full document provider takes
to resolve the first request. Once the full document provider resolves the first request, the semantic tokens
provided via the range provider will be discarded and from that point forward, only the document provider
will be used.
Multiple providers can be registered for a language. In that case providers are sorted by their score and the best-matching provider is used. Failure of the selected provider will cause a failure of the whole operation.
A selector that defines the documents this provider is applicable to.
A document range semantic tokens provider.
A Disposable that unregisters this provider when being disposed.
Register a formatting provider for a document.
Multiple providers can be registered for a language. In that case providers are sorted by their score and the best-matching provider is used. Failure of the selected provider will cause a failure of the whole operation.
A selector that defines the documents this provider is applicable to.
A document formatting edit provider.
A Disposable that unregisters this provider when being disposed.
Register a formatting provider for a document range.
Note: A document range provider is also a document formatter which means there is no need to register a document formatter when also registering a range provider.
Multiple providers can be registered for a language. In that case providers are sorted by their score and the best-matching provider is used. Failure of the selected provider will cause a failure of the whole operation.
A selector that defines the documents this provider is applicable to.
A document range formatting edit provider.
A Disposable that unregisters this provider when being disposed.
Register a formatting provider that works on type. The provider is active when the user enables the setting editor.formatOnType
.
Multiple providers can be registered for a language. In that case providers are sorted by their score and the best-matching provider is used. Failure of the selected provider will cause a failure of the whole operation.
A selector that defines the documents this provider is applicable to.
An on type formatting edit provider.
A character on which formatting should be triggered, like }
.
More trigger characters.
A Disposable that unregisters this provider when being disposed.
Register a signature help provider.
Multiple providers can be registered for a language. In that case providers are sorted by their score and called sequentially until a provider returns a valid result.
A selector that defines the documents this provider is applicable to.
A signature help provider.
Trigger signature help when the user types one of the characters, like ,
or (
.
A Disposable that unregisters this provider when being disposed.
A selector that defines the documents this provider is applicable to.
A signature help provider.
Information about the provider.
A Disposable that unregisters this provider when being disposed.
Register a document link provider.
Multiple providers can be registered for a language. In that case providers are asked in parallel and the results are merged. A failing provider (rejected promise or exception) will not cause a failure of the whole operation.
A selector that defines the documents this provider is applicable to.
A document link provider.
A Disposable that unregisters this provider when being disposed.
Register a color provider.
Multiple providers can be registered for a language. In that case providers are asked in parallel and the results are merged. A failing provider (rejected promise or exception) will not cause a failure of the whole operation.
A selector that defines the documents this provider is applicable to.
A color provider.
A Disposable that unregisters this provider when being disposed.
Register a inlay hints provider.
Multiple providers can be registered for a language. In that case providers are asked in parallel and the results are merged. A failing provider (rejected promise or exception) will not cause a failure of the whole operation.
A selector that defines the documents this provider is applicable to.
An inlay hints provider.
A Disposable that unregisters this provider when being disposed.
Register a folding range provider.
Multiple providers can be registered for a language. In that case providers are asked in parallel and the results are merged. If multiple folding ranges start at the same position, only the range of the first registered provider is used. If a folding range overlaps with an other range that has a smaller position, it is also ignored.
A failing provider (rejected promise or exception) will not cause a failure of the whole operation.
A selector that defines the documents this provider is applicable to.
A folding range provider.
A Disposable that unregisters this provider when being disposed.
Register a selection range provider.
Multiple providers can be registered for a language. In that case providers are asked in parallel and the results are merged. A failing provider (rejected promise or exception) will not cause a failure of the whole operation.
A selector that defines the documents this provider is applicable to.
A selection range provider.
A Disposable that unregisters this provider when being disposed.
Register a call hierarchy provider.
A selector that defines the documents this provider is applicable to.
A call hierarchy provider.
A Disposable that unregisters this provider when being disposed.
Register a type hierarchy provider.
A selector that defines the documents this provider is applicable to.
A type hierarchy provider.
A Disposable that unregisters this provider when being disposed.
Register a linked editing range provider.
Multiple providers can be registered for a language. In that case providers are sorted by their score and the best-matching provider that has a result is used. Failure of the selected provider will cause a failure of the whole operation.
A selector that defines the documents this provider is applicable to.
A linked editing range provider.
A Disposable that unregisters this provider when being disposed.
Registers a new DocumentDropEditProvider.
A selector that defines the documents this provider applies to.
A drop provider.
A Disposable that unregisters this provider when disposed of.
Set a language configuration for a language.
A language identifier like typescript
.
Language configuration.
A Disposable that unsets this configuration.
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.
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' }
. 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.