Completion Feature
Opened this issue · 0 comments
Completion Request
The Completion request is sent from the client to the server to compute completion items at a given cursor position. Completion items are presented in the IntelliSense user interface. If computing complete completion items is expensive servers can additional provide a handler for the resolve completion item request. This request is send when a completion item is selected in the user interface.
Changed:: in 2.0 the requests uses TextDocumentPositionParams with a proper textDocument and position property. In 1.0 the uri of the referenced text document was inlined into the params object.
Request
- method: 'textDocument/completion'
- params:
TextDocumentPositionParams
Response
- result:
CompletionItem[] | CompletionList
/**
* Represents a collection of [completion items](#CompletionItem) to be presented
* in the editor.
*/
interface CompletionList {
/**
* This list it not complete. Further typing should result in recomputing
* this list.
*/
isIncomplete: boolean;
/**
* The completion items.
*/
items: CompletionItem[];
}
interface CompletionItem {
/**
* The label of this completion item. By default
* also the text that is inserted when selecting
* this completion.
*/
label: string;
/**
* The kind of this completion item. Based of the kind
* an icon is chosen by the editor.
*/
kind?: number;
/**
* A human-readable string with additional information
* about this item, like type or symbol information.
*/
detail?: string;
/**
* A human-readable string that represents a doc-comment.
*/
documentation?: string;
/**
* A string that shoud be used when comparing this item
* with other items. When `falsy` the label is used.
*/
sortText?: string;
/**
* A string that should be used when filtering a set of
* completion items. When `falsy` the label is used.
*/
filterText?: string;
/**
* A string that should be inserted a document when selecting
* this completion. When `falsy` the label is used.
*/
insertText?: string;
/**
* An edit which is applied to a document when selecting
* this completion. When an edit is provided the value of
* insertText is ignored.
*/
textEdit?: TextEdit;
/**
* An data entry field that is preserved on a completion item between
* a completion and a completion resolve request.
*/
data?: any
}
Where CompletionItemKind is defined as follows:
/**
* The kind of a completion entry.
*/
enum CompletionItemKind {
Text = 1,
Method = 2,
Function = 3,
Constructor = 4,
Field = 5,
Variable = 6,
Class = 7,
Interface = 8,
Module = 9,
Property = 10,
Unit = 11,
Value = 12,
Enum = 13,
Keyword = 14,
Snippet = 15,
Color = 16,
File = 17,
Reference = 18
}
- error: code and message set in case an exception happens during the completion request.
Completion Item Resolve Request
The request is sent from the client to the server to resolve additional information for a given completion item.
Request
- method: 'completionItem/resolve'
- param:
CompletionItem
Response
- result:
CompletionItem
- error: code and message set in case an exception happens during the completion resolve request.