Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 29 additions & 4 deletions types/atom/autocomplete-plus/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,20 @@ export interface SuggestionInsertedEvent {
suggestion: TextSuggestion|SnippetSuggestion;
}

/**
* COMPATIBILITY STUB. WILL BE REMOVED
*/
// tslint:disable-next-line:no-empty-interface
export interface Suggestion<
T extends { text: string }|{ snippet: string }
> extends SuggestionBase {}
// TODO: Remove on next minor version

/**
* An autocompletion suggestion for the user.
* Primary data type for the Atom Autocomplete+ service.
*/
export interface Suggestion<T extends { text: string }|{ snippet: string }> {
export interface SuggestionBase {
/**
* A string that will show in the UI for this suggestion.
* When not set, snippet || text is displayed.
Expand Down Expand Up @@ -91,22 +100,29 @@ export interface Suggestion<T extends { text: string }|{ snippet: string }> {
* When specified, a More.. link will be displayed in the description area.
*/
descriptionMoreURL?: string;

/**
* (experimental) Description with Markdown formatting.
* Takes precedence over plaintext description.
*/
descriptionMarkdown?: string;
}

export interface TextSuggestion extends Suggestion<TextSuggestion> {
export interface TextSuggestion extends SuggestionBase {
/** The text which will be inserted into the editor, in place of the prefix. */
text: string;
}

export interface SnippetSuggestion extends Suggestion<SnippetSuggestion> {
export interface SnippetSuggestion extends SuggestionBase {
/**
* A snippet string. This will allow users to tab through function arguments
* or other options.
*/
snippet: string;
}

export type Suggestions = Array<TextSuggestion|SnippetSuggestion>;
export type AnySuggestion = TextSuggestion|SnippetSuggestion;
export type Suggestions = AnySuggestion[];

/** The interface that all Autocomplete+ providers must implement. */
export interface AutocompleteProvider {
Expand Down Expand Up @@ -154,4 +170,13 @@ export interface AutocompleteProvider {

/** Will be called if your provider is being destroyed by autocomplete+ */
dispose?(): void;

/**
* (experimental) Is called when a suggestion is selected by the user for
* the purpose of loading more information about the suggestion. Return a
* Promise of the new suggestion to replace it with or return null if
* no change is needed.
*/
getSuggestionDetailsOnSelect?:
(suggestion: AnySuggestion) => Promise<AnySuggestion | null> | AnySuggestion | null;
}