Interface ICompletionProvider<T>

The interface to implement a completion provider.

interface ICompletionProvider<T> {
    identifier: string;
    rank?: number;
    renderer?: null | Completer.IRenderer<ICompletionItem>;
    fetch(request, context, trigger?): Promise<ICompletionItemsReply<T>>;
    isApplicable(context): Promise<boolean>;
    modelFactory?(context): Promise<Completer.IModel>;
    resolve?(completionItem, context, patch?): Promise<T>;
    shouldShowContinuousHint?(completerIsVisible, changed, context?): boolean;
}

Type Parameters

Implemented by

Properties

identifier: string

Unique identifier of the provider

rank?: number

Rank used to order completion results from different completion providers.

Note: The default providers (CompletionProvider:context and

CompletionProvider:kernel) use a rank of ≈500. If you want to give priority to your provider, use a rank of 1000 or above.

The rank is optional for backwards compatibility. If the rank is undefined, it will assign a rank of [1, 499] making the provider available but with a lower priority.

Renderer for provider's completions (optional).

Methods

  • Given an incomplete (unresolved) completion item, resolve it by adding all missing details, such as lazy-fetched documentation.

    Parameters

    • completionItem: T

      the completion item to resolve

    • context: ICompletionContext

      The context of the completer

    • Optional patch: null | IPatch

      The text which will be injected if the completion item is selected.

    Returns Promise<T>

  • If users enable autoCompletion in setting, this method is called on text changed event of CodeMirror to check if the completion items should be shown.

    Parameters

    • completerIsVisible: boolean

      Current visibility status of the completer widget

    • changed: SourceChange

      changed text.

    • Optional context: ICompletionContext

      The context of the completer (optional).

    Returns boolean