generated from atom-community/atom-ide-template
-
Notifications
You must be signed in to change notification settings - Fork 10
/
datatip.d.ts
81 lines (65 loc) · 2.3 KB
/
datatip.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import * as Atom from "atom"
export interface DatatipService {
addProvider(provider: DatatipProvider): Atom.DisposableLike
addModifierProvider?(provider: ModifierDatatipProvider): Atom.DisposableLike
createPinnedDataTip?(datatip: Datatip, editor: Atom.TextEditor, options?: PinnedDatatipOptions): Atom.DisposableLike
}
export interface PinnedDatatipOptions {
/** Defaults to 'end-of-line'. */
position?: PinnedDatatipPosition
/** Defaults to true. */
showRangeHighlight?: boolean
}
export type PinnedDatatipPosition = "end-of-line" | "above-range"
export interface DatatipProvider {
priority: number
/** A unique name for the provider to be used for analytics. It is recommended that it be the name of the provider's package. */
providerName: string
datatip(
editor: Atom.TextEditor,
bufferPosition: Atom.Point,
/** The mouse event that triggered the datatip. This is null for manually toggled datatips. */
mouseEvent?: MouseEvent | null
): Promise<Datatip | undefined | null>
/** Either pass this or `validForScope` */
grammarScopes?: ReadonlyArray<string>
/** Either pass `grammarScopes` or this function. */
validForScope?(scopeName: string): boolean
}
export interface ModifierDatatipProvider {
priority: number
grammarScopes?: string[]
providerName: string
modifierDatatip(
editor: Atom.TextEditor,
bufferPosition: Atom.Point,
heldKeys: Set<ModifierKey>
): Promise<Datatip | undefined | null>
}
export type AnyDatatipProvider = DatatipProvider | ModifierDatatipProvider
/** Borrowed from the LSP API. */
export interface MarkdownMarkedString {
type: "markdown"
value: string
}
export interface SnippetMarkedString {
type: "snippet"
grammar: Atom.Grammar
value: string
}
export type MarkedString = MarkdownMarkedString | SnippetMarkedString
export interface MarkedStringDatatip {
markedStrings: MarkedString[]
range: Atom.Range
pinnable?: boolean
}
export interface ReactComponentDatatip {
/** React component */
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore: JSX will be defined if React or Etch is used.
component: () => JSX.Element
range: Atom.Range
pinnable?: boolean
}
export type Datatip = MarkedStringDatatip | ReactComponentDatatip
export type ModifierKey = "metaKey" | "shiftKey" | "altKey" | "ctrlKey"