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(${0:args})";
item.insertTextFormat = InsertTextFormat.Snippet;

Properties

additionalTextEdits

An array of TextEdit objects describing additional changes to apply to the editor when this item is chosen, unrelated to the change made to the completion position. The ranges of these edits must not intersect each other nor the range of the completion item’s primary edit.

This property is settable.

Added in Nova 2.

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.

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.

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.

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, organized by logical category, are:

Types Description Notes
Type A generic object type or metatype.
Class An object class type.
Category An extension to a type.
Interface An interface of type conformance.
Enum An enumeration of values.
Union A union of types.
Struct A simple type structure.
Types Description Notes
Function A self-contained callable.
Method A callable member of an object.
Closure A self-contained closure.
Constructor An object type constructor.
Destructor An object type destructor. Added in Nova 4.
Getter An object property getter.
Setter An object property setter.
StaticMethod A static callable member of a type. Added in Nova 4.
Values Description Notes
Constant A non-modifyable value.
Variable A modifyable value.
Property An object property value.
Argument An argument passed to a callable.
Color A color value.
EnumMember A member value of an enumeration.
StaticProperty A static type property value. Added in Nova 4.
Expressions Description Notes
Expression An inline expression.
Statement An inline statement.
Package A logical code package.
File A referenced document.
Reference An external reference.
Keyword A syntactic keyword.
Stylesheets Description Notes
StyleRuleset A set of rules, such as CSS attributes.
StyleDirective A set of directives, such as a CSS @at-rule.
StyleID A style ID selector.
StyleClass A style class selector.
StylePseudoClass A style pseudo-class selector. Added in Nova 4.
StylePseudoElement A style pseudo-element selector. Added in Nova 4.
Tags Description Notes
Tag A generic markup tag.
TagHead A document head (metadata) tag. Added in Nova 4.
TagTitle A document title tag. Added in Nova 4.
TagMeta A document metadata item tag. Added in Nova 4.
TagLink An external resource reference tag (link). Added in Nova 4.
TagBody A document body tag. Added in Nova 4.
TagScript An scripting reference tag. Added in Nova 4.
TagStyle A styleset reference tag. Added in Nova 4.
TagHeading A heading tag (h1, etc.). Added in Nova 4.
TagSection A section tag (section, nav, etc.). Added in Nova 4.
TagContainer A generic container tag (div, span). Added in Nova 4.
TagUnorderedList An unordered list tag. Added in Nova 4.
TagOrderedList An ordered list tag. Added in Nova 4.
TagListItem A list item tag. Added in Nova 4.
TagAnchor An external resource anchor tag (a). Added in Nova 4.
TagImage An external image reference tag (img). Added in Nova 4.
TagMedia An external media asset reference tag (audio, etc.). Added in Nova 4.
TagForm A form tag. Added in Nova 4.
TagFormField A form field tag. Added in Nova 4.
TagFramework A framework tag (PHP, etc). Added in Nova 4.

This property is readonly.

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.

path

If the item’s kind is CompletionItemKind.File and this property is set to a file path, the file’s icon will be used for the completion item (as long as the image is not also set).

Additionally, the file path may be shown beside the completion item to indicate the full path it represents (if, for example, the item’s name is just the file or module name).

Added in Nova 7.

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.

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.