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

Some assistant registration methods takes a selector argument that specifies when the assistant is applicable. This value may be a string, an object, or an array of either.

If a selector 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 a selector is an object, it may have the following properties:

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

By using an array, you may specify multiple selectors that may match (for example, for multiple syntaxes):

let selectors = ["javascript", "jsx", "typescript", "tsx"] // string values

let selectors = [{syntax: "javascript"}, {syntax: "jsx"}, {syntax: "typescript"}, {syntax: "tsx"}] // object values

Methods

registerCompletionAssistant(selector, object[, options])

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);
}

Completion Assistant Options

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

Value Description Notes
triggerChars A Charset object that defines characters, other than identifier characters, which trigger completions to be requested (such as ., :, etc.) Added in Nova 3.

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);
}

Issue Assistant Options

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.

registerTaskAssistant(object[, options])

Added in Nova 2.

Registers a Task Assistant, which can provide tasks to the IDE.

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

The object provided should conform to the following interface:

interface TaskAssistant {
    provideTasks();
}

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

Value Description
identifier An identifier for the assistant, which can be passed to nova.workspace.reloadTasks()
name A user-readable name for the assistant displayed above its tasks

provideTasks()

The provideTasks method of the assistant should return an array of Task objects.