|
| 1 | +import * as Atom from "atom"; |
| 2 | + |
| 3 | +declare module "atom-ide" { |
| 4 | + export interface DatatipService { |
| 5 | + addProvider(provider: DatatipProvider): Atom.DisposableLike; |
| 6 | + addModifierProvider(provider: ModifierDatatipProvider): Atom.DisposableLike; |
| 7 | + createPinnedDataTip( |
| 8 | + datatip: Datatip, |
| 9 | + editor: Atom.TextEditor, |
| 10 | + options?: PinnedDatatipOptions |
| 11 | + ): Atom.DisposableLike; |
| 12 | + } |
| 13 | + |
| 14 | + export interface PinnedDatatipOptions { |
| 15 | + // Defaults to 'end-of-line'. |
| 16 | + position?: PinnedDatatipPosition; |
| 17 | + // Defaults to true. |
| 18 | + showRangeHighlight?: boolean; |
| 19 | + } |
| 20 | + |
| 21 | + export type PinnedDatatipPosition = "end-of-line" | "above-range"; |
| 22 | + |
| 23 | + export interface DatatipProvider { |
| 24 | + priority: number; |
| 25 | + grammarScopes?: ReadonlyArray<string>; |
| 26 | + // A unique name for the provider to be used for analytics. |
| 27 | + // It is recommended that it be the name of the provider's package. |
| 28 | + providerName: string; |
| 29 | + datatip( |
| 30 | + editor: Atom.TextEditor, |
| 31 | + bufferPosition: Atom.Point |
| 32 | + ): Promise<Datatip | undefined | null>; |
| 33 | + } |
| 34 | + |
| 35 | + export interface ModifierDatatipProvider { |
| 36 | + priority: number; |
| 37 | + grammarScopes?: string[]; |
| 38 | + providerName: string; |
| 39 | + modifierDatatip( |
| 40 | + editor: Atom.TextEditor, |
| 41 | + bufferPosition: Atom.Point, |
| 42 | + heldKeys: Set<ModifierKey> |
| 43 | + ): Promise<Datatip | undefined | null>; |
| 44 | + } |
| 45 | + |
| 46 | + export type AnyDatatipProvider = DatatipProvider | ModifierDatatipProvider; |
| 47 | + |
| 48 | + export type Datatip = |
| 49 | + | { |
| 50 | + markedStrings: MarkedString[]; |
| 51 | + range: Atom.Range; |
| 52 | + pinnable?: boolean; |
| 53 | + } |
| 54 | + | { |
| 55 | + component: () => JSX.Element; // React component |
| 56 | + range: Atom.Range; |
| 57 | + pinnable?: boolean; |
| 58 | + }; |
| 59 | + |
| 60 | + // Borrowed from the LSP API. |
| 61 | + export type MarkedString = |
| 62 | + | { |
| 63 | + type: "markdown"; |
| 64 | + value: string; |
| 65 | + } |
| 66 | + | { |
| 67 | + type: "snippet"; |
| 68 | + grammar: Atom.Grammar; |
| 69 | + value: string; |
| 70 | + }; |
| 71 | + |
| 72 | + export type ModifierKey = "metaKey" | "shiftKey" | "altKey" | "ctrlKey"; |
| 73 | +} |
0 commit comments