Interface ICompletionProvider<T>

The interface to implement a completion provider.

interface ICompletionProvider<T extends ICompletionItem = ICompletionItem> {
    identifier: string;
    rank?: number;
    renderer?: null | Completer.IRenderer<ICompletionItem>;
    fetch(
        request: CompletionHandler.IRequest,
        context: ICompletionContext,
        trigger?: CompletionTriggerKind,
    ): Promise<ICompletionItemsReply<T>>;
    isApplicable(context: ICompletionContext): Promise<boolean>;
    modelFactory(context: ICompletionContext): Promise<Completer.IModel>;
    resolve(
        completionItem: T,
        context: ICompletionContext,
        patch?: null | IPatch,
    ): Promise<T>;
    shouldShowContinuousHint(
        completerIsVisible: boolean,
        changed: SourceChange,
        context?: ICompletionContext,
    ): 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.

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

    • Optionalpatch: 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.

    • Optionalcontext: ICompletionContext

      The context of the completer (optional).

    Returns boolean