mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 13:29:44 +00:00
Expose the inline completions provider in the monaco editor.
This commit is contained in:
parent
e9579534bb
commit
67a8548712
|
@ -686,7 +686,7 @@ export interface CompletionItemProvider {
|
|||
}
|
||||
|
||||
/**
|
||||
* How an {@link InlineCompletionItemProvider inline completion provider} was triggered.
|
||||
* How an {@link InlineCompletionsProvider inline completion provider} was triggered.
|
||||
*/
|
||||
export enum InlineCompletionTriggerKind {
|
||||
/**
|
||||
|
@ -709,9 +709,6 @@ export interface InlineCompletionContext {
|
|||
readonly triggerKind: InlineCompletionTriggerKind;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export interface InlineCompletion {
|
||||
/**
|
||||
* The text to insert.
|
||||
|
@ -729,20 +726,21 @@ export interface InlineCompletion {
|
|||
readonly command?: Command;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export interface InlineCompletions<TItem extends InlineCompletion = InlineCompletion> {
|
||||
readonly items: readonly TItem[];
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export interface InlineCompletionsProvider<T extends InlineCompletions = InlineCompletions> {
|
||||
provideInlineCompletions(model: model.ITextModel, position: Position, context: InlineCompletionContext, token: CancellationToken): ProviderResult<T>;
|
||||
|
||||
/**
|
||||
* Will be called when an item is shown.
|
||||
*/
|
||||
handleItemDidShow?(completions: T, item: T['items'][number]): void;
|
||||
|
||||
/**
|
||||
* Will be called when a completions list is no longer in use and can be garbage-collected.
|
||||
*/
|
||||
freeInlineCompletions(completions: T): void;
|
||||
}
|
||||
|
||||
|
|
|
@ -361,7 +361,7 @@ export enum InlayHintKind {
|
|||
}
|
||||
|
||||
/**
|
||||
* How an {@link InlineCompletionItemProvider inline completion provider} was triggered.
|
||||
* How an {@link InlineCompletionsProvider inline completion provider} was triggered.
|
||||
*/
|
||||
export enum InlineCompletionTriggerKind {
|
||||
/**
|
||||
|
|
|
@ -547,6 +547,13 @@ export function registerDocumentRangeSemanticTokensProvider(languageId: string,
|
|||
return modes.DocumentRangeSemanticTokensProviderRegistry.register(languageId, provider);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register an inline completions provider.
|
||||
*/
|
||||
export function registerInlineCompletionsProvider(languageId: string, provider: modes.InlineCompletionsProvider): IDisposable {
|
||||
return modes.InlineCompletionsProviderRegistry.register(languageId, provider);
|
||||
}
|
||||
|
||||
/**
|
||||
* Contains additional diagnostic information about the context in which
|
||||
* a [code action](#CodeActionProvider.provideCodeActions) is run.
|
||||
|
@ -613,6 +620,7 @@ export function createMonacoLanguagesAPI(): typeof monaco.languages {
|
|||
registerSelectionRangeProvider: <any>registerSelectionRangeProvider,
|
||||
registerDocumentSemanticTokensProvider: <any>registerDocumentSemanticTokensProvider,
|
||||
registerDocumentRangeSemanticTokensProvider: <any>registerDocumentRangeSemanticTokensProvider,
|
||||
registerInlineCompletionsProvider: <any>registerInlineCompletionsProvider,
|
||||
|
||||
// enums
|
||||
DocumentHighlightKind: standaloneEnums.DocumentHighlightKind,
|
||||
|
|
38
src/vs/monaco.d.ts
vendored
38
src/vs/monaco.d.ts
vendored
|
@ -5330,6 +5330,11 @@ declare namespace monaco.languages {
|
|||
*/
|
||||
export function registerDocumentRangeSemanticTokensProvider(languageId: string, provider: DocumentRangeSemanticTokensProvider): IDisposable;
|
||||
|
||||
/**
|
||||
* Register an inline completions provider.
|
||||
*/
|
||||
export function registerInlineCompletionsProvider(languageId: string, provider: InlineCompletionsProvider): IDisposable;
|
||||
|
||||
/**
|
||||
* Contains additional diagnostic information about the context in which
|
||||
* a [code action](#CodeActionProvider.provideCodeActions) is run.
|
||||
|
@ -5837,7 +5842,7 @@ declare namespace monaco.languages {
|
|||
}
|
||||
|
||||
/**
|
||||
* How an {@link InlineCompletionItemProvider inline completion provider} was triggered.
|
||||
* How an {@link InlineCompletionsProvider inline completion provider} was triggered.
|
||||
*/
|
||||
export enum InlineCompletionTriggerKind {
|
||||
/**
|
||||
|
@ -5859,6 +5864,37 @@ declare namespace monaco.languages {
|
|||
readonly triggerKind: InlineCompletionTriggerKind;
|
||||
}
|
||||
|
||||
export interface InlineCompletion {
|
||||
/**
|
||||
* The text to insert.
|
||||
* If the text contains a line break, the range must end at the end of a line.
|
||||
* If existing text should be replaced, the existing text must be a prefix of the text to insert.
|
||||
*/
|
||||
readonly text: string;
|
||||
/**
|
||||
* The range to replace.
|
||||
* Must begin and end on the same line.
|
||||
*/
|
||||
readonly range?: IRange;
|
||||
readonly command?: Command;
|
||||
}
|
||||
|
||||
export interface InlineCompletions<TItem extends InlineCompletion = InlineCompletion> {
|
||||
readonly items: readonly TItem[];
|
||||
}
|
||||
|
||||
export interface InlineCompletionsProvider<T extends InlineCompletions = InlineCompletions> {
|
||||
provideInlineCompletions(model: editor.ITextModel, position: Position, context: InlineCompletionContext, token: CancellationToken): ProviderResult<T>;
|
||||
/**
|
||||
* Will be called when an item is shown.
|
||||
*/
|
||||
handleItemDidShow?(completions: T, item: T['items'][number]): void;
|
||||
/**
|
||||
* Will be called when a completions list is no longer in use and can be garbage-collected.
|
||||
*/
|
||||
freeInlineCompletions(completions: T): void;
|
||||
}
|
||||
|
||||
export interface CodeAction {
|
||||
title: string;
|
||||
command?: Command;
|
||||
|
|
Loading…
Reference in a new issue