nvim_runtime_lua

lsp.CompletionItem

A completion item represents a text snippet that is proposed to complete text that is being typed.

@since 3.17.0 @since 3.15.0 @since 3.16.0 @since 3.16.0 additional type InsertReplaceEdit @since 3.17.0

Fields19

CompletionItem.label : string

The label of this completion item.

The label property is also by default the text that is inserted when selecting this completion.

If label details are provided the label itself should be an unqualified name of the completion item.

CompletionItem.labelDetails : lsp.CompletionItemLabelDetails | nil
CompletionItem.kind : lsp.CompletionItemKind | nil

The kind of this completion item. Based of the kind an icon is chosen by the editor.

CompletionItem.tags : lsp.CompletionItemTag[] | nil
CompletionItem.detail : nil | string

A human-readable string with additional information about this item, like type or symbol information.

CompletionItem.documentation : string | lsp.MarkupContent | nil

A human-readable string that represents a doc-comment.

CompletionItem.deprecated : nil | boolean
Deprecated
Use `tags` instead.
CompletionItem.preselect : nil | boolean

Select this item when showing.

Note that only one completion item can be selected and that the tool / client decides which item that is. The rule is that the first item of those that match best is selected.

CompletionItem.sortText : nil | string

A string that should be used when comparing this item with other items. When falsy the {@link CompletionItem.label label} is used.

CompletionItem.filterText : nil | string

A string that should be used when filtering a set of completion items. When falsy the {@link CompletionItem.label label} is used.

CompletionItem.insertText : nil | string

A string that should be inserted into a document when selecting this completion. When falsy the {@link CompletionItem.label label} is used.

The insertText is subject to interpretation by the client side. Some tools might not take the string literally. For example VS Code when code complete is requested in this example con<cursor position> and a completion item with an insertText of console is provided it will only insert sole. Therefore it is recommended to use textEdit instead since it avoids additional client side interpretation.

CompletionItem.insertTextFormat : lsp.InsertTextFormat | nil

The format of the insert text. The format applies to both the insertText property and the newText property of a provided textEdit. If omitted defaults to InsertTextFormat.PlainText.

Please note that the insertTextFormat doesn't apply to additionalTextEdits.

CompletionItem.insertTextMode : lsp.InsertTextMode | nil
CompletionItem.textEdit : lsp.TextEdit | lsp.InsertReplaceEdit | nil
CompletionItem.textEditText : nil | string
CompletionItem.additionalTextEdits : lsp.TextEdit[] | nil

An optional array of additional {@link TextEdit text edits} that are applied when selecting this completion. Edits must not overlap (including the same insert position) with the main {@link CompletionItem.textEdit edit} nor with themselves.

Additional text edits should be used to change text unrelated to the current cursor position (for example adding an import statement at the top of the file if the completion item will insert an unqualified type).

CompletionItem.commitCharacters : string[] | nil

An optional set of characters that when pressed while this completion is active will accept it first and then type that character. Note that all commit characters should have length=1 and that superfluous characters will be ignored.

CompletionItem.command : lsp.Command | nil

An optional {@link Command command} that is executed after inserting this completion. Note that additional modifications to the current document should be described with the {@link CompletionItem.additionalTextEdits additionalTextEdits}-property.

CompletionItem.data : lsp.LSPAny | nil

A data entry field that is preserved on a completion item between a {@link CompletionRequest} and a {@link CompletionResolveRequest}.