CompletionItem

A CompletionItem object defines a single item displayed in the editor completions (autocomplete) list. Items define what happens when the user selects the item, such as replacing text at the cursor position and invoking an extension command.

The CompletionItem class is not subclassable.

Class Methods

constructor(label, kind)

Creates a new completion item.

let item = new CompletionItem("foobar()", CompletionItemKind.Function);

item.documentation = "Performs the foobar request.";
item.insertText = "foobar($[args])";
item.tokenize = true;

Properties

label

The user-visible name of the item in the completions list. By default, this is the text that is also inserted into the editor when the item is chosen.

This property is readonly.

kind

The kind of item, specified using the CompletionItemKind enum, which affects things such as the icon displayed beside the item, such as CompletionItemKind.Function.

The supported members of the CompletionItemKind enumeration are:

This property is readonly.

color

A Color object to display as a swatch in place of a symbol icon, if the item’s kind is set to Color.

This property is settable.

Added in Nova 1.2.

detail

An additional label for the item that is displayed alongside it, such as its type name.

This property is settable.

documentation

A user-visible documentation string displayed at the bottom of the completions panel when the item is highlighted.

This property is settable.

filterText

The text used when filtering the item. If not specified, label will be used.

This property is settable.

insertText

The text used when inserting the item into the editor. If not specified, label will be used.

This property is settable.

insertTextFormat

The format used when inserting the item’s insertText, specified using the InsertTextFormat enum.

The supported members of the InsertTextFormat enumeration are:

This property is settable.

Added in Nova 1.2.

range

A Range value that describes the textual range within the editor that should be replaced when the item is chosen. If not specified, the word preceeding the cursor will be replaced.

This property is settable.

commitChars

A Charset object that specify the character set that, if typed while the item is highlighted, will accept the completion before inserting the typed character.

This property is settable.

tokenize

This property is deprecated as of Nova 1.2. Consider using the insertTextFormat property instead.

Whether the text inserted by the completion should parsed for a special tokenization format.

If true, then occurrences of the format $[value] (a name surrounded by brackets and prefixed with a dollar sign) will be replaced by editor tokens containing the name value, where value may be any string that contains any characters other than $, [ and ]. By default this property is false.

For backwards compatibility, settings this value to true will modify the insertTextFormat to a private value representing this format. This format may not be used alongside other insertion formats and its use is discouraged going forward.

This property is settable.

Deprecated in Nova 1.2.