AssistantsRegistry

The AssistantsRegistry class is used to register and invoke assistants, which can provide specific extension functionality within the editor. A shared instance of the class is always available as the nova.assistants environment property.

Selectors

Each assistant registration method takes a selector argument that specifies when the assistant is applicable. This value may be a string or an object.

If this value is a string, it should be the name of a language syntax, such as "javascript". The assistant will then apply to all JavaScript documents. The special string "*" may be used to match all available syntaxes.

If this value is an object, it may have the following properties:

Value Description
syntax The name of the document’s language syntax

Methods

registerCompletionAssistant(selector, object)

Registers a completion assistant, which can provide completion items to the editor’s autocomplete list.

This method returns a Disposable that can be used to unregister the assistant.

The object provided should conform to the following interface:

interface CompletionAssistant {
    provideCompletionItems(editor, context);
}

provideCompletionItems(editor, context)

The provideCompletionItems method of the assistant should take as an argument the TextEditor instance requesting completion, and a CompletionContext object and return an array of CompletionItem objects, or a Promise resolving to such.

registerIssueAssistant(selector, object[, options])

Registers an issue assistant, which can provide diagnostic issues to the editor.

This method returns a Disposable that can be used to unregister the assistant.

The object provided should conform to the following interface:

interface IssueAssistant {
    provideIssues(editor);
}

The options parameter is optional, and can be an Object with the following properties:

Value Description
event The event for which issues are requested

Issue Request Events

The event option for issue assistants provided at registration time can affect when the editor asks for issues from the assistant:

Some issue assistants may be better suited to operating when the user saves a document as opposed to when the user changes a document. For best results, consider offering an option in an extension’s global or workspace configuration that allows this to be changed by the user.

provideIssues(editor)

The provideIssues method of the assistant should take as an argument the TextEditor instance requesting completion and return an array of Issue objects, or a Promise resolving to such.