1 | /******************************************************************
|
2 | MIT License http://www.opensource.org/licenses/mit-license.php
|
3 | Author Qiming Zhao <chemzqm@gmail> (https://github.com/chemzqm)
|
4 | *******************************************************************/
|
5 |
|
6 | /// <reference types="node" />
|
7 | import cp from 'child_process'
|
8 | import { URL } from 'url'
|
9 |
|
10 | declare module 'coc.nvim' {
|
11 | // Language server protocol interfaces {{
|
12 | export interface Thenable<T> {
|
13 | then<TResult>(onfulfilled?: (value: T) => TResult | Thenable<TResult>, onrejected?: (reason: any) => TResult | Thenable<TResult>): Thenable<TResult>
|
14 | // eslint-disable-next-line @typescript-eslint/unified-signatures
|
15 | then<TResult>(onfulfilled?: (value: T) => TResult | Thenable<TResult>, onrejected?: (reason: any) => void): Thenable<TResult>
|
16 | }
|
17 |
|
18 | export interface Disposable {
|
19 | /**
|
20 | * Dispose this object.
|
21 | */
|
22 | dispose(): void
|
23 | }
|
24 |
|
25 | export namespace Disposable {
|
26 | function create(func: () => void): Disposable
|
27 | }
|
28 |
|
29 | /**
|
30 | * The declaration of a symbol representation as one or many [locations](#Location).
|
31 | */
|
32 | export type Declaration = Location | Location[]
|
33 | /**
|
34 | * Information about where a symbol is declared.
|
35 | *
|
36 | * Provides additional metadata over normal [location](#Location) declarations, including the range of
|
37 | * the declaring symbol.
|
38 | *
|
39 | * Servers should prefer returning `DeclarationLink` over `Declaration` if supported
|
40 | * by the client.
|
41 | */
|
42 | export type DeclarationLink = LocationLink
|
43 |
|
44 | export type ProgressToken = number | string
|
45 |
|
46 | export interface WorkDoneProgressBegin {
|
47 | kind: 'begin'
|
48 | /**
|
49 | * Mandatory title of the progress operation. Used to briefly inform about
|
50 | * the kind of operation being performed.
|
51 | *
|
52 | * Examples: "Indexing" or "Linking dependencies".
|
53 | */
|
54 | title: string
|
55 | /**
|
56 | * Controls if a cancel button should show to allow the user to cancel the
|
57 | * long running operation. Clients that don't support cancellation are allowed
|
58 | * to ignore the setting.
|
59 | */
|
60 | cancellable?: boolean
|
61 | /**
|
62 | * Optional, more detailed associated progress message. Contains
|
63 | * complementary information to the `title`.
|
64 | *
|
65 | * Examples: "3/25 files", "project/src/module2", "node_modules/some_dep".
|
66 | * If unset, the previous progress message (if any) is still valid.
|
67 | */
|
68 | message?: string
|
69 | /**
|
70 | * Optional progress percentage to display (value 100 is considered 100%).
|
71 | * If not provided infinite progress is assumed and clients are allowed
|
72 | * to ignore the `percentage` value in subsequent in report notifications.
|
73 | *
|
74 | * The value should be steadily rising. Clients are free to ignore values
|
75 | * that are not following this rule.
|
76 | */
|
77 | percentage?: number
|
78 | }
|
79 |
|
80 | export interface WorkDoneProgressReport {
|
81 | kind: 'report'
|
82 | /**
|
83 | * Controls enablement state of a cancel button. This property is only valid if a cancel
|
84 | * button got requested in the `WorkDoneProgressStart` payload.
|
85 | *
|
86 | * Clients that don't support cancellation or don't support control the button's
|
87 | * enablement state are allowed to ignore the setting.
|
88 | */
|
89 | cancellable?: boolean
|
90 | /**
|
91 | * Optional, more detailed associated progress message. Contains
|
92 | * complementary information to the `title`.
|
93 | *
|
94 | * Examples: "3/25 files", "project/src/module2", "node_modules/some_dep".
|
95 | * If unset, the previous progress message (if any) is still valid.
|
96 | */
|
97 | message?: string
|
98 | /**
|
99 | * Optional progress percentage to display (value 100 is considered 100%).
|
100 | * If not provided infinite progress is assumed and clients are allowed
|
101 | * to ignore the `percentage` value in subsequent in report notifications.
|
102 | *
|
103 | * The value should be steadily rising. Clients are free to ignore values
|
104 | * that are not following this rule.
|
105 | */
|
106 | percentage?: number
|
107 | }
|
108 |
|
109 | /**
|
110 | * The file event type
|
111 | */
|
112 | export namespace FileChangeType {
|
113 | /**
|
114 | * The file got created.
|
115 | */
|
116 | const Created = 1
|
117 | /**
|
118 | * The file got changed.
|
119 | */
|
120 | const Changed = 2
|
121 | /**
|
122 | * The file got deleted.
|
123 | */
|
124 | const Deleted = 3
|
125 | }
|
126 |
|
127 | export type FileChangeType = 1 | 2 | 3
|
128 |
|
129 | /**
|
130 | * An event describing a file change.
|
131 | */
|
132 | export interface FileEvent {
|
133 | /**
|
134 | * The file's uri.
|
135 | */
|
136 | uri: string
|
137 | /**
|
138 | * The change type.
|
139 | */
|
140 | type: FileChangeType
|
141 | }
|
142 |
|
143 | export interface WorkDoneProgressEnd {
|
144 | kind: 'end'
|
145 | /**
|
146 | * Optional, a final message indicating to for example indicate the outcome
|
147 | * of the operation.
|
148 | */
|
149 | message?: string
|
150 | }
|
151 |
|
152 | /**
|
153 | * A literal to identify a text document in the client.
|
154 | */
|
155 | export interface TextDocumentIdentifier {
|
156 | /**
|
157 | * The text document's uri.
|
158 | */
|
159 | uri: string
|
160 | }
|
161 |
|
162 | /**
|
163 | * A parameter literal used in requests to pass a text document and a position inside that
|
164 | * document.
|
165 | */
|
166 | export interface TextDocumentPositionParams {
|
167 | /**
|
168 | * The text document.
|
169 | */
|
170 | textDocument: TextDocumentIdentifier
|
171 | /**
|
172 | * The position inside the text document.
|
173 | */
|
174 | position: Position
|
175 | }
|
176 |
|
177 | export interface WorkspaceFolder {
|
178 | /**
|
179 | * The associated URI for this workspace folder.
|
180 | */
|
181 | uri: string
|
182 | /**
|
183 | * The name of the workspace folder. Used to refer to this
|
184 | * workspace folder in the user interface.
|
185 | */
|
186 | name: string
|
187 | }
|
188 |
|
189 | /**
|
190 | * An event describing a change to a text document.
|
191 | */
|
192 | export interface TextDocumentContentChange {
|
193 | /**
|
194 | * The range of the document that changed.
|
195 | */
|
196 | range: Range
|
197 | /**
|
198 | * The new text for the provided range.
|
199 | */
|
200 | text: string
|
201 | }
|
202 |
|
203 | /**
|
204 | * The workspace folder change event.
|
205 | */
|
206 | export interface WorkspaceFoldersChangeEvent {
|
207 | /**
|
208 | * The array of added workspace folders
|
209 | */
|
210 | added: WorkspaceFolder[]
|
211 | /**
|
212 | * The array of the removed workspace folders
|
213 | */
|
214 | removed: WorkspaceFolder[]
|
215 | }
|
216 |
|
217 | /**
|
218 | * An event that is fired when a [document](#LinesTextDocument) will be saved.
|
219 | *
|
220 | * To make modifications to the document before it is being saved, call the
|
221 | * [`waitUntil`](#TextDocumentWillSaveEvent.waitUntil)-function with a thenable
|
222 | * that resolves to an array of [text edits](#TextEdit).
|
223 | */
|
224 | export interface TextDocumentWillSaveEvent {
|
225 |
|
226 | /**
|
227 | * The document that will be saved.
|
228 | */
|
229 | document: LinesTextDocument
|
230 |
|
231 | /**
|
232 | * The reason why save was triggered.
|
233 | */
|
234 | reason: 1 | 2 | 3
|
235 | }
|
236 |
|
237 | /**
|
238 | * A document filter denotes a document by different properties like
|
239 | * the [language](#LinesTextDocument.languageId), the [scheme](#Uri.scheme) of
|
240 | * its resource, or a glob-pattern that is applied to the [path](#LinesTextDocument.fileName).
|
241 | *
|
242 | * Glob patterns can have the following syntax:
|
243 | * - `*` to match one or more characters in a path segment
|
244 | * - `?` to match on one character in a path segment
|
245 | * - `**` to match any number of path segments, including none
|
246 | * - `{}` to group conditions (e.g. `**/*.{ts,js}` matches all TypeScript and JavaScript files)
|
247 | * - `[]` to declare a range of characters to match in a path segment (e.g., `example.[0-9]` to match on `example.0`, `example.1`, …)
|
248 | * - `[!...]` to negate a range of characters to match in a path segment (e.g., `example.[!0-9]` to match on `example.a`, `example.b`, but not `example.0`)
|
249 | *
|
250 | * @sample A language filter that applies to typescript files on disk: `{ language: 'typescript', scheme: 'file' }`
|
251 | * @sample A language filter that applies to all package.json paths: `{ language: 'json', pattern: '**package.json' }`
|
252 | */
|
253 | export type DocumentFilter = {
|
254 | /** A language id, like `typescript`. */
|
255 | language: string
|
256 | /** A Uri [scheme](#Uri.scheme), like `file` or `untitled`. */
|
257 | scheme?: string
|
258 | /** A glob pattern, like `*.{ts,js}`. */
|
259 | pattern?: string
|
260 | } | {
|
261 | /** A language id, like `typescript`. */
|
262 | language?: string
|
263 | /** A Uri [scheme](#Uri.scheme), like `file` or `untitled`. */
|
264 | scheme: string
|
265 | /** A glob pattern, like `*.{ts,js}`. */
|
266 | pattern?: string
|
267 | } | {
|
268 | /** A language id, like `typescript`. */
|
269 | language?: string
|
270 | /** A Uri [scheme](#Uri.scheme), like `file` or `untitled`. */
|
271 | scheme?: string
|
272 | /** A glob pattern, like `*.{ts,js}`. */
|
273 | pattern: string
|
274 | }
|
275 | /**
|
276 | * A document selector is the combination of one or many document filters.
|
277 | *
|
278 | * @sample `let sel:DocumentSelector = [{ language: 'typescript' }, { language: 'json', pattern: '**∕tsconfig.json' }]`;
|
279 | */
|
280 | export type DocumentSelector = (string | DocumentFilter)[]
|
281 | /**
|
282 | * A selection range represents a part of a selection hierarchy. A selection range
|
283 | * may have a parent selection range that contains it.
|
284 | */
|
285 | export interface SelectionRange {
|
286 | /**
|
287 | * The [range](#Range) of this selection range.
|
288 | */
|
289 | range: Range
|
290 | /**
|
291 | * The parent selection range containing this range. Therefore `parent.range` must contain `this.range`.
|
292 | */
|
293 | parent?: SelectionRange
|
294 | }
|
295 |
|
296 | /**
|
297 | * MarkedString can be used to render human readable text. It is either a markdown string
|
298 | * or a code-block that provides a language and a code snippet. The language identifier
|
299 | * is semantically equal to the optional language identifier in fenced code blocks in GitHub
|
300 | * issues. See https://help.github.com/articles/creating-and-highlighting-code-blocks/#syntax-highlighting
|
301 | *
|
302 | * The pair of a language and a value is an equivalent to markdown:
|
303 | * ```${language}
|
304 | * ${value}
|
305 | * ```
|
306 | *
|
307 | * Note that markdown strings will be sanitized - that means html will be escaped.
|
308 | * @deprecated use MarkupContent instead.
|
309 | */
|
310 | export type MarkedString = string | {
|
311 | language: string
|
312 | value: string
|
313 | }
|
314 | /**
|
315 | * The result of a hover request.
|
316 | */
|
317 | export interface Hover {
|
318 | /**
|
319 | * The hover's content
|
320 | */
|
321 | contents: MarkupContent | MarkedString | MarkedString[]
|
322 | /**
|
323 | * An optional range
|
324 | */
|
325 | range?: Range
|
326 | }
|
327 |
|
328 | /**
|
329 | * The definition of a symbol represented as one or many [locations](#Location).
|
330 | * For most programming languages there is only one location at which a symbol is
|
331 | * defined.
|
332 | *
|
333 | * Servers should prefer returning `DefinitionLink` over `Definition` if supported
|
334 | * by the client.
|
335 | */
|
336 | export type Definition = Location | Location[]
|
337 |
|
338 | /**
|
339 | * Information about where a symbol is defined.
|
340 | *
|
341 | * Provides additional metadata over normal [location](#Location) definitions, including the range of
|
342 | * the defining symbol
|
343 | */
|
344 | export type DefinitionLink = LocationLink
|
345 |
|
346 | /**
|
347 | * How a signature help was triggered.
|
348 | */
|
349 | export namespace SignatureHelpTriggerKind {
|
350 | /**
|
351 | * Signature help was invoked manually by the user or by a command.
|
352 | */
|
353 | const Invoked: 1
|
354 | /**
|
355 | * Signature help was triggered by a trigger character.
|
356 | */
|
357 | const TriggerCharacter: 2
|
358 | /**
|
359 | * Signature help was triggered by the cursor moving or by the document content changing.
|
360 | */
|
361 | const ContentChange: 3
|
362 | }
|
363 |
|
364 | export type SignatureHelpTriggerKind = 1 | 2 | 3
|
365 |
|
366 | /**
|
367 | * Represents the signature of something callable. A signature
|
368 | * can have a label, like a function-name, a doc-comment, and
|
369 | * a set of parameters.
|
370 | */
|
371 | export interface SignatureInformation {
|
372 | /**
|
373 | * The label of this signature. Will be shown in
|
374 | * the UI.
|
375 | */
|
376 | label: string
|
377 | /**
|
378 | * The human-readable doc-comment of this signature. Will be shown
|
379 | * in the UI but can be omitted.
|
380 | */
|
381 | documentation?: string | MarkupContent
|
382 | /**
|
383 | * The parameters of this signature.
|
384 | */
|
385 | parameters?: ParameterInformation[]
|
386 | /**
|
387 | * The index of the active parameter.
|
388 | *
|
389 | * If provided, this is used in place of `SignatureHelp.activeParameter`.
|
390 | *
|
391 | * @since 3.16.0
|
392 | */
|
393 | activeParameter?: number
|
394 | }
|
395 |
|
396 | /**
|
397 | * Represents a parameter of a callable-signature. A parameter can
|
398 | * have a label and a doc-comment.
|
399 | */
|
400 | export interface ParameterInformation {
|
401 | /**
|
402 | * The label of this parameter information.
|
403 | *
|
404 | * Either a string or an inclusive start and exclusive end offsets within its containing
|
405 | * signature label. (see SignatureInformation.label). The offsets are based on a UTF-16
|
406 | * string representation as `Position` and `Range` does.
|
407 | *
|
408 | * *Note*: a label of type string should be a substring of its containing signature label.
|
409 | * Its intended use case is to highlight the parameter label part in the `SignatureInformation.label`.
|
410 | */
|
411 | label: string | [number, number]
|
412 | /**
|
413 | * The human-readable doc-comment of this signature. Will be shown
|
414 | * in the UI but can be omitted.
|
415 | */
|
416 | documentation?: string | MarkupContent
|
417 | }
|
418 |
|
419 | /**
|
420 | * Signature help represents the signature of something
|
421 | * callable. There can be multiple signature but only one
|
422 | * active and only one active parameter.
|
423 | */
|
424 | export interface SignatureHelp {
|
425 | /**
|
426 | * One or more signatures.
|
427 | */
|
428 | signatures: SignatureInformation[]
|
429 | /**
|
430 | * The active signature. Set to `null` if no
|
431 | * signatures exist.
|
432 | */
|
433 | activeSignature: number | null
|
434 | /**
|
435 | * The active parameter of the active signature. Set to `null`
|
436 | * if the active signature has no parameters.
|
437 | */
|
438 | activeParameter: number | null
|
439 | }
|
440 | /**
|
441 | * Additional information about the context in which a signature help request was triggered.
|
442 | *
|
443 | * @since 3.15.0
|
444 | */
|
445 | export interface SignatureHelpContext {
|
446 | /**
|
447 | * Action that caused signature help to be triggered.
|
448 | */
|
449 | triggerKind: SignatureHelpTriggerKind
|
450 | /**
|
451 | * Character that caused signature help to be triggered.
|
452 | *
|
453 | * This is undefined when `triggerKind !== SignatureHelpTriggerKind.TriggerCharacter`
|
454 | */
|
455 | triggerCharacter?: string
|
456 | /**
|
457 | * `true` if signature help was already showing when it was triggered.
|
458 | *
|
459 | * Retriggers occur when the signature help is already active and can be caused by actions such as
|
460 | * typing a trigger character, a cursor move, or document content changes.
|
461 | */
|
462 | isRetrigger: boolean
|
463 | /**
|
464 | * The currently active `SignatureHelp`.
|
465 | *
|
466 | * The `activeSignatureHelp` has its `SignatureHelp.activeSignature` field updated based on
|
467 | * the user navigating through available signatures.
|
468 | */
|
469 | activeSignatureHelp?: SignatureHelp
|
470 | }
|
471 |
|
472 | /**
|
473 | * Represents a folding range.
|
474 | */
|
475 | export interface FoldingRange {
|
476 | /**
|
477 | * The zero-based line number from where the folded range starts.
|
478 | */
|
479 | startLine: number
|
480 | /**
|
481 | * The zero-based character offset from where the folded range starts. If not defined, defaults to the length of the start line.
|
482 | */
|
483 | startCharacter?: number
|
484 | /**
|
485 | * The zero-based line number where the folded range ends.
|
486 | */
|
487 | endLine: number
|
488 | /**
|
489 | * The zero-based character offset before the folded range ends. If not defined, defaults to the length of the end line.
|
490 | */
|
491 | endCharacter?: number
|
492 | /**
|
493 | * Describes the kind of the folding range such as `comment' or 'region'. The kind
|
494 | * is used to categorize folding ranges and used by commands like 'Fold all comments'. See
|
495 | * [FoldingRangeKind](#FoldingRangeKind) for an enumeration of standardized kinds.
|
496 | */
|
497 | kind?: string
|
498 | }
|
499 |
|
500 | /**
|
501 | * A symbol kind.
|
502 | */
|
503 | export namespace SymbolKind {
|
504 | const File: 1
|
505 | const Module: 2
|
506 | const Namespace: 3
|
507 | const Package: 4
|
508 | const Class: 5
|
509 | const Method: 6
|
510 | const Property: 7
|
511 | const Field: 8
|
512 | const Constructor: 9
|
513 | const Enum: 10
|
514 | const Interface: 11
|
515 | const Function: 12
|
516 | const Variable: 13
|
517 | const Constant: 14
|
518 | const String: 15
|
519 | const Number: 16
|
520 | const Boolean: 17
|
521 | const Array: 18
|
522 | const Object: 19
|
523 | const Key: 20
|
524 | const Null: 21
|
525 | const EnumMember: 22
|
526 | const Struct: 23
|
527 | const Event: 24
|
528 | const Operator: 25
|
529 | const TypeParameter: 26
|
530 | }
|
531 |
|
532 | export type SymbolKind = 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
|
533 |
|
534 | /**
|
535 | * Represents information about programming constructs like variables, classes,
|
536 | * interfaces etc.
|
537 | */
|
538 | export interface SymbolInformation {
|
539 | /**
|
540 | * The name of this symbol.
|
541 | */
|
542 | name: string
|
543 | /**
|
544 | * The kind of this symbol.
|
545 | */
|
546 | kind: SymbolKind
|
547 | /**
|
548 | * Indicates if this symbol is deprecated.
|
549 | */
|
550 | deprecated?: boolean
|
551 | /**
|
552 | * The location of this symbol. The location's range is used by a tool
|
553 | * to reveal the location in the editor. If the symbol is selected in the
|
554 | * tool the range's start information is used to position the cursor. So
|
555 | * the range usually spans more than the actual symbol's name and does
|
556 | * normally include thinks like visibility modifiers.
|
557 | *
|
558 | * The range doesn't have to denote a node range in the sense of a abstract
|
559 | * syntax tree. It can therefore not be used to re-construct a hierarchy of
|
560 | * the symbols.
|
561 | */
|
562 | location: Location
|
563 | /**
|
564 | * The name of the symbol containing this symbol. This information is for
|
565 | * user interface purposes (e.g. to render a qualifier in the user interface
|
566 | * if necessary). It can't be used to re-infer a hierarchy for the document
|
567 | * symbols.
|
568 | */
|
569 | containerName?: string
|
570 | }
|
571 |
|
572 | /**
|
573 | * Represents programming constructs like variables, classes, interfaces etc.
|
574 | * that appear in a document. Document symbols can be hierarchical and they
|
575 | * have two ranges: one that encloses its definition and one that points to
|
576 | * its most interesting range, e.g. the range of an identifier.
|
577 | */
|
578 | export interface DocumentSymbol {
|
579 | /**
|
580 | * The name of this symbol. Will be displayed in the user interface and therefore must not be
|
581 | * an empty string or a string only consisting of white spaces.
|
582 | */
|
583 | name: string
|
584 | /**
|
585 | * More detail for this symbol, e.g the signature of a function.
|
586 | */
|
587 | detail?: string
|
588 | /**
|
589 | * The kind of this symbol.
|
590 | */
|
591 | kind: SymbolKind
|
592 | /**
|
593 | * Indicates if this symbol is deprecated.
|
594 | */
|
595 | deprecated?: boolean
|
596 | /**
|
597 | * The range enclosing this symbol not including leading/trailing whitespace but everything else
|
598 | * like comments. This information is typically used to determine if the the clients cursor is
|
599 | * inside the symbol to reveal in the symbol in the UI.
|
600 | */
|
601 | range: Range
|
602 | /**
|
603 | * The range that should be selected and revealed when this symbol is being picked, e.g the name of a function.
|
604 | * Must be contained by the the `range`.
|
605 | */
|
606 | selectionRange: Range
|
607 | /**
|
608 | * Children of this symbol, e.g. properties of a class.
|
609 | */
|
610 | children?: DocumentSymbol[]
|
611 | }
|
612 |
|
613 | export interface FormattingOptions {
|
614 | /**
|
615 | * If indentation is based on spaces (`insertSpaces` = true), the number of spaces that make an indent.
|
616 | */
|
617 | tabSize: number
|
618 | /**
|
619 | * Is indentation based on spaces?
|
620 | */
|
621 | insertSpaces: boolean
|
622 | /**
|
623 | * Trim trailing whitespaces on a line.
|
624 | *
|
625 | * @since 3.15.0
|
626 | */
|
627 | trimTrailingWhitespace?: boolean
|
628 | /**
|
629 | * Insert a newline character at the end of the file if one does not exist.
|
630 | *
|
631 | * @since 3.15.0
|
632 | */
|
633 | insertFinalNewline?: boolean
|
634 | /**
|
635 | * Trim all newlines after the final newline at the end of the file.
|
636 | *
|
637 | * @since 3.15.0
|
638 | */
|
639 | trimFinalNewlines?: boolean
|
640 | }
|
641 |
|
642 | /**
|
643 | * The reason why code actions were requested.
|
644 | *
|
645 | * @since 3.17.0
|
646 | */
|
647 | export namespace CodeActionTriggerKind {
|
648 | /**
|
649 | * Code actions were explicitly requested by the user or by an extension.
|
650 | */
|
651 | const Invoked: 1
|
652 | /**
|
653 | * Code actions were requested automatically.
|
654 | *
|
655 | * This typically happens when current selection in a file changes, but can
|
656 | * also be triggered when file content changes.
|
657 | */
|
658 | const Automatic: 2
|
659 | }
|
660 | export type CodeActionTriggerKind = 1 | 2
|
661 | /**
|
662 | * Contains additional diagnostic information about the context in which
|
663 | * a [code action](#CodeActionProvider.provideCodeActions) is run.
|
664 | */
|
665 | export interface CodeActionContext {
|
666 | /**
|
667 | * An array of diagnostics known on the client side overlapping the range provided to the
|
668 | * `textDocument/codeAction` request. They are provided so that the server knows which
|
669 | * errors are currently presented to the user for the given range. There is no guarantee
|
670 | * that these accurately reflect the error state of the resource. The primary parameter
|
671 | * to compute code actions is the provided range.
|
672 | */
|
673 | diagnostics: Diagnostic[]
|
674 | /**
|
675 | * Requested kind of actions to return.
|
676 | *
|
677 | * Actions not of this kind are filtered out by the client before being shown. So servers
|
678 | * can omit computing them.
|
679 | */
|
680 | only?: string[]
|
681 | /**
|
682 | * The reason why code actions were requested.
|
683 | *
|
684 | * @since 3.17.0
|
685 | */
|
686 | triggerKind?: CodeActionTriggerKind
|
687 | }
|
688 |
|
689 |
|
690 | /**
|
691 | * A document highlight kind.
|
692 | */
|
693 | export namespace DocumentHighlightKind {
|
694 | /**
|
695 | * A textual occurrence.
|
696 | */
|
697 | const Text: 1
|
698 | /**
|
699 | * Read-access of a symbol, like reading a variable.
|
700 | */
|
701 | const Read: 2
|
702 | /**
|
703 | * Write-access of a symbol, like writing to a variable.
|
704 | */
|
705 | const Write: 3
|
706 | }
|
707 |
|
708 | export type DocumentHighlightKind = 1 | 2 | 3
|
709 | /**
|
710 | * A document highlight is a range inside a text document which deserves
|
711 | * special attention. Usually a document highlight is visualized by changing
|
712 | * the background color of its range.
|
713 | */
|
714 | export interface DocumentHighlight {
|
715 | /**
|
716 | * The range this highlight applies to.
|
717 | */
|
718 | range: Range
|
719 | /**
|
720 | * The highlight kind, default is [text](#DocumentHighlightKind.Text).
|
721 | */
|
722 | kind?: DocumentHighlightKind
|
723 | }
|
724 |
|
725 | /**
|
726 | * A document link is a range in a text document that links to an internal or external resource, like another
|
727 | * text document or a web site.
|
728 | */
|
729 | export interface DocumentLink {
|
730 | /**
|
731 | * The range this link applies to.
|
732 | */
|
733 | range: Range
|
734 | /**
|
735 | * The uri this link points to.
|
736 | */
|
737 | target?: string
|
738 | /**
|
739 | * The tooltip text when you hover over this link.
|
740 | *
|
741 | * If a tooltip is provided, is will be displayed in a string that includes instructions on how to
|
742 | * trigger the link, such as `{0} (ctrl + click)`. The specific instructions vary depending on OS,
|
743 | * user settings, and localization.
|
744 | *
|
745 | * @since 3.15.0
|
746 | */
|
747 | tooltip?: string
|
748 | /**
|
749 | * A data entry field that is preserved on a document link between a
|
750 | * DocumentLinkRequest and a DocumentLinkResolveRequest.
|
751 | */
|
752 | data?: any
|
753 | }
|
754 |
|
755 | /**
|
756 | * Represents a color in RGBA space.
|
757 | */
|
758 | export interface Color {
|
759 | /**
|
760 | * The red component of this color in the range [0-1].
|
761 | */
|
762 | readonly red: number
|
763 | /**
|
764 | * The green component of this color in the range [0-1].
|
765 | */
|
766 | readonly green: number
|
767 | /**
|
768 | * The blue component of this color in the range [0-1].
|
769 | */
|
770 | readonly blue: number
|
771 | /**
|
772 | * The alpha component of this color in the range [0-1].
|
773 | */
|
774 | readonly alpha: number
|
775 | }
|
776 |
|
777 | /**
|
778 | * Represents a color range from a document.
|
779 | */
|
780 | export interface ColorInformation {
|
781 | /**
|
782 | * The range in the document where this color appears.
|
783 | */
|
784 | range: Range
|
785 | /**
|
786 | * The actual color value for this color range.
|
787 | */
|
788 | color: Color
|
789 | }
|
790 |
|
791 | export interface ColorPresentation {
|
792 | /**
|
793 | * The label of this color presentation. It will be shown on the color
|
794 | * picker header. By default this is also the text that is inserted when selecting
|
795 | * this color presentation.
|
796 | */
|
797 | label: string
|
798 | /**
|
799 | * An [edit](#TextEdit) which is applied to a document when selecting
|
800 | * this presentation for the color. When `falsy` the [label](#ColorPresentation.label)
|
801 | * is used.
|
802 | */
|
803 | textEdit?: TextEdit
|
804 | /**
|
805 | * An optional array of additional [text edits](#TextEdit) that are applied when
|
806 | * selecting this color presentation. Edits must not overlap with the main [edit](#ColorPresentation.textEdit) nor with themselves.
|
807 | */
|
808 | additionalTextEdits?: TextEdit[]
|
809 | }
|
810 |
|
811 | /**
|
812 | * A code lens represents a [command](#Command) that should be shown along with
|
813 | * source text, like the number of references, a way to run tests, etc.
|
814 | *
|
815 | * A code lens is _unresolved_ when no command is associated to it. For performance
|
816 | * reasons the creation of a code lens and resolving should be done to two stages.
|
817 | */
|
818 | export interface CodeLens {
|
819 | /**
|
820 | * The range in which this code lens is valid. Should only span a single line.
|
821 | */
|
822 | range: Range
|
823 | /**
|
824 | * The command this code lens represents.
|
825 | */
|
826 | command?: Command
|
827 | /**
|
828 | * An data entry field that is preserved on a code lens item between
|
829 | * a [CodeLensRequest](#CodeLensRequest) and a [CodeLensResolveRequest]
|
830 | * (#CodeLensResolveRequest)
|
831 | */
|
832 | data?: any
|
833 | }
|
834 |
|
835 | /**
|
836 | * Represents the connection of two locations. Provides additional metadata over normal [locations](#Location),
|
837 | * including an origin range.
|
838 | */
|
839 | export interface LocationLink {
|
840 | /**
|
841 | * Span of the origin of this link.
|
842 | *
|
843 | * Used as the underlined span for mouse definition hover. Defaults to the word range at
|
844 | * the definition position.
|
845 | */
|
846 | originSelectionRange?: Range
|
847 | /**
|
848 | * The target resource identifier of this link.
|
849 | */
|
850 | targetUri: string
|
851 | /**
|
852 | * The full target range of this link. If the target for example is a symbol then target range is the
|
853 | * range enclosing this symbol not including leading/trailing whitespace but everything else
|
854 | * like comments. This information is typically used to highlight the range in the editor.
|
855 | */
|
856 | targetRange: Range
|
857 | /**
|
858 | * The range that should be selected and revealed when this link is being followed, e.g the name of a function.
|
859 | * Must be contained by the the `targetRange`. See also `DocumentSymbol#range`
|
860 | */
|
861 | targetSelectionRange: Range
|
862 | }
|
863 |
|
864 | /**
|
865 | * The LocationLink namespace provides helper functions to work with
|
866 | * [LocationLink](#LocationLink) literals.
|
867 | */
|
868 | export namespace LocationLink {
|
869 | /**
|
870 | * Creates a LocationLink literal.
|
871 | * @param targetUri The definition's uri.
|
872 | * @param targetRange The full range of the definition.
|
873 | * @param targetSelectionRange The span of the symbol definition at the target.
|
874 | * @param originSelectionRange The span of the symbol being defined in the originating source file.
|
875 | */
|
876 | function create(targetUri: string, targetRange: Range, targetSelectionRange: Range, originSelectionRange?: Range): LocationLink
|
877 | /**
|
878 | * Checks whether the given literal conforms to the [LocationLink](#LocationLink) interface.
|
879 | */
|
880 | function is(value: any): value is LocationLink
|
881 | }
|
882 |
|
883 | export type MarkupKind = 'plaintext' | 'markdown'
|
884 |
|
885 | /**
|
886 | * Describes the content type that a client supports in various
|
887 | * result literals like `Hover`, `ParameterInfo` or `CompletionItem`.
|
888 | *
|
889 | * Please note that `MarkupKinds` must not start with a `$`. This kinds
|
890 | * are reserved for internal usage.
|
891 | */
|
892 | export namespace MarkupKind {
|
893 | /**
|
894 | * Plain text is supported as a content format
|
895 | */
|
896 | const PlainText: 'plaintext'
|
897 | /**
|
898 | * Markdown is supported as a content format
|
899 | */
|
900 | const Markdown: 'markdown'
|
901 | }
|
902 | /**
|
903 | * A `MarkupContent` literal represents a string value which content is interpreted base on its
|
904 | * kind flag. Currently the protocol supports `plaintext` and `markdown` as markup kinds.
|
905 | *
|
906 | * If the kind is `markdown` then the value can contain fenced code blocks like in GitHub issues.
|
907 | * See https://help.github.com/articles/creating-and-highlighting-code-blocks/#syntax-highlighting
|
908 | *
|
909 | * Here is an example how such a string can be constructed using JavaScript / TypeScript:
|
910 | * ```ts
|
911 | * let markdown: MarkdownContent = {
|
912 | * kind: MarkupKind.Markdown,
|
913 | * value: [
|
914 | * '# Header',
|
915 | * 'Some text',
|
916 | * '```typescript',
|
917 | * 'someCode();',
|
918 | * '```'
|
919 | * ].join('\n')
|
920 | * };
|
921 | * ```
|
922 | *
|
923 | * *Please Note* that clients might sanitize the return markdown. A client could decide to
|
924 | * remove HTML from the markdown to avoid script execution.
|
925 | */
|
926 | export interface MarkupContent {
|
927 | /**
|
928 | * The type of the Markup
|
929 | */
|
930 | kind: MarkupKind
|
931 | /**
|
932 | * The content itself
|
933 | */
|
934 | value: string
|
935 | }
|
936 |
|
937 | /**
|
938 | * The kind of a completion entry.
|
939 | */
|
940 | export namespace CompletionItemKind {
|
941 | const Text: 1
|
942 | const Method: 2
|
943 | const Function: 3
|
944 | const Constructor: 4
|
945 | const Field: 5
|
946 | const Variable: 6
|
947 | const Class: 7
|
948 | const Interface: 8
|
949 | const Module: 9
|
950 | const Property: 10
|
951 | const Unit: 11
|
952 | const Value: 12
|
953 | const Enum: 13
|
954 | const Keyword: 14
|
955 | const Snippet: 15
|
956 | const Color: 16
|
957 | const File: 17
|
958 | const Reference: 18
|
959 | const Folder: 19
|
960 | const EnumMember: 20
|
961 | const Constant: 21
|
962 | const Struct: 22
|
963 | const Event: 23
|
964 | const Operator: 24
|
965 | const TypeParameter: 25
|
966 | }
|
967 |
|
968 | export type CompletionItemKind = 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
|
969 |
|
970 | /**
|
971 | * Defines whether the insert text in a completion item should be interpreted as
|
972 | * plain text or a snippet.
|
973 | */
|
974 | export namespace InsertTextFormat {
|
975 | /**
|
976 | * The primary text to be inserted is treated as a plain string.
|
977 | */
|
978 | const PlainText: 1
|
979 | /**
|
980 | * The primary text to be inserted is treated as a snippet.
|
981 | *
|
982 | * A snippet can define tab stops and placeholders with `$1`, `$2`
|
983 | * and `${3:foo}`. `$0` defines the final tab stop, it defaults to
|
984 | * the end of the snippet. Placeholders with equal identifiers are linked,
|
985 | * that is typing in one will update others too.
|
986 | *
|
987 | * See also: https://github.com/microsoft/vscode/blob/main/src/vs/editor/contrib/snippet/snippet.md
|
988 | */
|
989 | const Snippet: 2
|
990 | }
|
991 | export type InsertTextFormat = 1 | 2
|
992 |
|
993 | /**
|
994 | * A completion item represents a text snippet that is
|
995 | * proposed to complete text that is being typed.
|
996 | */
|
997 | export interface CompletionItem {
|
998 | /**
|
999 | * The label of this completion item. By default
|
1000 | * also the text that is inserted when selecting
|
1001 | * this completion.
|
1002 | */
|
1003 | label: string
|
1004 | /**
|
1005 | * The kind of this completion item. Based of the kind
|
1006 | * an icon is chosen by the editor.
|
1007 | */
|
1008 | kind?: CompletionItemKind
|
1009 | /**
|
1010 | * Tags for this completion item.
|
1011 | *
|
1012 | * @since 3.15.0
|
1013 | */
|
1014 | tags?: number[]
|
1015 | /**
|
1016 | * A human-readable string with additional information
|
1017 | * about this item, like type or symbol information.
|
1018 | */
|
1019 | detail?: string
|
1020 | /**
|
1021 | * A human-readable string that represents a doc-comment.
|
1022 | */
|
1023 | documentation?: string | MarkupContent
|
1024 | /**
|
1025 | * Indicates if this item is deprecated.
|
1026 | * @deprecated Use `tags` instead.
|
1027 | */
|
1028 | deprecated?: boolean
|
1029 | /**
|
1030 | * Select this item when showing.
|
1031 | *
|
1032 | * *Note* that only one completion item can be selected and that the
|
1033 | * tool / client decides which item that is. The rule is that the *first*
|
1034 | * item of those that match best is selected.
|
1035 | */
|
1036 | preselect?: boolean
|
1037 | /**
|
1038 | * A string that should be used when comparing this item
|
1039 | * with other items. When `falsy` the [label](#CompletionItem.label)
|
1040 | * is used.
|
1041 | */
|
1042 | sortText?: string
|
1043 | /**
|
1044 | * A string that should be used when filtering a set of
|
1045 | * completion items. When `falsy` the [label](#CompletionItem.label)
|
1046 | * is used.
|
1047 | */
|
1048 | filterText?: string
|
1049 | /**
|
1050 | * A string that should be inserted into a document when selecting
|
1051 | * this completion. When `falsy` the [label](#CompletionItem.label)
|
1052 | * is used.
|
1053 | *
|
1054 | * The `insertText` is subject to interpretation by the client side.
|
1055 | * Some tools might not take the string literally. For example
|
1056 | * VS Code when code complete is requested in this example `con<cursor position>`
|
1057 | * and a completion item with an `insertText` of `console` is provided it
|
1058 | * will only insert `sole`. Therefore it is recommended to use `textEdit` instead
|
1059 | * since it avoids additional client side interpretation.
|
1060 | */
|
1061 | insertText?: string
|
1062 | /**
|
1063 | * The format of the insert text. The format applies to both the `insertText` property
|
1064 | * and the `newText` property of a provided `textEdit`. If omitted defaults to
|
1065 | * `InsertTextFormat.PlainText`.
|
1066 | */
|
1067 | insertTextFormat?: InsertTextFormat
|
1068 | /**
|
1069 | * An [edit](#TextEdit) which is applied to a document when selecting
|
1070 | * this completion. When an edit is provided the value of
|
1071 | * [insertText](#CompletionItem.insertText) is ignored.
|
1072 | *
|
1073 | * *Note:* The text edit's range must be a [single line] and it must contain the position
|
1074 | * at which completion has been requested.
|
1075 | */
|
1076 | textEdit?: TextEdit
|
1077 | /**
|
1078 | * An optional array of additional [text edits](#TextEdit) that are applied when
|
1079 | * selecting this completion. Edits must not overlap (including the same insert position)
|
1080 | * with the main [edit](#CompletionItem.textEdit) nor with themselves.
|
1081 | *
|
1082 | * Additional text edits should be used to change text unrelated to the current cursor position
|
1083 | * (for example adding an import statement at the top of the file if the completion item will
|
1084 | * insert an unqualified type).
|
1085 | */
|
1086 | additionalTextEdits?: TextEdit[]
|
1087 | /**
|
1088 | * An optional set of characters that when pressed while this completion is active will accept it first and
|
1089 | * then type that character. *Note* that all commit characters should have `length=1` and that superfluous
|
1090 | * characters will be ignored.
|
1091 | */
|
1092 | commitCharacters?: string[]
|
1093 | /**
|
1094 | * An optional [command](#Command) that is executed *after* inserting this completion. *Note* that
|
1095 | * additional modifications to the current document should be described with the
|
1096 | * [additionalTextEdits](#CompletionItem.additionalTextEdits)-property.
|
1097 | */
|
1098 | command?: Command
|
1099 | /**
|
1100 | * An data entry field that is preserved on a completion item between
|
1101 | * a [CompletionRequest](#CompletionRequest) and a [CompletionResolveRequest]
|
1102 | * (#CompletionResolveRequest)
|
1103 | */
|
1104 | data?: any
|
1105 | }
|
1106 |
|
1107 | /**
|
1108 | * Represents a collection of [completion items](#CompletionItem) to be presented
|
1109 | * in the editor.
|
1110 | */
|
1111 | export interface CompletionList {
|
1112 | /**
|
1113 | * This list it not complete. Further typing results in recomputing this list.
|
1114 | */
|
1115 | isIncomplete: boolean
|
1116 | /**
|
1117 | * The completion items.
|
1118 | */
|
1119 | items: CompletionItem[]
|
1120 | }
|
1121 |
|
1122 | /**
|
1123 | * How a completion was triggered
|
1124 | */
|
1125 | export namespace CompletionTriggerKind {
|
1126 | /**
|
1127 | * Completion was triggered by typing an identifier (24x7 code
|
1128 | * complete), manual invocation (e.g Ctrl+Space) or via API.
|
1129 | */
|
1130 | const Invoked: 1
|
1131 | /**
|
1132 | * Completion was triggered by a trigger character specified by
|
1133 | * the `triggerCharacters` properties of the `CompletionRegistrationOptions`.
|
1134 | */
|
1135 | const TriggerCharacter: 2
|
1136 | /**
|
1137 | * Completion was re-triggered as current completion list is incomplete
|
1138 | */
|
1139 | const TriggerForIncompleteCompletions: 3
|
1140 | }
|
1141 |
|
1142 | export type CompletionTriggerKind = 1 | 2 | 3
|
1143 |
|
1144 | /**
|
1145 | * Contains additional information about the context in which a completion request is triggered.
|
1146 | */
|
1147 | export interface CompletionContext {
|
1148 | /**
|
1149 | * How the completion was triggered.
|
1150 | */
|
1151 | triggerKind: CompletionTriggerKind,
|
1152 | /**
|
1153 | * The trigger character (a single character) that has trigger code complete.
|
1154 | * Is undefined if `triggerKind !== CompletionTriggerKind.TriggerCharacter`
|
1155 | */
|
1156 | triggerCharacter?: string
|
1157 |
|
1158 | option?: CompleteOption
|
1159 | }
|
1160 |
|
1161 | /**
|
1162 | * Represents a reference to a command. Provides a title which
|
1163 | * will be used to represent a command in the UI and, optionally,
|
1164 | * an array of arguments which will be passed to the command handler
|
1165 | * function when invoked.
|
1166 | */
|
1167 | export interface Command {
|
1168 | /**
|
1169 | * Title of the command, like `save`.
|
1170 | */
|
1171 | title: string
|
1172 | /**
|
1173 | * The identifier of the actual command handler.
|
1174 | */
|
1175 | command: string
|
1176 | /**
|
1177 | * Arguments that the command handler should be
|
1178 | * invoked with.
|
1179 | */
|
1180 | arguments?: any[]
|
1181 | }
|
1182 |
|
1183 | export interface TextDocumentEdit {
|
1184 | /**
|
1185 | * The text document to change.
|
1186 | */
|
1187 | textDocument: {
|
1188 | uri: string
|
1189 | version: number | null
|
1190 | }
|
1191 | /**
|
1192 | * The edits to be applied.
|
1193 | */
|
1194 | edits: TextEdit[]
|
1195 | }
|
1196 |
|
1197 | /**
|
1198 | * A workspace edit represents changes to many resources managed in the workspace. The edit
|
1199 | * should either provide `changes` or `documentChanges`. If documentChanges are present
|
1200 | * they are preferred over `changes` if the client can handle versioned document edits.
|
1201 | */
|
1202 | export interface WorkspaceEdit {
|
1203 | /**
|
1204 | * Holds changes to existing resources.
|
1205 | */
|
1206 | changes?: {
|
1207 | [uri: string]: TextEdit[]
|
1208 | }
|
1209 | /**
|
1210 | * Depending on the client capability `workspace.workspaceEdit.resourceOperations` document changes
|
1211 | * are either an array of `TextDocumentEdit`s to express changes to n different text documents
|
1212 | * where each text document edit addresses a specific version of a text document. Or it can contain
|
1213 | * above `TextDocumentEdit`s mixed with create, rename and delete file / folder operations.
|
1214 | *
|
1215 | * Whether a client supports versioned document edits is expressed via
|
1216 | * `workspace.workspaceEdit.documentChanges` client capability.
|
1217 | *
|
1218 | * If a client neither supports `documentChanges` nor `workspace.workspaceEdit.resourceOperations` then
|
1219 | * only plain `TextEdit`s using the `changes` property are supported.
|
1220 | */
|
1221 | documentChanges?: (TextDocumentEdit | CreateFile | RenameFile | DeleteFile)[]
|
1222 | }
|
1223 |
|
1224 | interface ResourceOperation {
|
1225 | kind: string
|
1226 | }
|
1227 |
|
1228 | /**
|
1229 | * Delete file options
|
1230 | */
|
1231 | export interface DeleteFileOptions {
|
1232 | /**
|
1233 | * Delete the content recursively if a folder is denoted.
|
1234 | */
|
1235 | recursive?: boolean
|
1236 | /**
|
1237 | * Ignore the operation if the file doesn't exist.
|
1238 | */
|
1239 | ignoreIfNotExists?: boolean
|
1240 | }
|
1241 | /**
|
1242 | * Delete file operation
|
1243 | */
|
1244 | export interface DeleteFile extends ResourceOperation {
|
1245 | /**
|
1246 | * A delete
|
1247 | */
|
1248 | kind: 'delete'
|
1249 | /**
|
1250 | * The file to delete.
|
1251 | */
|
1252 | uri: string
|
1253 | /**
|
1254 | * Delete options.
|
1255 | */
|
1256 | options?: DeleteFileOptions
|
1257 | }
|
1258 |
|
1259 | /**
|
1260 | * Options to create a file.
|
1261 | */
|
1262 | export interface CreateFileOptions {
|
1263 | /**
|
1264 | * Overwrite existing file. Overwrite wins over `ignoreIfExists`
|
1265 | */
|
1266 | overwrite?: boolean
|
1267 | /**
|
1268 | * Ignore if exists.
|
1269 | */
|
1270 | ignoreIfExists?: boolean
|
1271 | }
|
1272 | /**
|
1273 | * Create file operation.
|
1274 | */
|
1275 | export interface CreateFile extends ResourceOperation {
|
1276 | /**
|
1277 | * A create
|
1278 | */
|
1279 | kind: 'create'
|
1280 | /**
|
1281 | * The resource to create.
|
1282 | */
|
1283 | uri: string
|
1284 | /**
|
1285 | * Additional options
|
1286 | */
|
1287 | options?: CreateFileOptions
|
1288 | }
|
1289 |
|
1290 | /**
|
1291 | * Rename file options
|
1292 | */
|
1293 | export interface RenameFileOptions {
|
1294 | /**
|
1295 | * Overwrite target if existing. Overwrite wins over `ignoreIfExists`
|
1296 | */
|
1297 | overwrite?: boolean
|
1298 | /**
|
1299 | * Ignores if target exists.
|
1300 | */
|
1301 | ignoreIfExists?: boolean
|
1302 | }
|
1303 | /**
|
1304 | * Rename file operation
|
1305 | */
|
1306 | export interface RenameFile extends ResourceOperation {
|
1307 | /**
|
1308 | * A rename
|
1309 | */
|
1310 | kind: 'rename'
|
1311 | /**
|
1312 | * The old (existing) location.
|
1313 | */
|
1314 | oldUri: string
|
1315 | /**
|
1316 | * The new location.
|
1317 | */
|
1318 | newUri: string
|
1319 | /**
|
1320 | * Rename options.
|
1321 | */
|
1322 | options?: RenameFileOptions
|
1323 | }
|
1324 | /**
|
1325 | * Represents a related message and source code location for a diagnostic. This should be
|
1326 | * used to point to code locations that cause or related to a diagnostics, e.g when duplicating
|
1327 | * a symbol in a scope.
|
1328 | */
|
1329 | export interface DiagnosticRelatedInformation {
|
1330 | /**
|
1331 | * The location of this related diagnostic information.
|
1332 | */
|
1333 | location: Location
|
1334 | /**
|
1335 | * The message of this related diagnostic information.
|
1336 | */
|
1337 | message: string
|
1338 | }
|
1339 |
|
1340 | /**
|
1341 | * The diagnostic's severity.
|
1342 | */
|
1343 | export namespace DiagnosticSeverity {
|
1344 | /**
|
1345 | * Reports an error.
|
1346 | */
|
1347 | const Error: 1
|
1348 | /**
|
1349 | * Reports a warning.
|
1350 | */
|
1351 | const Warning: 2
|
1352 | /**
|
1353 | * Reports an information.
|
1354 | */
|
1355 | const Information: 3
|
1356 | /**
|
1357 | * Reports a hint.
|
1358 | */
|
1359 | const Hint: 4
|
1360 | }
|
1361 |
|
1362 | export type DiagnosticSeverity = 1 | 2 | 3 | 4
|
1363 |
|
1364 | /**
|
1365 | * The diagnostic tags.
|
1366 | *
|
1367 | * @since 3.15.0
|
1368 | */
|
1369 | export namespace DiagnosticTag {
|
1370 | /**
|
1371 | * Unused or unnecessary code.
|
1372 | *
|
1373 | * Clients are allowed to render diagnostics with this tag faded out instead of having
|
1374 | * an error squiggle.
|
1375 | */
|
1376 | const Unnecessary: 1
|
1377 | /**
|
1378 | * Deprecated or obsolete code.
|
1379 | *
|
1380 | * Clients are allowed to rendered diagnostics with this tag strike through.
|
1381 | */
|
1382 | const Deprecated: 2
|
1383 | }
|
1384 |
|
1385 | export type DiagnosticTag = 1 | 2
|
1386 |
|
1387 | /**
|
1388 | * Represents a diagnostic, such as a compiler error or warning. Diagnostic objects
|
1389 | * are only valid in the scope of a resource.
|
1390 | */
|
1391 | export interface Diagnostic {
|
1392 | /**
|
1393 | * The range at which the message applies
|
1394 | */
|
1395 | range: Range
|
1396 | /**
|
1397 | * The diagnostic's severity. Can be omitted. If omitted it is up to the
|
1398 | * client to interpret diagnostics as error, warning, info or hint.
|
1399 | */
|
1400 | severity?: DiagnosticSeverity
|
1401 | /**
|
1402 | * The diagnostic's code, which usually appear in the user interface.
|
1403 | */
|
1404 | code?: number | string
|
1405 | /**
|
1406 | * A human-readable string describing the source of this
|
1407 | * diagnostic, e.g. 'typescript' or 'super lint'. It usually
|
1408 | * appears in the user interface.
|
1409 | */
|
1410 | source?: string
|
1411 | /**
|
1412 | * The diagnostic's message. It usually appears in the user interface
|
1413 | */
|
1414 | message: string
|
1415 | /**
|
1416 | * Additional metadata about the diagnostic.
|
1417 | */
|
1418 | tags?: DiagnosticTag[]
|
1419 | /**
|
1420 | * An array of related diagnostic information, e.g. when symbol-names within
|
1421 | * a scope collide all definitions can be marked via this property.
|
1422 | */
|
1423 | relatedInformation?: DiagnosticRelatedInformation[]
|
1424 | }
|
1425 |
|
1426 | /**
|
1427 | * The Diagnostic namespace provides helper functions to work with
|
1428 | * [Diagnostic](#Diagnostic) literals.
|
1429 | */
|
1430 | export namespace Diagnostic {
|
1431 | /**
|
1432 | * Creates a new Diagnostic literal.
|
1433 | */
|
1434 | function create(range: Range, message: string, severity?: DiagnosticSeverity, code?: number | string, source?: string, relatedInformation?: DiagnosticRelatedInformation[]): Diagnostic
|
1435 | /**
|
1436 | * Checks whether the given literal conforms to the [Diagnostic](#Diagnostic) interface.
|
1437 | */
|
1438 | function is(value: any): value is Diagnostic
|
1439 | }
|
1440 |
|
1441 | /**
|
1442 | * A code action represents a change that can be performed in code, e.g. to fix a problem or
|
1443 | * to refactor code.
|
1444 | *
|
1445 | * A CodeAction must set either `edit` and/or a `command`. If both are supplied, the `edit` is applied first, then the `command` is executed.
|
1446 | */
|
1447 | export interface CodeAction {
|
1448 | /**
|
1449 | * A short, human-readable, title for this code action.
|
1450 | */
|
1451 | title: string
|
1452 | /**
|
1453 | * The kind of the code action.
|
1454 | *
|
1455 | * Used to filter code actions.
|
1456 | */
|
1457 | kind?: CodeActionKind
|
1458 | /**
|
1459 | * The diagnostics that this code action resolves.
|
1460 | */
|
1461 | diagnostics?: Diagnostic[]
|
1462 | /**
|
1463 | * Marks this as a preferred action. Preferred actions are used by the `auto fix` command and can be targeted
|
1464 | * by keybindings.
|
1465 | *
|
1466 | * A quick fix should be marked preferred if it properly addresses the underlying error.
|
1467 | * A refactoring should be marked preferred if it is the most reasonable choice of actions to take.
|
1468 | *
|
1469 | * @since 3.15.0
|
1470 | */
|
1471 | isPreferred?: boolean
|
1472 | /**
|
1473 | * The workspace edit this code action performs.
|
1474 | */
|
1475 | edit?: WorkspaceEdit
|
1476 | /**
|
1477 | * A command this code action executes. If a code action
|
1478 | * provides a edit and a command, first the edit is
|
1479 | * executed and then the command.
|
1480 | */
|
1481 | command?: Command
|
1482 | /**
|
1483 | * Id of client that provide codeAction.
|
1484 | */
|
1485 | clientId?: string
|
1486 | }
|
1487 |
|
1488 | /**
|
1489 | * The kind of a code action.
|
1490 | *
|
1491 | * Kinds are a hierarchical list of identifiers separated by `.`, e.g. `"refactor.extract.function"`.
|
1492 | *
|
1493 | * The set of kinds is open and client needs to announce the kinds it supports to the server during
|
1494 | * initialization.
|
1495 | */
|
1496 | export type CodeActionKind = string
|
1497 | /**
|
1498 | * A set of predefined code action kinds
|
1499 | */
|
1500 | export namespace CodeActionKind {
|
1501 | /**
|
1502 | * Empty kind.
|
1503 | */
|
1504 | const Empty: CodeActionKind
|
1505 | /**
|
1506 | * Base kind for quickfix actions: 'quickfix'
|
1507 | */
|
1508 | const QuickFix: CodeActionKind
|
1509 | /**
|
1510 | * Base kind for refactoring actions: 'refactor'
|
1511 | */
|
1512 | const Refactor: CodeActionKind
|
1513 | /**
|
1514 | * Base kind for refactoring extraction actions: 'refactor.extract'
|
1515 | *
|
1516 | * Example extract actions:
|
1517 | *
|
1518 | * - Extract method
|
1519 | * - Extract function
|
1520 | * - Extract variable
|
1521 | * - Extract interface from class
|
1522 | * - ...
|
1523 | */
|
1524 | const RefactorExtract: CodeActionKind
|
1525 | /**
|
1526 | * Base kind for refactoring inline actions: 'refactor.inline'
|
1527 | *
|
1528 | * Example inline actions:
|
1529 | *
|
1530 | * - Inline function
|
1531 | * - Inline variable
|
1532 | * - Inline constant
|
1533 | * - ...
|
1534 | */
|
1535 | const RefactorInline: CodeActionKind
|
1536 | /**
|
1537 | * Base kind for refactoring rewrite actions: 'refactor.rewrite'
|
1538 | *
|
1539 | * Example rewrite actions:
|
1540 | *
|
1541 | * - Convert JavaScript function to class
|
1542 | * - Add or remove parameter
|
1543 | * - Encapsulate field
|
1544 | * - Make method static
|
1545 | * - Move method to base class
|
1546 | * - ...
|
1547 | */
|
1548 | const RefactorRewrite: CodeActionKind
|
1549 | /**
|
1550 | * Base kind for source actions: `source`
|
1551 | *
|
1552 | * Source code actions apply to the entire file.
|
1553 | */
|
1554 | const Source: CodeActionKind
|
1555 | /**
|
1556 | * Base kind for an organize imports source action: `source.organizeImports`
|
1557 | */
|
1558 | const SourceOrganizeImports: CodeActionKind
|
1559 | /**
|
1560 | * Base kind for auto-fix source actions: `source.fixAll`.
|
1561 | *
|
1562 | * Fix all actions automatically fix errors that have a clear fix that do not require user input.
|
1563 | * They should not suppress errors or perform unsafe fixes such as generating new types or classes.
|
1564 | *
|
1565 | * @since 3.15.0
|
1566 | */
|
1567 | const SourceFixAll: CodeActionKind
|
1568 | }
|
1569 |
|
1570 | /**
|
1571 | * Position in a text document expressed as zero-based line and character offset.
|
1572 | * The offsets are based on a UTF-16 string representation. So a string of the form
|
1573 | * `a𐐀b` the character offset of the character `a` is 0, the character offset of `𐐀`
|
1574 | * is 1 and the character offset of b is 3 since `𐐀` is represented using two code
|
1575 | * units in UTF-16.
|
1576 | *
|
1577 | * Positions are line end character agnostic. So you can not specify a position that
|
1578 | * denotes `\r|\n` or `\n|` where `|` represents the character offset.
|
1579 | */
|
1580 | export interface Position {
|
1581 | /**
|
1582 | * Line position in a document (zero-based).
|
1583 | * If a line number is greater than the number of lines in a document, it defaults back to the number of lines in the document.
|
1584 | * If a line number is negative, it defaults to 0.
|
1585 | */
|
1586 | line: number
|
1587 | /**
|
1588 | * Character offset on a line in a document (zero-based). Assuming that the line is
|
1589 | * represented as a string, the `character` value represents the gap between the
|
1590 | * `character` and `character + 1`.
|
1591 | *
|
1592 | * If the character value is greater than the line length it defaults back to the
|
1593 | * line length.
|
1594 | * If a line number is negative, it defaults to 0.
|
1595 | */
|
1596 | character: number
|
1597 | }
|
1598 |
|
1599 | /**
|
1600 | * The Position namespace provides helper functions to work with
|
1601 | * [Position](#Position) literals.
|
1602 | */
|
1603 | export namespace Position {
|
1604 | /**
|
1605 | * Creates a new Position literal from the given line and character.
|
1606 | * @param line The position's line.
|
1607 | * @param character The position's character.
|
1608 | */
|
1609 | function create(line: number, character: number): Position
|
1610 | /**
|
1611 | * Checks whether the given liternal conforms to the [Position](#Position) interface.
|
1612 | */
|
1613 | function is(value: any): value is Position
|
1614 | }
|
1615 |
|
1616 | /**
|
1617 | * Represents a typed event.
|
1618 | *
|
1619 | * A function that represents an event to which you subscribe by calling it with
|
1620 | * a listener function as argument.
|
1621 | *
|
1622 | * @example
|
1623 | * item.onDidChange(function(event) { console.log("Event happened: " + event); });
|
1624 | */
|
1625 | export interface Event<T> {
|
1626 |
|
1627 | /**
|
1628 | * A function that represents an event to which you subscribe by calling it with
|
1629 | * a listener function as argument.
|
1630 | *
|
1631 | * @param listener The listener function will be called when the event happens.
|
1632 | * @param thisArgs The `this`-argument which will be used when calling the event listener.
|
1633 | * @param disposables An array to which a [disposable](#Disposable) will be added.
|
1634 | * @return A disposable which unsubscribes the event listener.
|
1635 | */
|
1636 | (listener: (e: T) => any, thisArgs?: any, disposables?: Disposable[]): Disposable
|
1637 | }
|
1638 |
|
1639 | export namespace Event {
|
1640 | const None: Event<any>
|
1641 | }
|
1642 |
|
1643 | export interface EmitterOptions {
|
1644 | onFirstListenerAdd?: Function
|
1645 | onLastListenerRemove?: Function
|
1646 | }
|
1647 |
|
1648 | export class Emitter<T> {
|
1649 | constructor(_options?: EmitterOptions | undefined)
|
1650 | /**
|
1651 | * For the public to allow to subscribe
|
1652 | * to events from this Emitter
|
1653 | */
|
1654 | get event(): Event<T>
|
1655 | /**
|
1656 | * To be kept private to fire an event to
|
1657 | * subscribers
|
1658 | */
|
1659 | fire(event: T): any
|
1660 | dispose(): void
|
1661 | }
|
1662 |
|
1663 | /**
|
1664 | * Represents a location inside a resource, such as a line
|
1665 | * inside a text file.
|
1666 | */
|
1667 | export interface Location {
|
1668 | uri: string
|
1669 | range: Range
|
1670 | }
|
1671 |
|
1672 | /**
|
1673 | * The Location namespace provides helper functions to work with
|
1674 | * [Location](#Location) literals.
|
1675 | */
|
1676 | export namespace Location {
|
1677 | /**
|
1678 | * Creates a Location literal.
|
1679 | * @param uri The location's uri.
|
1680 | * @param range The location's range.
|
1681 | */
|
1682 | function create(uri: string, range: Range): Location
|
1683 | /**
|
1684 | * Checks whether the given literal conforms to the [Location](#Location) interface.
|
1685 | */
|
1686 | function is(value: any): value is Location
|
1687 | }
|
1688 |
|
1689 | /**
|
1690 | * A range in a text document expressed as (zero-based) start and end positions.
|
1691 | *
|
1692 | * If you want to specify a range that contains a line including the line ending
|
1693 | * character(s) then use an end position denoting the start of the next line.
|
1694 | * For example:
|
1695 | * ```ts
|
1696 | * {
|
1697 | * start: { line: 5, character: 23 }
|
1698 | * end : { line 6, character : 0 }
|
1699 | * }
|
1700 | * ```
|
1701 | */
|
1702 | export interface Range {
|
1703 | /**
|
1704 | * The range's start position
|
1705 | */
|
1706 | start: Position
|
1707 | /**
|
1708 | * The range's end position.
|
1709 | */
|
1710 | end: Position
|
1711 | }
|
1712 |
|
1713 | /**
|
1714 | * The Range namespace provides helper functions to work with
|
1715 | * [Range](#Range) literals.
|
1716 | */
|
1717 | export namespace Range {
|
1718 | /**
|
1719 | * Create a new Range liternal.
|
1720 | * @param start The range's start position.
|
1721 | * @param end The range's end position.
|
1722 | */
|
1723 | function create(start: Position, end: Position): Range
|
1724 | /**
|
1725 | * Create a new Range liternal.
|
1726 | * @param startLine The start line number.
|
1727 | * @param startCharacter The start character.
|
1728 | * @param endLine The end line number.
|
1729 | * @param endCharacter The end character.
|
1730 | */
|
1731 | function create(startLine: number, startCharacter: number, endLine: number, endCharacter: number): Range
|
1732 | /**
|
1733 | * Checks whether the given literal conforms to the [Range](#Range) interface.
|
1734 | */
|
1735 | function is(value: any): value is Range
|
1736 | }
|
1737 |
|
1738 | /**
|
1739 | * A text edit applicable to a text document.
|
1740 | */
|
1741 | export interface TextEdit {
|
1742 | /**
|
1743 | * The range of the text document to be manipulated. To insert
|
1744 | * text into a document create a range where start === end.
|
1745 | */
|
1746 | range: Range
|
1747 | /**
|
1748 | * The string to be inserted. For delete operations use an
|
1749 | * empty string.
|
1750 | */
|
1751 | newText: string
|
1752 | }
|
1753 |
|
1754 | /**
|
1755 | * The TextEdit namespace provides helper function to create replace,
|
1756 | * insert and delete edits more easily.
|
1757 | */
|
1758 | export namespace TextEdit {
|
1759 | /**
|
1760 | * Creates a replace text edit.
|
1761 | * @param range The range of text to be replaced.
|
1762 | * @param newText The new text.
|
1763 | */
|
1764 | function replace(range: Range, newText: string): TextEdit
|
1765 | /**
|
1766 | * Creates a insert text edit.
|
1767 | * @param position The position to insert the text at.
|
1768 | * @param newText The text to be inserted.
|
1769 | */
|
1770 | function insert(position: Position, newText: string): TextEdit
|
1771 | /**
|
1772 | * Creates a delete text edit.
|
1773 | * @param range The range of text to be deleted.
|
1774 | */
|
1775 | function del(range: Range): TextEdit
|
1776 | function is(value: any): value is TextEdit
|
1777 | }
|
1778 |
|
1779 | /**
|
1780 | * Defines a CancellationToken. This interface is not
|
1781 | * intended to be implemented. A CancellationToken must
|
1782 | * be created via a CancellationTokenSource.
|
1783 | */
|
1784 | export interface CancellationToken {
|
1785 | /**
|
1786 | * Is `true` when the token has been cancelled, `false` otherwise.
|
1787 | */
|
1788 | readonly isCancellationRequested: boolean
|
1789 | /**
|
1790 | * An [event](#Event) which fires upon cancellation.
|
1791 | */
|
1792 | readonly onCancellationRequested: Event<any>
|
1793 | }
|
1794 |
|
1795 | export namespace CancellationToken {
|
1796 | const None: CancellationToken
|
1797 | const Cancelled: CancellationToken
|
1798 | function is(value: any): value is CancellationToken
|
1799 | }
|
1800 |
|
1801 | export class CancellationTokenSource {
|
1802 | get token(): CancellationToken
|
1803 | cancel(): void
|
1804 | dispose(): void
|
1805 | }
|
1806 |
|
1807 | /**
|
1808 | * Represents a line of text, such as a line of source code.
|
1809 | *
|
1810 | * TextLine objects are __immutable__. When a {@link LinesTextDocument document} changes,
|
1811 | * previously retrieved lines will not represent the latest state.
|
1812 | */
|
1813 | export interface TextLine {
|
1814 | /**
|
1815 | * The zero-based line number.
|
1816 | */
|
1817 | readonly lineNumber: number
|
1818 |
|
1819 | /**
|
1820 | * The text of this line without the line separator characters.
|
1821 | */
|
1822 | readonly text: string
|
1823 |
|
1824 | /**
|
1825 | * The range this line covers without the line separator characters.
|
1826 | */
|
1827 | readonly range: Range
|
1828 |
|
1829 | /**
|
1830 | * The range this line covers with the line separator characters.
|
1831 | */
|
1832 | readonly rangeIncludingLineBreak: Range
|
1833 |
|
1834 | /**
|
1835 | * The offset of the first character which is not a whitespace character as defined
|
1836 | * by `/\s/`. **Note** that if a line is all whitespace the length of the line is returned.
|
1837 | */
|
1838 | readonly firstNonWhitespaceCharacterIndex: number
|
1839 |
|
1840 | /**
|
1841 | * Whether this line is whitespace only, shorthand
|
1842 | * for {@link TextLine.firstNonWhitespaceCharacterIndex} === {@link TextLine.text TextLine.text.length}.
|
1843 | */
|
1844 | readonly isEmptyOrWhitespace: boolean
|
1845 | }
|
1846 |
|
1847 | /**
|
1848 | * A simple text document. Not to be implemented. The document keeps the content
|
1849 | * as string.
|
1850 | */
|
1851 | export interface TextDocument {
|
1852 | /**
|
1853 | * The associated URI for this document. Most documents have the __file__-scheme, indicating that they
|
1854 | * represent files on disk. However, some documents may have other schemes indicating that they are not
|
1855 | * available on disk.
|
1856 | *
|
1857 | * @readonly
|
1858 | */
|
1859 | readonly uri: string
|
1860 | /**
|
1861 | * The identifier of the language associated with this document.
|
1862 | *
|
1863 | * @readonly
|
1864 | */
|
1865 | readonly languageId: string
|
1866 | /**
|
1867 | * The version number of this document (it will increase after each
|
1868 | * change, including undo/redo).
|
1869 | *
|
1870 | * @readonly
|
1871 | */
|
1872 | readonly version: number
|
1873 | /**
|
1874 | * Get the text of this document. A substring can be retrieved by
|
1875 | * providing a range.
|
1876 | *
|
1877 | * @param range (optional) An range within the document to return.
|
1878 | * If no range is passed, the full content is returned.
|
1879 | * Invalid range positions are adjusted as described in [Position.line](#Position.line)
|
1880 | * and [Position.character](#Position.character).
|
1881 | * If the start range position is greater than the end range position,
|
1882 | * then the effect of getText is as if the two positions were swapped.
|
1883 |
|
1884 | * @return The text of this document or a substring of the text if a
|
1885 | * range is provided.
|
1886 | */
|
1887 | getText(range?: Range): string
|
1888 | /**
|
1889 | * Converts a zero-based offset to a position.
|
1890 | *
|
1891 | * @param offset A zero-based offset.
|
1892 | * @return A valid [position](#Position).
|
1893 | */
|
1894 | positionAt(offset: number): Position
|
1895 | /**
|
1896 | * Converts the position to a zero-based offset.
|
1897 | * Invalid positions are adjusted as described in [Position.line](#Position.line)
|
1898 | * and [Position.character](#Position.character).
|
1899 | *
|
1900 | * @param position A position.
|
1901 | * @return A valid zero-based offset.
|
1902 | */
|
1903 | offsetAt(position: Position): number
|
1904 | /**
|
1905 | * The number of lines in this document.
|
1906 | *
|
1907 | * @readonly
|
1908 | */
|
1909 | readonly lineCount: number
|
1910 | }
|
1911 |
|
1912 | export interface LinesTextDocument extends TextDocument {
|
1913 | /**
|
1914 | * Total length of TextDocument.
|
1915 | */
|
1916 | readonly length: number
|
1917 | /**
|
1918 | * End position of TextDocument.
|
1919 | */
|
1920 | readonly end: Position
|
1921 | /**
|
1922 | * 'eol' option of related buffer. When enabled additional `\n` will be
|
1923 | * added to the end of document content
|
1924 | */
|
1925 | readonly rol: boolean
|
1926 | /**
|
1927 | * Lines of TextDocument.
|
1928 | */
|
1929 | readonly lines: ReadonlyArray<string>
|
1930 | /**
|
1931 | * Returns a text line denoted by the line number. Note
|
1932 | * that the returned object is *not* live and changes to the
|
1933 | * document are not reflected.
|
1934 | *
|
1935 | * @param line or position
|
1936 | * @return A {@link TextLine line}.
|
1937 | */
|
1938 | lineAt(lineOrPos: number | Position): TextLine
|
1939 | }
|
1940 |
|
1941 | /**
|
1942 | * @since 3.16.0
|
1943 | */
|
1944 | export interface SemanticTokensLegend {
|
1945 | /**
|
1946 | * The token types a server uses.
|
1947 | */
|
1948 | tokenTypes: string[]
|
1949 | /**
|
1950 | * The token modifiers a server uses.
|
1951 | */
|
1952 | tokenModifiers: string[]
|
1953 | }
|
1954 |
|
1955 | /**
|
1956 | * @since 3.16.0
|
1957 | */
|
1958 | export interface SemanticTokens {
|
1959 | /**
|
1960 | * An optional result id. If provided and clients support delta updating
|
1961 | * the client will include the result id in the next semantic token request.
|
1962 | * A server can then instead of computing all semantic tokens again simply
|
1963 | * send a delta.
|
1964 | */
|
1965 | resultId?: string
|
1966 | /**
|
1967 | * The actual tokens.
|
1968 | */
|
1969 | data: number[]
|
1970 | }
|
1971 |
|
1972 | /**
|
1973 | * @since 3.16.0
|
1974 | */
|
1975 | export interface SemanticTokensEdit {
|
1976 | /**
|
1977 | * The start offset of the edit.
|
1978 | */
|
1979 | start: number
|
1980 | /**
|
1981 | * The count of elements to remove.
|
1982 | */
|
1983 | deleteCount: number
|
1984 | /**
|
1985 | * The elements to insert.
|
1986 | */
|
1987 | data?: number[]
|
1988 | }
|
1989 |
|
1990 | /**
|
1991 | * @since 3.16.0
|
1992 | */
|
1993 | export interface SemanticTokensDelta {
|
1994 | readonly resultId?: string
|
1995 | /**
|
1996 | * The semantic token edits to transform a previous result into a new result.
|
1997 | */
|
1998 | edits: SemanticTokensEdit[]
|
1999 | }
|
2000 |
|
2001 | /**
|
2002 | * The result of a linked editing range request.
|
2003 | *
|
2004 | * @since 3.16.0
|
2005 | */
|
2006 | export interface LinkedEditingRanges {
|
2007 | /**
|
2008 | * A list of ranges that can be edited together. The ranges must have
|
2009 | * identical length and contain identical text content. The ranges cannot overlap.
|
2010 | */
|
2011 | ranges: Range[]
|
2012 | /**
|
2013 | * An optional word pattern (regular expression) that describes valid contents for
|
2014 | * the given ranges. If no pattern is provided, the client configuration's word
|
2015 | * pattern will be used.
|
2016 | */
|
2017 | wordPattern?: string
|
2018 | }
|
2019 |
|
2020 | /**
|
2021 | * Represents programming constructs like functions or constructors in the context
|
2022 | * of call hierarchy.
|
2023 | *
|
2024 | * @since 3.16.0
|
2025 | */
|
2026 | export interface CallHierarchyItem {
|
2027 | /**
|
2028 | * The name of this item.
|
2029 | */
|
2030 | name: string
|
2031 | /**
|
2032 | * The kind of this item.
|
2033 | */
|
2034 | kind: SymbolKind
|
2035 | /**
|
2036 | * Tags for this item.
|
2037 | */
|
2038 | tags?: number[]
|
2039 | /**
|
2040 | * More detail for this item, e.g. the signature of a function.
|
2041 | */
|
2042 | detail?: string
|
2043 | /**
|
2044 | * The resource identifier of this item.
|
2045 | */
|
2046 | uri: string
|
2047 | /**
|
2048 | * The range enclosing this symbol not including leading/trailing whitespace but everything else, e.g. comments and code.
|
2049 | */
|
2050 | range: Range
|
2051 | /**
|
2052 | * The range that should be selected and revealed when this symbol is being picked, e.g. the name of a function.
|
2053 | * Must be contained by the [`range`](#CallHierarchyItem.range).
|
2054 | */
|
2055 | selectionRange: Range
|
2056 | /**
|
2057 | * A data entry field that is preserved between a call hierarchy prepare and
|
2058 | * incoming calls or outgoing calls requests.
|
2059 | */
|
2060 | data?: unknown
|
2061 | }
|
2062 |
|
2063 | /**
|
2064 | * Represents an incoming call, e.g. a caller of a method or constructor.
|
2065 | *
|
2066 | * @since 3.16.0
|
2067 | */
|
2068 | export interface CallHierarchyIncomingCall {
|
2069 | /**
|
2070 | * The item that makes the call.
|
2071 | */
|
2072 | from: CallHierarchyItem
|
2073 | /**
|
2074 | * The ranges at which the calls appear. This is relative to the caller
|
2075 | * denoted by [`this.from`](#CallHierarchyIncomingCall.from).
|
2076 | */
|
2077 | fromRanges: Range[]
|
2078 | }
|
2079 | /**
|
2080 | * Represents an outgoing call, e.g. calling a getter from a method or a method from a constructor etc.
|
2081 | *
|
2082 | * @since 3.16.0
|
2083 | */
|
2084 | export interface CallHierarchyOutgoingCall {
|
2085 | /**
|
2086 | * The item that is called.
|
2087 | */
|
2088 | to: CallHierarchyItem
|
2089 | /**
|
2090 | * The range at which this item is called. This is the range relative to the caller, e.g the item
|
2091 | * passed to [`provideCallHierarchyOutgoingCalls`](#CallHierarchyItemProvider.provideCallHierarchyOutgoingCalls)
|
2092 | * and not [`this.to`](#CallHierarchyOutgoingCall.to).
|
2093 | */
|
2094 | fromRanges: Range[]
|
2095 | }
|
2096 |
|
2097 | /**
|
2098 | * Moniker uniqueness level to define scope of the moniker.
|
2099 | *
|
2100 | * @since 3.16.0
|
2101 | */
|
2102 | export namespace UniquenessLevel {
|
2103 | /**
|
2104 | * The moniker is only unique inside a document
|
2105 | */
|
2106 | export const document = 'document'
|
2107 |
|
2108 | /**
|
2109 | * The moniker is unique inside a project for which a dump got created
|
2110 | */
|
2111 | export const project = 'project'
|
2112 |
|
2113 | /**
|
2114 | * The moniker is unique inside the group to which a project belongs
|
2115 | */
|
2116 | export const group = 'group'
|
2117 |
|
2118 | /**
|
2119 | * The moniker is unique inside the moniker scheme.
|
2120 | */
|
2121 | export const scheme = 'scheme'
|
2122 |
|
2123 | /**
|
2124 | * The moniker is globally unique
|
2125 | */
|
2126 | export const global = 'global'
|
2127 | }
|
2128 |
|
2129 | export type UniquenessLevel = 'document' | 'project' | 'group' | 'scheme' | 'global'
|
2130 |
|
2131 | /**
|
2132 | * The moniker kind.
|
2133 | *
|
2134 | * @since 3.16.0
|
2135 | */
|
2136 | export enum MonikerKind {
|
2137 | /**
|
2138 | * The moniker represent a symbol that is imported into a project
|
2139 | */
|
2140 | import = 'import',
|
2141 |
|
2142 | /**
|
2143 | * The moniker represents a symbol that is exported from a project
|
2144 | */
|
2145 | export = 'export',
|
2146 |
|
2147 | /**
|
2148 | * The moniker represents a symbol that is local to a project (e.g. a local
|
2149 | * variable of a function, a class not visible outside the project, ...)
|
2150 | */
|
2151 | local = 'local'
|
2152 | }
|
2153 |
|
2154 | /**
|
2155 | * Moniker definition to match LSIF 0.5 moniker definition.
|
2156 | *
|
2157 | * @since 3.16.0
|
2158 | */
|
2159 | export interface Moniker {
|
2160 | /**
|
2161 | * The scheme of the moniker. For example tsc or .Net
|
2162 | */
|
2163 | scheme: string
|
2164 |
|
2165 | /**
|
2166 | * The identifier of the moniker. The value is opaque in LSIF however
|
2167 | * schema owners are allowed to define the structure if they want.
|
2168 | */
|
2169 | identifier: string
|
2170 |
|
2171 | /**
|
2172 | * The scope in which the moniker is unique
|
2173 | */
|
2174 | unique: UniquenessLevel
|
2175 |
|
2176 | /**
|
2177 | * The moniker kind if known.
|
2178 | */
|
2179 | kind?: MonikerKind
|
2180 | }
|
2181 |
|
2182 | export type InlayHintKind = 1 | 2
|
2183 |
|
2184 | /**
|
2185 | * An inlay hint label part allows for interactive and composite labels
|
2186 | * of inlay hints.
|
2187 | *
|
2188 | * @since 3.17.0
|
2189 | * @proposed
|
2190 | */
|
2191 | export interface InlayHintLabelPart {
|
2192 |
|
2193 | /**
|
2194 | * The value of this label part.
|
2195 | */
|
2196 | value: string
|
2197 |
|
2198 | /**
|
2199 | * The tooltip text when you hover over this label part. Depending on
|
2200 | * the client capability `inlayHint.resolveSupport` clients might resolve
|
2201 | * this property late using the resolve request.
|
2202 | */
|
2203 | tooltip?: string | MarkupContent
|
2204 |
|
2205 | /**
|
2206 | * An optional source code location that represents this
|
2207 | * label part.
|
2208 | *
|
2209 | * The editor will use this location for the hover and for code navigation
|
2210 | * features: This part will become a clickable link that resolves to the
|
2211 | * definition of the symbol at the given location (not necessarily the
|
2212 | * location itself), it shows the hover that shows at the given location,
|
2213 | * and it shows a context menu with further code navigation commands.
|
2214 | *
|
2215 | * Depending on the client capability `inlayHint.resolveSupport` clients
|
2216 | * might resolve this property late using the resolve request.
|
2217 | */
|
2218 | location?: Location
|
2219 |
|
2220 | /**
|
2221 | * An optional command for this label part.
|
2222 | *
|
2223 | * Depending on the client capability `inlayHint.resolveSupport` clients
|
2224 | * might resolve this property late using the resolve request.
|
2225 | */
|
2226 | command?: Command
|
2227 | }
|
2228 |
|
2229 | /**
|
2230 | * Inlay hint information.
|
2231 | *
|
2232 | * @since 3.17.0
|
2233 | * @proposed
|
2234 | */
|
2235 | export interface InlayHint {
|
2236 |
|
2237 | /**
|
2238 | * The position of this hint.
|
2239 | */
|
2240 | position: Position
|
2241 |
|
2242 | /**
|
2243 | * The label of this hint. A human readable string or an array of
|
2244 | * InlayHintLabelPart label parts.
|
2245 | *
|
2246 | * *Note* that neither the string nor the label part can be empty.
|
2247 | */
|
2248 | label: string | InlayHintLabelPart[]
|
2249 |
|
2250 | /**
|
2251 | * The kind of this hint. Can be omitted in which case the client
|
2252 | * should fall back to a reasonable default.
|
2253 | */
|
2254 | kind?: InlayHintKind
|
2255 |
|
2256 | /**
|
2257 | * Optional text edits that are performed when accepting this inlay hint.
|
2258 | *
|
2259 | * *Note* that edits are expected to change the document so that the inlay
|
2260 | * hint (or its nearest variant) is now part of the document and the inlay
|
2261 | * hint itself is now obsolete.
|
2262 | */
|
2263 | textEdits?: TextEdit[]
|
2264 |
|
2265 | /**
|
2266 | * The tooltip text when you hover over this item.
|
2267 | */
|
2268 | tooltip?: string | MarkupContent
|
2269 |
|
2270 | /**
|
2271 | * Render padding before the hint.
|
2272 | *
|
2273 | * Note: Padding should use the editor's background color, not the
|
2274 | * background color of the hint itself. That means padding can be used
|
2275 | * to visually align/separate an inlay hint.
|
2276 | */
|
2277 | paddingLeft?: boolean
|
2278 |
|
2279 | /**
|
2280 | * Render padding after the hint.
|
2281 | *
|
2282 | * Note: Padding should use the editor's background color, not the
|
2283 | * background color of the hint itself. That means padding can be used
|
2284 | * to visually align/separate an inlay hint.
|
2285 | */
|
2286 | paddingRight?: boolean
|
2287 |
|
2288 | /**
|
2289 | * A data entry field that is preserved on a inlay hint between
|
2290 | * a `textDocument/inlayHint` and a `inlayHint/resolve` request.
|
2291 | */
|
2292 | data?: any
|
2293 | }
|
2294 |
|
2295 | /**
|
2296 | * A previous result id in a workspace pull request.
|
2297 | *
|
2298 | * @since 3.17.0
|
2299 | */
|
2300 | export type PreviousResultId = {
|
2301 | /**
|
2302 | * The URI for which the client knowns a
|
2303 | * result id.
|
2304 | */
|
2305 | uri: string
|
2306 | /**
|
2307 | * The value of the previous result id.
|
2308 | */
|
2309 | value: string
|
2310 | }
|
2311 |
|
2312 | export type DocumentDiagnosticReportKind = 'full' | 'unchanged'
|
2313 |
|
2314 | /**
|
2315 | * The document diagnostic report kinds.
|
2316 | *
|
2317 | * @since 3.17.0
|
2318 | */
|
2319 | export namespace DocumentDiagnosticReportKind {
|
2320 | /**
|
2321 | * A diagnostic report with a full
|
2322 | * set of problems.
|
2323 | */
|
2324 | const Full = "full"
|
2325 | /**
|
2326 | * A report indicating that the last
|
2327 | * returned report is still accurate.
|
2328 | */
|
2329 | const Unchanged = "unchanged"
|
2330 | }
|
2331 | /**
|
2332 | * A diagnostic report with a full set of problems.
|
2333 | *
|
2334 | * @since 3.17.0
|
2335 | */
|
2336 | export type FullDocumentDiagnosticReport = {
|
2337 | /**
|
2338 | * A full document diagnostic report.
|
2339 | */
|
2340 | kind: typeof DocumentDiagnosticReportKind.Full
|
2341 | /**
|
2342 | * An optional result id. If provided it will
|
2343 | * be sent on the next diagnostic request for the
|
2344 | * same document.
|
2345 | */
|
2346 | resultId?: string
|
2347 | /**
|
2348 | * The actual items.
|
2349 | */
|
2350 | items: Diagnostic[]
|
2351 | }
|
2352 |
|
2353 | /**
|
2354 | * A diagnostic report indicating that the last returned
|
2355 | * report is still accurate.
|
2356 | *
|
2357 | * @since 3.17.0
|
2358 | */
|
2359 | export type UnchangedDocumentDiagnosticReport = {
|
2360 | /**
|
2361 | * A document diagnostic report indicating
|
2362 | * no changes to the last result. A server can
|
2363 | * only return `unchanged` if result ids are
|
2364 | * provided.
|
2365 | */
|
2366 | kind: typeof DocumentDiagnosticReportKind.Unchanged
|
2367 | /**
|
2368 | * A result id which will be sent on the next
|
2369 | * diagnostic request for the same document.
|
2370 | */
|
2371 | resultId: string
|
2372 | }
|
2373 |
|
2374 | /**
|
2375 | * An unchanged diagnostic report with a set of related documents.
|
2376 | *
|
2377 | * @since 3.17.0
|
2378 | */
|
2379 | export type RelatedUnchangedDocumentDiagnosticReport = UnchangedDocumentDiagnosticReport & {
|
2380 | /**
|
2381 | * Diagnostics of related documents. This information is useful
|
2382 | * in programming languages where code in a file A can generate
|
2383 | * diagnostics in a file B which A depends on. An example of
|
2384 | * such a language is C/C++ where marco definitions in a file
|
2385 | * a.cpp and result in errors in a header file b.hpp.
|
2386 | *
|
2387 | * @since 3.17.0
|
2388 | */
|
2389 | relatedDocuments?: {
|
2390 | [uri: string]: FullDocumentDiagnosticReport | UnchangedDocumentDiagnosticReport
|
2391 | }
|
2392 | }
|
2393 |
|
2394 | export type RelatedFullDocumentDiagnosticReport = FullDocumentDiagnosticReport & {
|
2395 | /**
|
2396 | * Diagnostics of related documents. This information is useful
|
2397 | * in programming languages where code in a file A can generate
|
2398 | * diagnostics in a file B which A depends on. An example of
|
2399 | * such a language is C/C++ where marco definitions in a file
|
2400 | * a.cpp and result in errors in a header file b.hpp.
|
2401 | *
|
2402 | * @since 3.17.0
|
2403 | */
|
2404 | relatedDocuments?: {
|
2405 | [uri: string]: FullDocumentDiagnosticReport | UnchangedDocumentDiagnosticReport
|
2406 | }
|
2407 | }
|
2408 | export type DocumentDiagnosticReport = RelatedFullDocumentDiagnosticReport | RelatedUnchangedDocumentDiagnosticReport
|
2409 |
|
2410 | /*
|
2411 | * A workspace diagnostic report.
|
2412 | *
|
2413 | * @since 3.17.0
|
2414 | */
|
2415 | export type WorkspaceDiagnosticReport = {
|
2416 | items: WorkspaceDocumentDiagnosticReport[]
|
2417 | }
|
2418 | /**
|
2419 | * A partial result for a workspace diagnostic report.
|
2420 | *
|
2421 | * @since 3.17.0
|
2422 | */
|
2423 | export type WorkspaceDiagnosticReportPartialResult = {
|
2424 | items: WorkspaceDocumentDiagnosticReport[]
|
2425 | }
|
2426 |
|
2427 | export type WorkspaceFullDocumentDiagnosticReport = FullDocumentDiagnosticReport & {
|
2428 | /**
|
2429 | * The URI for which diagnostic information is reported.
|
2430 | */
|
2431 | uri: string
|
2432 | /**
|
2433 | * The version number for which the diagnostics are reported.
|
2434 | * If the document is not marked as open `null` can be provided.
|
2435 | */
|
2436 | version: number | null
|
2437 | }
|
2438 |
|
2439 | export type WorkspaceUnchangedDocumentDiagnosticReport = UnchangedDocumentDiagnosticReport & {
|
2440 | /**
|
2441 | * The URI for which diagnostic information is reported.
|
2442 | */
|
2443 | uri: string
|
2444 | /**
|
2445 | * The version number for which the diagnostics are reported.
|
2446 | * If the document is not marked as open `null` can be provided.
|
2447 | */
|
2448 | version: number | null
|
2449 | }
|
2450 |
|
2451 | export type WorkspaceDocumentDiagnosticReport = WorkspaceFullDocumentDiagnosticReport | WorkspaceUnchangedDocumentDiagnosticReport
|
2452 |
|
2453 | export interface ResultReporter {
|
2454 | (chunk: WorkspaceDiagnosticReportPartialResult | null): void
|
2455 | }
|
2456 | // }}
|
2457 |
|
2458 | // nvim interfaces {{
|
2459 | type VimValue =
|
2460 | | number
|
2461 | | boolean
|
2462 | | string
|
2463 | | number[]
|
2464 | | { [key: string]: any }
|
2465 |
|
2466 | // see `:h nvim_set_client_info()` for details.
|
2467 | export interface VimClientInfo {
|
2468 | name: string
|
2469 | version: {
|
2470 | major?: number
|
2471 | minor?: number
|
2472 | patch?: number
|
2473 | prerelease?: string
|
2474 | commit?: string
|
2475 | }
|
2476 | type: 'remote' | 'embedder' | 'host'
|
2477 | methods?: {
|
2478 | [index: string]: any
|
2479 | }
|
2480 | attributes?: {
|
2481 | [index: string]: any
|
2482 | }
|
2483 | }
|
2484 |
|
2485 | export interface UiAttachOptions {
|
2486 | rgb?: boolean
|
2487 | ext_popupmenu?: boolean
|
2488 | ext_tabline?: boolean
|
2489 | ext_wildmenu?: boolean
|
2490 | ext_cmdline?: boolean
|
2491 | ext_linegrid?: boolean
|
2492 | ext_hlstate?: boolean
|
2493 | }
|
2494 |
|
2495 | export interface ChanInfo {
|
2496 | id: number
|
2497 | stream: 'stdio' | 'stderr' | 'socket' | 'job'
|
2498 | mode: 'bytes' | 'terminal' | 'rpc'
|
2499 | pty?: number
|
2500 | buffer?: number
|
2501 | client?: VimClientInfo
|
2502 | }
|
2503 |
|
2504 | /**
|
2505 | * Returned by nvim_get_commands api.
|
2506 | */
|
2507 | export interface VimCommandDescription {
|
2508 | name: string
|
2509 | bang: boolean
|
2510 | bar: boolean
|
2511 | register: boolean
|
2512 | definition: string
|
2513 | count?: number | null
|
2514 | script_id: number
|
2515 | complete?: string
|
2516 | nargs?: string
|
2517 | range?: string
|
2518 | complete_arg?: string
|
2519 | }
|
2520 |
|
2521 | export interface NvimFloatOptions {
|
2522 | standalone?: boolean
|
2523 | focusable?: boolean
|
2524 | relative?: 'editor' | 'cursor' | 'win'
|
2525 | anchor?: 'NW' | 'NE' | 'SW' | 'SE'
|
2526 | height: number
|
2527 | width: number
|
2528 | row: number
|
2529 | col: number
|
2530 | }
|
2531 |
|
2532 | export interface ExtmarkOptions {
|
2533 | id?: number
|
2534 | // 0-based inclusive.
|
2535 | end_line?: number
|
2536 | // 0-based exclusive.
|
2537 | end_col?: number
|
2538 | // name of the highlight group used to highlight this mark.
|
2539 | hl_group?: string
|
2540 | hl_mode?: 'replace' | 'combine' | 'blend'
|
2541 | hl_eol?: boolean
|
2542 | // A list of [text, highlight] tuples
|
2543 | virt_text?: [string, string | string[]][]
|
2544 | virt_text_pos?: 'eol' | 'overlay' | 'right_align'
|
2545 | virt_text_win_col?: number
|
2546 | virt_text_hide?: boolean
|
2547 | virt_lines?: [string, string | string[]][][]
|
2548 | virt_lines_above?: boolean
|
2549 | virt_lines_leftcol?: boolean
|
2550 | right_gravity?: boolean
|
2551 | end_right_gravity?: boolean
|
2552 | priority?: number
|
2553 | }
|
2554 |
|
2555 | export interface ExtmarkDetails {
|
2556 | end_col: number
|
2557 | end_row: number
|
2558 | priority: number
|
2559 | hl_group?: string
|
2560 | virt_text?: [string, string][]
|
2561 | virt_lines?: [string, string | string][][]
|
2562 | }
|
2563 |
|
2564 | export interface NvimProc {
|
2565 | ppid: number
|
2566 | name: string
|
2567 | pid: number
|
2568 | }
|
2569 |
|
2570 | export interface SignPlaceOption {
|
2571 | id?: number
|
2572 | group?: string
|
2573 | name: string
|
2574 | lnum: number
|
2575 | priority?: number
|
2576 | }
|
2577 |
|
2578 | export interface SignUnplaceOption {
|
2579 | group?: string
|
2580 | id?: number
|
2581 | }
|
2582 |
|
2583 | export interface SignPlacedOption {
|
2584 | /**
|
2585 | * Use '*' for all group, default to '' as unnamed group.
|
2586 | */
|
2587 | group?: string
|
2588 | id?: number
|
2589 | lnum?: number
|
2590 | }
|
2591 |
|
2592 | export interface SignItem {
|
2593 | group: string
|
2594 | id: number
|
2595 | lnum: number
|
2596 | name: string
|
2597 | priority: number
|
2598 | }
|
2599 |
|
2600 | export interface HighlightItem {
|
2601 | hlGroup: string
|
2602 | /**
|
2603 | * 0 based
|
2604 | */
|
2605 | lnum: number
|
2606 | /**
|
2607 | * 0 based
|
2608 | */
|
2609 | colStart: number
|
2610 | /**
|
2611 | * 0 based
|
2612 | */
|
2613 | colEnd: number
|
2614 | }
|
2615 |
|
2616 | export interface ExtendedHighlightItem extends HighlightItem {
|
2617 | combine?: boolean
|
2618 | start_incl?: boolean
|
2619 | end_incl?: boolean
|
2620 | }
|
2621 |
|
2622 | export interface HighlightOption {
|
2623 | /**
|
2624 | * 0 based start line, default to 0.
|
2625 | */
|
2626 | start?: number
|
2627 | /**
|
2628 | * 0 based end line, default to 0.
|
2629 | */
|
2630 | end?: number
|
2631 | /**
|
2632 | * Default to 0 on vim8, 4096 on neovim
|
2633 | */
|
2634 | priority?: number
|
2635 | /**
|
2636 | * Buffer changedtick to match.
|
2637 | */
|
2638 | changedtick?: number
|
2639 | }
|
2640 |
|
2641 | export interface BufferKeymapOption {
|
2642 | nowait?: boolean
|
2643 | silent?: boolean
|
2644 | script?: boolean
|
2645 | expr?: boolean
|
2646 | unique?: boolean
|
2647 | }
|
2648 |
|
2649 | export interface BufferHighlight {
|
2650 | /**
|
2651 | * Name of the highlight group to use
|
2652 | */
|
2653 | hlGroup?: string
|
2654 | /**
|
2655 | * Namespace to use or -1 for ungrouped highlight
|
2656 | */
|
2657 | srcId?: number
|
2658 | /**
|
2659 | * Line to highlight (zero-indexed)
|
2660 | */
|
2661 | line?: number
|
2662 | /**
|
2663 | * Start of (byte-indexed) column range to highlight
|
2664 | */
|
2665 | colStart?: number
|
2666 | /**
|
2667 | * End of (byte-indexed) column range to highlight, or -1 to highlight to end of line
|
2668 | */
|
2669 | colEnd?: number
|
2670 | }
|
2671 |
|
2672 | export interface BufferClearHighlight {
|
2673 | srcId?: number
|
2674 | lineStart?: number
|
2675 | lineEnd?: number
|
2676 | }
|
2677 |
|
2678 | export interface VirtualTextOption {
|
2679 | /**
|
2680 | * Only works on vim9 yet.
|
2681 | */
|
2682 | col?: number
|
2683 | /**
|
2684 | * highlight mode
|
2685 | */
|
2686 | hl_mode?: 'combine' | 'replace' | 'blend'
|
2687 | /**
|
2688 | * neovim only
|
2689 | */
|
2690 | virt_text_win_col?: number
|
2691 | /**
|
2692 | * vim9 only
|
2693 | */
|
2694 | text_align?: 'after' | 'right' | 'below'
|
2695 | /**
|
2696 | * vim9 only
|
2697 | */
|
2698 | text_wrap?: 'wrap' | 'truncate'
|
2699 | }
|
2700 |
|
2701 |
|
2702 | interface BaseApi<T> {
|
2703 | /**
|
2704 | * unique identify number
|
2705 | */
|
2706 | id: number
|
2707 |
|
2708 | /**
|
2709 | * Check if same by compare id.
|
2710 | */
|
2711 | equals(other: T): boolean
|
2712 |
|
2713 | /**
|
2714 | * Request to vim, name need to be nvim_ prefixed and supported by vim.
|
2715 | *
|
2716 | * @param {string} name - nvim function name
|
2717 | * @param {VimValue[]} args
|
2718 | * @returns {Promise<VimValue>}
|
2719 | */
|
2720 | request(name: string, args?: VimValue[]): Promise<any>
|
2721 |
|
2722 | /**
|
2723 | * Send notification to vim, name need to be nvim_ prefixed and supported
|
2724 | * by vim
|
2725 | */
|
2726 | notify(name: string, args?: VimValue[]): void
|
2727 |
|
2728 | /**
|
2729 | * Retrieves scoped variable, returns null when value doesn't exist.
|
2730 | */
|
2731 | getVar(name: string): Promise<VimValue | null>
|
2732 |
|
2733 | /**
|
2734 | * Set scoped variable by request.
|
2735 | *
|
2736 | * @param {string} name
|
2737 | * @param {VimValue} value
|
2738 | * @returns {Promise<void>}
|
2739 | */
|
2740 | setVar(name: string, value: VimValue): Promise<void>
|
2741 |
|
2742 | /**
|
2743 | * Set scoped variable by notification.
|
2744 | */
|
2745 | setVar(name: string, value: VimValue, isNotify: true): void
|
2746 |
|
2747 | /**
|
2748 | * Delete scoped variable by notification.
|
2749 | */
|
2750 | deleteVar(name: string): void
|
2751 |
|
2752 | /**
|
2753 | * Retrieves a scoped option, doesn't exist for tabpage.
|
2754 | */
|
2755 | getOption(name: string): Promise<VimValue>
|
2756 |
|
2757 | /**
|
2758 | * Set scoped option by request, doesn't exist for tabpage.
|
2759 | */
|
2760 | setOption(name: string, value: VimValue): Promise<void>
|
2761 |
|
2762 | /**
|
2763 | * Set scoped variable by notification, doesn't exist for tabpage.
|
2764 | */
|
2765 | setOption(name: string, value: VimValue, isNotify: true): void
|
2766 | }
|
2767 |
|
2768 | export interface Neovim extends BaseApi<Neovim> {
|
2769 |
|
2770 | /**
|
2771 | * Echo error message to vim and log error stack.
|
2772 | */
|
2773 | echoError(msg: unknown): void
|
2774 |
|
2775 | /**
|
2776 | * Check if `nvim_` function exists.
|
2777 | */
|
2778 | hasFunction(name: string): boolean
|
2779 |
|
2780 | /**
|
2781 | * Get channelid used by coc.nvim.
|
2782 | */
|
2783 | channelId: Promise<number>
|
2784 |
|
2785 | /**
|
2786 | * Create buffer instance by id.
|
2787 | */
|
2788 | createBuffer(id: number): Buffer
|
2789 |
|
2790 | /**
|
2791 | * Create window instance by id.
|
2792 | */
|
2793 | createWindow(id: number): Window
|
2794 |
|
2795 | /**
|
2796 | * Create tabpage instance by id.
|
2797 | */
|
2798 | createTabpage(id: number): Tabpage
|
2799 |
|
2800 | /**
|
2801 | * Stop send subsequent notifications.
|
2802 | * This method **must** be paired with `nvim.resumeNotification` in a sync manner.
|
2803 | */
|
2804 | pauseNotification(): void
|
2805 |
|
2806 | /**
|
2807 | * Send paused notifications by nvim_call_atomic request
|
2808 | *
|
2809 | * @param {boolean} redrawVim Redraw vim on vim8 to update the screen
|
2810 | *
|
2811 | * **Note**: avoid call async function between pauseNotification and
|
2812 | * resumeNotification.
|
2813 | */
|
2814 | resumeNotification(redrawVim?: boolean): Promise<[VimValue[], [string, number, string] | null]>
|
2815 |
|
2816 | /**
|
2817 | * Send paused notifications by nvim_call_atomic notification
|
2818 | *
|
2819 | * @param {boolean} redrawVim Redraw vim to update the screen
|
2820 | * @param {true} notify
|
2821 | * @returns {void}
|
2822 | */
|
2823 | resumeNotification(redrawVim: boolean, notify: true): void
|
2824 |
|
2825 | /**
|
2826 | * Send redraw command to vim, does nothing on neovim since it's not necessary on most cases.
|
2827 | */
|
2828 | redrawVim(): void
|
2829 |
|
2830 | /**
|
2831 | * Get list of current buffers.
|
2832 | */
|
2833 | buffers: Promise<Buffer[]>
|
2834 |
|
2835 | /**
|
2836 | * Get current buffer.
|
2837 | */
|
2838 | buffer: Promise<Buffer>
|
2839 |
|
2840 | /**
|
2841 | * Set current buffer
|
2842 | */
|
2843 | setBuffer(buffer: Buffer): Promise<void>
|
2844 |
|
2845 | /**
|
2846 | * Get list of current tabpages.
|
2847 | */
|
2848 | tabpages: Promise<Tabpage[]>
|
2849 |
|
2850 | /**
|
2851 | * Get current tabpage.
|
2852 | */
|
2853 | tabpage: Promise<Tabpage>
|
2854 |
|
2855 | /**
|
2856 | * Set current tabpage
|
2857 | */
|
2858 | setTabpage(tabpage: Tabpage): Promise<void>
|
2859 |
|
2860 | /**
|
2861 | * Get list of current windows.
|
2862 | */
|
2863 | windows: Promise<Window[]>
|
2864 |
|
2865 | /**
|
2866 | * Get current window.
|
2867 | */
|
2868 | window: Promise<Window>
|
2869 |
|
2870 | /**
|
2871 | * Set current window.
|
2872 | */
|
2873 | setWindow(window: Window): Promise<void>
|
2874 |
|
2875 | /**
|
2876 | * Get information of all channels,
|
2877 | * **Note:** works on neovim only.
|
2878 | */
|
2879 | chans: Promise<ChanInfo[]>
|
2880 |
|
2881 | /**
|
2882 | * Get information of channel by id,
|
2883 | * **Note:** works on neovim only.
|
2884 | */
|
2885 | getChanInfo(id: number): Promise<ChanInfo>
|
2886 |
|
2887 | /**
|
2888 | * Creates a new namespace, or gets an existing one.
|
2889 | * `:h nvim_create_namespace()`
|
2890 | */
|
2891 | createNamespace(name?: string): Promise<number>
|
2892 |
|
2893 | /**
|
2894 | * Gets existing, non-anonymous namespaces.
|
2895 | *
|
2896 | * @return dict that maps from names to namespace ids.
|
2897 | */
|
2898 | namespaces: Promise<{ [name: string]: number }>
|
2899 |
|
2900 | /**
|
2901 | * Gets a map of global (non-buffer-local) Ex commands.
|
2902 | *
|
2903 | * @return Map of maps describing commands.
|
2904 | */
|
2905 | getCommands(opt?: { builtin: boolean }): Promise<{ [name: string]: VimCommandDescription }>
|
2906 |
|
2907 | /**
|
2908 | * Get list of all runtime paths
|
2909 | */
|
2910 | runtimePaths: Promise<string[]>
|
2911 |
|
2912 | /**
|
2913 | * Set global working directory.
|
2914 | * **Note:** works on neovim only.
|
2915 | */
|
2916 | setDirectory(dir: string): Promise<void>
|
2917 |
|
2918 | /**
|
2919 | * Get current line.
|
2920 | */
|
2921 | line: Promise<string>
|
2922 |
|
2923 | /**
|
2924 | * Creates a new, empty, unnamed buffer.
|
2925 | *
|
2926 | * **Note:** works on neovim only.
|
2927 | */
|
2928 | createNewBuffer(listed?: boolean, scratch?: boolean): Promise<Buffer>
|
2929 |
|
2930 | /**
|
2931 | * Create float window of neovim.
|
2932 | *
|
2933 | * **Note:** works on neovim only, use high level api provided by window
|
2934 | * module is recommended.
|
2935 | */
|
2936 | openFloatWindow(buffer: Buffer, enter: boolean, options: NvimFloatOptions): Promise<Window>
|
2937 |
|
2938 | /**
|
2939 | * Set current line.
|
2940 | */
|
2941 | setLine(line: string): Promise<void>
|
2942 |
|
2943 | /**
|
2944 | * Gets a list of global (non-buffer-local) |mapping| definitions.
|
2945 | * `:h nvim_get_keymap`
|
2946 | *
|
2947 | * **Note:** works on neovim only.
|
2948 | */
|
2949 | getKeymap(mode: string): Promise<object[]>
|
2950 |
|
2951 | /**
|
2952 | * Gets the current mode. |mode()| "blocking" is true if Nvim is waiting for input.
|
2953 | *
|
2954 | * **Note:** blocking would always be false when used with vim.
|
2955 | */
|
2956 | mode: Promise<{ mode: string; blocking: boolean }>
|
2957 |
|
2958 | /**
|
2959 | * Returns a map of color names and RGB values.
|
2960 | *
|
2961 | * **Note:** works on neovim only.
|
2962 | */
|
2963 | colorMap(): Promise<{ [name: string]: number }>
|
2964 |
|
2965 | /**
|
2966 | * Returns the 24-bit RGB value of a |nvim_get_color_map()| color name or
|
2967 | * "#rrggbb" hexadecimal string.
|
2968 | *
|
2969 | * **Note:** works on neovim only.
|
2970 | */
|
2971 | getColorByName(name: string): Promise<number>
|
2972 |
|
2973 | /**
|
2974 | * Gets a highlight definition by id. |hlID()|
|
2975 | *
|
2976 | * **Note:** works on neovim only.
|
2977 | */
|
2978 | getHighlight(nameOrId: string | number, isRgb?: boolean): Promise<object>
|
2979 |
|
2980 | /**
|
2981 | * Get a highlight by name, return rgb by default.
|
2982 | *
|
2983 | * **Note:** works on neovim only.
|
2984 | */
|
2985 | getHighlightByName(name: string, isRgb?: boolean): Promise<object>
|
2986 |
|
2987 | /**
|
2988 | * Get a highlight by id, return rgb by default.
|
2989 | *
|
2990 | * **Note:** works on neovim only.
|
2991 | */
|
2992 | getHighlightById(id: number, isRgb?: boolean): Promise<object>
|
2993 |
|
2994 | /**
|
2995 | * Delete current line in buffer.
|
2996 | */
|
2997 | deleteCurrentLine(): Promise<void>
|
2998 |
|
2999 | /**
|
3000 | * Evaluates a VimL expression (:help expression). Dictionaries
|
3001 | * and Lists are recursively expanded. On VimL error: Returns a
|
3002 | * generic error; v:errmsg is not updated.
|
3003 | *
|
3004 | */
|
3005 | eval(expr: string): Promise<VimValue>
|
3006 |
|
3007 | /**
|
3008 | * Executes lua, it's possible neovim client does not support this
|
3009 | *
|
3010 | * **Note:** works on neovim only.
|
3011 | */
|
3012 | lua(code: string, args?: VimValue[]): Promise<object>
|
3013 |
|
3014 | /**
|
3015 | * Calls a VimL |Dictionary-function| with the given arguments.
|
3016 | */
|
3017 | callDictFunction(dict: object | string, fname: string, args: VimValue | VimValue[]): Promise<object>
|
3018 |
|
3019 | /**
|
3020 | * Call a vim function.
|
3021 | *
|
3022 | * @param {string} fname - function name
|
3023 | * @param {VimValue | VimValue[]} args
|
3024 | * @returns {Promise<any>}
|
3025 | */
|
3026 | call(fname: string, args?: VimValue | VimValue[]): Promise<any>
|
3027 |
|
3028 | /**
|
3029 | * Call a vim function by notification.
|
3030 | */
|
3031 | call(fname: string, args: VimValue | VimValue[], isNotify: true): void
|
3032 |
|
3033 | /**
|
3034 | * Call a vim function with timer of timeout 0.
|
3035 | *
|
3036 | * @param {string} fname - function name
|
3037 | * @param {VimValue | VimValue[]} args
|
3038 | * @returns {Promise<any>}
|
3039 | */
|
3040 | callTimer(fname: string, args?: VimValue | VimValue[]): Promise<void>
|
3041 |
|
3042 | /**
|
3043 | * Call a vim function with timer of timeout 0 by notification.
|
3044 | */
|
3045 | callTimer(fname: string, args: VimValue | VimValue[], isNotify: true): void
|
3046 |
|
3047 | /**
|
3048 | * Call async vim function that accept callback as argument
|
3049 | * by using notifications.
|
3050 | */
|
3051 | callAsync(fname: string, args?: VimValue | VimValue[]): Promise<unknown>
|
3052 |
|
3053 | /**
|
3054 | * Calls many API methods atomically.
|
3055 | */
|
3056 | callAtomic(calls: [string, VimValue[]][]): Promise<[any[], any[] | null]>
|
3057 |
|
3058 | /**
|
3059 | * Executes an ex-command by request.
|
3060 | */
|
3061 | command(arg: string): Promise<void>
|
3062 |
|
3063 | /**
|
3064 | * Executes an ex-command by notification.
|
3065 | */
|
3066 | command(arg: string, isNotify: true): void
|
3067 |
|
3068 | /**
|
3069 | * Runs a command and returns output.
|
3070 | *
|
3071 | * @deprecated Use exec() instead.
|
3072 | */
|
3073 | commandOutput(arg: string): Promise<string>
|
3074 |
|
3075 | /**
|
3076 | * Executes Vimscript (multiline block of Ex-commands), like
|
3077 | * anonymous |:source|
|
3078 | */
|
3079 | exec(src: string, output?: boolean): Promise<string>
|
3080 |
|
3081 | /**
|
3082 | * Gets a v: variable.
|
3083 | */
|
3084 | getVvar(name: string): Promise<VimValue>
|
3085 |
|
3086 | /**
|
3087 | * `:h nvim_feedkeys`
|
3088 | */
|
3089 | feedKeys(keys: string, mode: string, escapeCsi: boolean): Promise<void>
|
3090 |
|
3091 | /**
|
3092 | * Queues raw user-input. Unlike |nvim_feedkeys()|, this uses a
|
3093 | * low-level input buffer and the call is non-blocking (input is
|
3094 | * processed asynchronously by the eventloop).
|
3095 | *
|
3096 | * On execution error: does not fail, but updates v:errmsg.
|
3097 | *
|
3098 | * **Note:** works on neovim only.
|
3099 | */
|
3100 | input(keys: string): Promise<number>
|
3101 |
|
3102 | /**
|
3103 | * Parse a VimL Expression.
|
3104 | */
|
3105 | parseExpression(expr: string, flags: string, highlight: boolean): Promise<object>
|
3106 |
|
3107 | /**
|
3108 | * Get process info, neovim only.
|
3109 | *
|
3110 | * **Note:** works on neovim only.
|
3111 | */
|
3112 | getProc(pid: number): Promise<NvimProc>
|
3113 |
|
3114 | /**
|
3115 | * Gets the immediate children of process `pid`.
|
3116 | *
|
3117 | * **Note:** works on neovim only.
|
3118 | */
|
3119 | getProcChildren(pid: number): Promise<NvimProc[]>
|
3120 |
|
3121 | /**
|
3122 | * Replaces terminal codes and |keycodes| (<CR>, <Esc>, ...)
|
3123 | * in a string with the internal representation.
|
3124 | *
|
3125 | * **Note:** works on neovim only.
|
3126 | */
|
3127 | replaceTermcodes(str: string, fromPart: boolean, doIt: boolean, special: boolean): Promise<string>
|
3128 |
|
3129 | /**
|
3130 | * Gets width(display cells) of string.
|
3131 | */
|
3132 | strWidth(str: string): Promise<number>
|
3133 |
|
3134 | /**
|
3135 | * Gets a list of dictionaries representing attached UIs.
|
3136 | *
|
3137 | * **Note:** works on neovim only.
|
3138 | */
|
3139 | uis: Promise<any[]>
|
3140 |
|
3141 | /**
|
3142 | * Subscribe to nvim event broadcasts.
|
3143 | *
|
3144 | * **Note:** works on neovim only.
|
3145 | */
|
3146 | subscribe(event: string): Promise<void>
|
3147 |
|
3148 | /**
|
3149 | * Unsubscribe to nvim event broadcasts
|
3150 | *
|
3151 | * **Note:** works on neovim only.
|
3152 | */
|
3153 | unsubscribe(event: string): Promise<void>
|
3154 |
|
3155 | /**
|
3156 | * Activates UI events on the channel.
|
3157 | *
|
3158 | * **Note:** works on neovim only.
|
3159 | */
|
3160 | uiAttach(width: number, height: number, options: UiAttachOptions): Promise<void>
|
3161 |
|
3162 | /**
|
3163 | * `:h nvim_ui_try_resize`
|
3164 | *
|
3165 | * **Note:** works on neovim only.
|
3166 | */
|
3167 | uiTryResize(width: number, height: number): Promise<void>
|
3168 |
|
3169 | /**
|
3170 | * Deactivates UI events on the channel.
|
3171 | *
|
3172 | * **Note:** works on neovim only.
|
3173 | */
|
3174 | uiDetach(): Promise<void>
|
3175 |
|
3176 | /**
|
3177 | * Quit vim.
|
3178 | */
|
3179 | quit(): Promise<void>
|
3180 | }
|
3181 |
|
3182 | export interface Buffer extends BaseApi<Buffer> {
|
3183 | id: number
|
3184 |
|
3185 | /** Total number of lines in buffer */
|
3186 | length: Promise<number>
|
3187 |
|
3188 | /**
|
3189 | * Get lines of buffer.
|
3190 | */
|
3191 | lines: Promise<string[]>
|
3192 |
|
3193 | /**
|
3194 | * Get changedtick of buffer.
|
3195 | */
|
3196 | changedtick: Promise<number>
|
3197 |
|
3198 | /**
|
3199 | * Add buffer keymap by notification.
|
3200 | */
|
3201 | setKeymap(mode: string, lhs: string, rhs: string, opts?: BufferKeymapOption): void
|
3202 |
|
3203 | /**
|
3204 | * Removes an ext mark by notification.
|
3205 | *
|
3206 | * @public
|
3207 | * @param {number} ns_id - Namespace id
|
3208 | * @param {number} id - Extmark id
|
3209 | */
|
3210 | deleteExtMark(ns_id: number, id: number): void
|
3211 |
|
3212 | /**
|
3213 | * Gets the position (0-indexed) of an extmark.
|
3214 | *
|
3215 | * @param {number} ns_id - Namespace id
|
3216 | * @param {number} id - Extmark id
|
3217 | * @param {Object} opts - Optional parameters.
|
3218 | * @returns {Promise<[] | [number, number] | [number, number, ExtmarkDetails]>}
|
3219 | */
|
3220 | getExtMarkById(ns_id: number, id: number, opts?: {
|
3221 | details?: boolean
|
3222 | }): Promise<[] | [number, number] | [number, number, ExtmarkDetails]>
|
3223 |
|
3224 | /**
|
3225 | * Gets extmarks in "traversal order" from a |charwise| region defined by
|
3226 | * buffer positions (inclusive, 0-indexed |api-indexing|).
|
3227 | *
|
3228 | * Region can be given as (row,col) tuples, or valid extmark ids (whose
|
3229 | * positions define the bounds). 0 and -1 are understood as (0,0) and (-1,-1)
|
3230 | * respectively, thus the following are equivalent:
|
3231 | *
|
3232 | * nvim_buf_get_extmarks(0, my_ns, 0, -1, {})
|
3233 | * nvim_buf_get_extmarks(0, my_ns, [0,0], [-1,-1], {})
|
3234 | *
|
3235 | * @param {number} ns_id - Namespace id
|
3236 | * @param {[number, number] | number} start
|
3237 | * @param {[number, number] | number} end
|
3238 | * @param {Object} opts
|
3239 | * @returns {Promise<[number, number, number, ExtmarkDetails?][]>}
|
3240 | */
|
3241 | getExtMarks(ns_id: number, start: [number, number] | number, end: [number, number] | number, opts?: {
|
3242 | details?: boolean
|
3243 | limit?: number
|
3244 | }): Promise<[number, number, number, ExtmarkDetails?][]>
|
3245 |
|
3246 | /**
|
3247 | * Creates or updates an extmark by notification, `:h nvim_buf_set_extmark`.
|
3248 | *
|
3249 | * @param {number} ns_id
|
3250 | * @param {number} line
|
3251 | * @param {number} col
|
3252 | * @param {ExtmarkOptions} opts
|
3253 | * @returns {void}
|
3254 | */
|
3255 | setExtMark(ns_id: number, line: number, col: number, opts?: ExtmarkOptions): void
|
3256 |
|
3257 | /**
|
3258 | * Add sign to buffer by notification.
|
3259 | *
|
3260 | * @param {SignPlaceOption} sign
|
3261 | */
|
3262 | placeSign(sign: SignPlaceOption): void
|
3263 |
|
3264 | /**
|
3265 | * Unplace signs by notification
|
3266 | */
|
3267 | unplaceSign(opts: SignUnplaceOption): void
|
3268 |
|
3269 | /**
|
3270 | * Get signs by group name or id and lnum.
|
3271 | *
|
3272 | * @param {SignPlacedOption} opts
|
3273 | */
|
3274 | getSigns(opts: SignPlacedOption): Promise<SignItem[]>
|
3275 |
|
3276 | /**
|
3277 | * Get highlight items by namespace (end inclusive).
|
3278 | *
|
3279 | * @param {string} ns Namespace key or id.
|
3280 | * @param {number} start 0 based line number, default to 0.
|
3281 | * @param {number} end 0 based line number, default to -1.
|
3282 | */
|
3283 | getHighlights(ns: string, start?: number, end?: number): Promise<HighlightItem[]>
|
3284 |
|
3285 | /**
|
3286 | * Update namespaced highlights in range by notification.
|
3287 | * Priority default to 0 on vim and 4096 on neovim.
|
3288 | * Note: timer used for whole buffer highlights for better performance.
|
3289 | *
|
3290 | * @param {string} ns Namespace key.
|
3291 | * @param {HighlightItem[]} highlights Highlight items.
|
3292 | * @param {HighlightOption} opts Highlight options.
|
3293 | */
|
3294 | updateHighlights(ns: string, highlights: ExtendedHighlightItem[], opts?: HighlightOption): void
|
3295 |
|
3296 | /**
|
3297 | * Gets a map of buffer-local |user-commands|.
|
3298 | *
|
3299 | * **Note:** works on neovim only.
|
3300 | */
|
3301 | getCommands(options?: {}): Promise<Object>
|
3302 |
|
3303 | /**
|
3304 | * Get lines of buffer, get all lines by default.
|
3305 | */
|
3306 | getLines(opts?: { start: number, end: number, strictIndexing?: boolean }): Promise<string[]>
|
3307 |
|
3308 | /**
|
3309 | * Set lines of buffer given indices use request.
|
3310 | */
|
3311 | setLines(lines: string[], opts?: { start: number, end: number, strictIndexing?: boolean }): Promise<void>
|
3312 |
|
3313 | /**
|
3314 | * Set lines of buffer given indices use notification.
|
3315 | */
|
3316 | setLines(lines: string[], opts: { start: number, end: number, strictIndexing?: boolean }, isNotify: true): void
|
3317 |
|
3318 | /**
|
3319 | * Set virtual text for a line use notification, works on both neovim and vim9.
|
3320 | *
|
3321 | * @public
|
3322 | * @param {number} src_id - Source group to use or 0 to use a new group, or -1
|
3323 | * @param {number} line - Line to annotate with virtual text (zero-indexed)
|
3324 | * @param {Chunk[]} chunks - List with [text, hl_group]
|
3325 | * @param {[index} opts
|
3326 | * @returns {Promise<number>}
|
3327 | */
|
3328 | setVirtualText(src_id: number, line: number, chunks: [string, string][], opts?: VirtualTextOption): void
|
3329 |
|
3330 | /**
|
3331 | * Append a string or list of lines to end of buffer
|
3332 | */
|
3333 | append(lines: string[] | string): Promise<void>
|
3334 |
|
3335 | /**
|
3336 | * Get buffer name.
|
3337 | */
|
3338 | name: Promise<string>
|
3339 |
|
3340 | /**
|
3341 | * Set buffer name.
|
3342 | */
|
3343 | setName(name: string): Promise<void>
|
3344 |
|
3345 | /**
|
3346 | * Check if buffer valid.
|
3347 | */
|
3348 | valid: Promise<boolean>
|
3349 |
|
3350 | /**
|
3351 | * Get mark position given mark name
|
3352 | *
|
3353 | * **Note:** works on neovim only.
|
3354 | */
|
3355 | mark(name: string): Promise<[number, number]>
|
3356 |
|
3357 | /**
|
3358 | * Gets a list of buffer-local |mapping| definitions.
|
3359 | *
|
3360 | * @return Array of maparg()-like dictionaries describing mappings.
|
3361 | * The "buffer" key holds the associated buffer handle.
|
3362 | */
|
3363 | getKeymap(mode: string): Promise<object[]>
|
3364 |
|
3365 | /**
|
3366 | * Check if buffer loaded.
|
3367 | */
|
3368 | loaded: Promise<boolean>
|
3369 |
|
3370 | /**
|
3371 | * Returns the byte offset for a line.
|
3372 | *
|
3373 | * Line 1 (index=0) has offset 0. UTF-8 bytes are counted. EOL is
|
3374 | * one byte. 'fileformat' and 'fileencoding' are ignored. The
|
3375 | * line index just after the last line gives the total byte-count
|
3376 | * of the buffer. A final EOL byte is counted if it would be
|
3377 | * written, see 'eol'.
|
3378 | *
|
3379 | * Unlike |line2byte()|, throws error for out-of-bounds indexing.
|
3380 | * Returns -1 for unloaded buffer.
|
3381 | *
|
3382 | * @return {Number} Integer byte offset, or -1 for unloaded buffer.
|
3383 | */
|
3384 | getOffset(index: number): Promise<number>
|
3385 |
|
3386 | /**
|
3387 | * Adds a highlight to buffer, checkout |nvim_buf_add_highlight|.
|
3388 | *
|
3389 | * Note: when `srcId = 0`, request is made for new `srcId`, otherwire, use notification.
|
3390 | * Note: `hlGroup` as empty string is not supported.
|
3391 | *
|
3392 | * @deprecated use `highlightRanges()` instead.
|
3393 | */
|
3394 | addHighlight(opts: BufferHighlight): Promise<number | null>
|
3395 |
|
3396 | /**
|
3397 | * Clear highlights of specified lins.
|
3398 | *
|
3399 | * @deprecated use clearNamespace() instead.
|
3400 | */
|
3401 | clearHighlight(args?: BufferClearHighlight)
|
3402 |
|
3403 | /**
|
3404 | * Add highlight to ranges by notification, works on both vim & neovim.
|
3405 | *
|
3406 | * Works on neovim and `workspace.isVim && workspace.env.textprop` is true
|
3407 | *
|
3408 | * @param {string | number} srcId Unique key or namespace number.
|
3409 | * @param {string} hlGroup Highlight group.
|
3410 | * @param {Range[]} ranges List of highlight ranges
|
3411 | */
|
3412 | highlightRanges(srcId: string | number, hlGroup: string, ranges: Range[]): void
|
3413 |
|
3414 | /**
|
3415 | * Clear namespace by id or name by notification, works on both vim & neovim.
|
3416 | *
|
3417 | * Works on neovim and `workspace.isVim && workspace.env.textprop` is true
|
3418 | *
|
3419 | * @param key Unique key or namespace number, use -1 for all namespaces
|
3420 | * @param lineStart Start of line, 0 based, default to 0.
|
3421 | * @param lineEnd End of line, 0 based, default to -1.
|
3422 | */
|
3423 | clearNamespace(key: number | string, lineStart?: number, lineEnd?: number)
|
3424 | }
|
3425 |
|
3426 | export interface Window extends BaseApi<Window> {
|
3427 | /**
|
3428 | * The windowid that not change within a Vim session
|
3429 | */
|
3430 | id: number
|
3431 |
|
3432 | /**
|
3433 | * Buffer in window.
|
3434 | */
|
3435 | buffer: Promise<Buffer>
|
3436 |
|
3437 | /**
|
3438 | * Tabpage contains window.
|
3439 | */
|
3440 | tabpage: Promise<Tabpage>
|
3441 |
|
3442 | /**
|
3443 | * Cursor position as [line, col], 1 based.
|
3444 | */
|
3445 | cursor: Promise<[number, number]>
|
3446 |
|
3447 | /**
|
3448 | * Window height.
|
3449 | */
|
3450 | height: Promise<number>
|
3451 |
|
3452 | /**
|
3453 | * Window width.
|
3454 | */
|
3455 | width: Promise<number>
|
3456 |
|
3457 | /**
|
3458 | * Set cursor position by request.
|
3459 | */
|
3460 | setCursor(pos: [number, number]): Promise<void>
|
3461 |
|
3462 | /**
|
3463 | * Set cursor position by notification.
|
3464 | */
|
3465 | setCursor(pos: [number, number], isNotify: true): void
|
3466 |
|
3467 | /**
|
3468 | * Set height
|
3469 | */
|
3470 | setHeight(height: number): Promise<void>
|
3471 |
|
3472 | /**
|
3473 | * Set height by notification.
|
3474 | */
|
3475 | setHeight(height: number, isNotify: true): void
|
3476 |
|
3477 | /**
|
3478 | * Set width.
|
3479 | */
|
3480 | setWidth(width: number): Promise<void>
|
3481 |
|
3482 | /**
|
3483 | * Set width by notification.
|
3484 | */
|
3485 | setWidth(width: number, isNotify: true): void
|
3486 |
|
3487 | /**
|
3488 | * Get window position, not work with vim8's popup.
|
3489 | */
|
3490 | position: Promise<[number, number]>
|
3491 |
|
3492 | /** 0-indexed, on-screen window position(row) in display cells. */
|
3493 | row: Promise<number>
|
3494 |
|
3495 | /** 0-indexed, on-screen window position(col) in display cells. */
|
3496 | col: Promise<number>
|
3497 |
|
3498 | /**
|
3499 | * Check if window valid.
|
3500 | */
|
3501 | valid: Promise<boolean>
|
3502 |
|
3503 | /**
|
3504 | * Get window number, throws for invalid window.
|
3505 | */
|
3506 | number: Promise<number>
|
3507 |
|
3508 | /**
|
3509 | * Config float window with options.
|
3510 | *
|
3511 | * **Note:** works on neovim only.
|
3512 | */
|
3513 | setConfig(options: NvimFloatOptions): Promise<void>
|
3514 |
|
3515 | /**
|
3516 | * Config float window with options by send notification.
|
3517 | *
|
3518 | * **Note:** works on neovim only.
|
3519 | */
|
3520 | setConfig(options: NvimFloatOptions, isNotify: true): void
|
3521 |
|
3522 | /**
|
3523 | * Gets window configuration.
|
3524 | *
|
3525 | * **Note:** works on neovim only.
|
3526 | *
|
3527 | * @returns Map defining the window configuration, see |nvim_open_win()|
|
3528 | */
|
3529 | getConfig(): Promise<NvimFloatOptions>
|
3530 |
|
3531 | /**
|
3532 | * Close window by send request.
|
3533 | */
|
3534 | close(force: boolean): Promise<void>
|
3535 |
|
3536 | /**
|
3537 | * Close window by send notification.
|
3538 | */
|
3539 | close(force: boolean, isNotify: true): void
|
3540 |
|
3541 | /**
|
3542 | * Add highlight to ranges by request (matchaddpos is used)
|
3543 | *
|
3544 | * @return {Promise<number[]>} match ids.
|
3545 | */
|
3546 | highlightRanges(hlGroup: string, ranges: Range[], priority?: number): Promise<number[]>
|
3547 |
|
3548 | /**
|
3549 | * Add highlight to ranges by notification (matchaddpos is used)
|
3550 | */
|
3551 | highlightRanges(hlGroup: string, ranges: Range[], priority: number, isNotify: true): void
|
3552 |
|
3553 | /**
|
3554 | * Clear match of highlight group by send notification.
|
3555 | */
|
3556 | clearMatchGroup(hlGroup: string): void
|
3557 |
|
3558 | /**
|
3559 | * Clear match of match ids by send notification.
|
3560 | */
|
3561 | clearMatches(ids: number[]): void
|
3562 | }
|
3563 |
|
3564 | export interface Tabpage extends BaseApi<Tabpage> {
|
3565 | /**
|
3566 | * tabpage number.
|
3567 | */
|
3568 | number: Promise<number>
|
3569 |
|
3570 | /**
|
3571 | * Is current tabpage valid.
|
3572 | */
|
3573 | valid: Promise<boolean>
|
3574 |
|
3575 | /**
|
3576 | * Returns all windows of tabpage.
|
3577 | */
|
3578 | windows: Promise<Window[]>
|
3579 |
|
3580 | /**
|
3581 | * Current window of tabpage.
|
3582 | */
|
3583 | window: Promise<Window>
|
3584 | }
|
3585 | // }}
|
3586 |
|
3587 | // vscode-uri {{
|
3588 | export interface UriComponents {
|
3589 | scheme: string
|
3590 | authority: string
|
3591 | path: string
|
3592 | query: string
|
3593 | fragment: string
|
3594 | }
|
3595 | /**
|
3596 | * Uniform Resource Identifier (URI) http://tools.ietf.org/html/rfc3986.
|
3597 | * This class is a simple parser which creates the basic component parts
|
3598 | * (http://tools.ietf.org/html/rfc3986#section-3) with minimal validation
|
3599 | * and encoding.
|
3600 | *
|
3601 | * ```txt
|
3602 | * foo://example.com:8042/over/there?name=ferret#nose
|
3603 | * \_/ \______________/\_________/ \_________/ \__/
|
3604 | * | | | | |
|
3605 | * scheme authority path query fragment
|
3606 | * | _____________________|__
|
3607 | * / \ / \
|
3608 | * urn:example:animal:ferret:nose
|
3609 | * ```
|
3610 | */
|
3611 | export class Uri implements UriComponents {
|
3612 | static isUri(thing: any): thing is Uri
|
3613 | /**
|
3614 | * scheme is the 'http' part of 'http://www.msft.com/some/path?query#fragment'.
|
3615 | * The part before the first colon.
|
3616 | */
|
3617 | readonly scheme: string
|
3618 | /**
|
3619 | * authority is the 'www.msft.com' part of 'http://www.msft.com/some/path?query#fragment'.
|
3620 | * The part between the first double slashes and the next slash.
|
3621 | */
|
3622 | readonly authority: string
|
3623 | /**
|
3624 | * path is the '/some/path' part of 'http://www.msft.com/some/path?query#fragment'.
|
3625 | */
|
3626 | readonly path: string
|
3627 | /**
|
3628 | * query is the 'query' part of 'http://www.msft.com/some/path?query#fragment'.
|
3629 | */
|
3630 | readonly query: string
|
3631 | /**
|
3632 | * fragment is the 'fragment' part of 'http://www.msft.com/some/path?query#fragment'.
|
3633 | */
|
3634 | readonly fragment: string
|
3635 | /**
|
3636 | * @internal
|
3637 | */
|
3638 | protected constructor(scheme: string, authority?: string, path?: string, query?: string, fragment?: string, _strict?: boolean)
|
3639 | /**
|
3640 | * @internal
|
3641 | */
|
3642 | protected constructor(components: UriComponents)
|
3643 | /**
|
3644 | * Returns a string representing the corresponding file system path of this URI.
|
3645 | * Will handle UNC paths, normalizes windows drive letters to lower-case, and uses the
|
3646 | * platform specific path separator.
|
3647 | *
|
3648 | * * Will *not* validate the path for invalid characters and semantics.
|
3649 | * * Will *not* look at the scheme of this URI.
|
3650 | * * The result shall *not* be used for display purposes but for accessing a file on disk.
|
3651 | *
|
3652 | *
|
3653 | * The *difference* to `URI#path` is the use of the platform specific separator and the handling
|
3654 | * of UNC paths. See the below sample of a file-uri with an authority (UNC path).
|
3655 | *
|
3656 | * ```ts
|
3657 | const u = URI.parse('file://server/c$/folder/file.txt')
|
3658 | u.authority === 'server'
|
3659 | u.path === '/shares/c$/file.txt'
|
3660 | u.fsPath === '\\server\c$\folder\file.txt'
|
3661 | ```
|
3662 | *
|
3663 | * Using `URI#path` to read a file (using fs-apis) would not be enough because parts of the path,
|
3664 | * namely the server name, would be missing. Therefore `URI#fsPath` exists - it's sugar to ease working
|
3665 | * with URIs that represent files on disk (`file` scheme).
|
3666 | */
|
3667 | readonly fsPath: string
|
3668 | with(change: {
|
3669 | scheme?: string
|
3670 | authority?: string | null
|
3671 | path?: string | null
|
3672 | query?: string | null
|
3673 | fragment?: string | null
|
3674 | }): Uri
|
3675 | /**
|
3676 | * Creates a new URI from a string, e.g. `http://www.msft.com/some/path`,
|
3677 | * `file:///usr/home`, or `scheme:with/path`.
|
3678 | *
|
3679 | * @param value A string which represents an URI (see `URI#toString`).
|
3680 | */
|
3681 | static parse(value: string, _strict?: boolean): Uri
|
3682 | /**
|
3683 | * Creates a new URI from a file system path, e.g. `c:\my\files`,
|
3684 | * `/usr/home`, or `\\server\share\some\path`.
|
3685 | *
|
3686 | * The *difference* between `URI#parse` and `URI#file` is that the latter treats the argument
|
3687 | * as path, not as stringified-uri. E.g. `URI.file(path)` is **not the same as**
|
3688 | * `URI.parse('file://' + path)` because the path might contain characters that are
|
3689 | * interpreted (# and ?). See the following sample:
|
3690 | * ```ts
|
3691 | const good = URI.file('/coding/c#/project1');
|
3692 | good.scheme === 'file';
|
3693 | good.path === '/coding/c#/project1';
|
3694 | good.fragment === '';
|
3695 | const bad = URI.parse('file://' + '/coding/c#/project1');
|
3696 | bad.scheme === 'file';
|
3697 | bad.path === '/coding/c'; // path is now broken
|
3698 | bad.fragment === '/project1';
|
3699 | ```
|
3700 | *
|
3701 | * @param path A file system path (see `URI#fsPath`)
|
3702 | */
|
3703 | static file(path: string): Uri
|
3704 | static from(components: {
|
3705 | scheme: string
|
3706 | authority?: string
|
3707 | path?: string
|
3708 | query?: string
|
3709 | fragment?: string
|
3710 | }): Uri
|
3711 | /**
|
3712 | * Creates a string representation for this URI. It's guaranteed that calling
|
3713 | * `URI.parse` with the result of this function creates an URI which is equal
|
3714 | * to this URI.
|
3715 | *
|
3716 | * * The result shall *not* be used for display purposes but for externalization or transport.
|
3717 | * * The result will be encoded using the percentage encoding and encoding happens mostly
|
3718 | * ignore the scheme-specific encoding rules.
|
3719 | *
|
3720 | * @param skipEncoding Do not encode the result, default is `false`
|
3721 | */
|
3722 | toString(skipEncoding?: boolean): string
|
3723 | toJSON(): UriComponents
|
3724 | }
|
3725 | // }}
|
3726 |
|
3727 | // vim interfaces {{
|
3728 | /**
|
3729 | * See `:h complete-items`
|
3730 | */
|
3731 | export interface VimCompleteItem {
|
3732 | word: string
|
3733 | abbr?: string
|
3734 | menu?: string
|
3735 | info?: string
|
3736 | kind?: string
|
3737 | icase?: number
|
3738 | equal?: number
|
3739 | dup?: number
|
3740 | empty?: number
|
3741 | user_data?: string
|
3742 | }
|
3743 |
|
3744 | export interface CompleteDoneItem {
|
3745 | readonly word: string
|
3746 | readonly abbr?: string
|
3747 | readonly source: string
|
3748 | readonly isSnippet: boolean
|
3749 | readonly kind?: string
|
3750 | readonly menu?: string
|
3751 | readonly user_data?: string
|
3752 | }
|
3753 |
|
3754 | export interface LocationListItem {
|
3755 | bufnr: number
|
3756 | lnum: number
|
3757 | end_lnum: number
|
3758 | col: number
|
3759 | end_col: number
|
3760 | text: string
|
3761 | type: string
|
3762 | }
|
3763 |
|
3764 | export interface QuickfixItem {
|
3765 | uri?: string
|
3766 | module?: string
|
3767 | range?: Range
|
3768 | text?: string
|
3769 | type?: string
|
3770 | filename?: string
|
3771 | bufnr?: number
|
3772 | lnum?: number
|
3773 | end_lnum?: number
|
3774 | col?: number
|
3775 | end_col?: number
|
3776 | valid?: boolean
|
3777 | nr?: number
|
3778 | }
|
3779 | // }}
|
3780 |
|
3781 | // provider interfaces {{
|
3782 | /**
|
3783 | * A provider result represents the values a provider, like the [`HoverProvider`](#HoverProvider),
|
3784 | * may return. For once this is the actual result type `T`, like `Hover`, or a thenable that resolves
|
3785 | * to that type `T`. In addition, `null` and `undefined` can be returned - either directly or from a
|
3786 | * thenable.
|
3787 | *
|
3788 | * The snippets below are all valid implementations of the [`HoverProvider`](#HoverProvider):
|
3789 | *
|
3790 | * ```ts
|
3791 | * let a: HoverProvider = {
|
3792 | * provideHover(doc, pos, token): ProviderResult<Hover> {
|
3793 | * return new Hover('Hello World')
|
3794 | * }
|
3795 | * }
|
3796 | *
|
3797 | * let b: HoverProvider = {
|
3798 | * provideHover(doc, pos, token): ProviderResult<Hover> {
|
3799 | * return new Promise(resolve => {
|
3800 | * resolve(new Hover('Hello World'))
|
3801 | * })
|
3802 | * }
|
3803 | * }
|
3804 | *
|
3805 | * let c: HoverProvider = {
|
3806 | * provideHover(doc, pos, token): ProviderResult<Hover> {
|
3807 | * return; // undefined
|
3808 | * }
|
3809 | * }
|
3810 | * ```
|
3811 | */
|
3812 | export type ProviderResult<T> =
|
3813 | | T
|
3814 | | undefined
|
3815 | | null
|
3816 | | Thenable<T | undefined | null>
|
3817 |
|
3818 | /**
|
3819 | * Supported provider names.
|
3820 | */
|
3821 | export enum ProviderName {
|
3822 | FormatOnType = 'formatOnType',
|
3823 | Rename = 'rename',
|
3824 | OnTypeEdit = 'onTypeEdit',
|
3825 | DocumentLink = 'documentLink',
|
3826 | DocumentColor = 'documentColor',
|
3827 | FoldingRange = 'foldingRange',
|
3828 | Format = 'format',
|
3829 | CodeAction = 'codeAction',
|
3830 | FormatRange = 'formatRange',
|
3831 | Hover = 'hover',
|
3832 | Signature = 'signature',
|
3833 | WorkspaceSymbols = 'workspaceSymbols',
|
3834 | DocumentSymbol = 'documentSymbol',
|
3835 | DocumentHighlight = 'documentHighlight',
|
3836 | Definition = 'definition',
|
3837 | Declaration = 'declaration',
|
3838 | TypeDefinition = 'typeDefinition',
|
3839 | Reference = 'reference',
|
3840 | Implementation = 'implementation',
|
3841 | CodeLens = 'codeLens',
|
3842 | SelectionRange = 'selectionRange',
|
3843 | CallHierarchy = 'callHierarchy',
|
3844 | SemanticTokens = 'semanticTokens',
|
3845 | SemanticTokensRange = 'semanticTokensRange',
|
3846 | LinkedEditing = 'linkedEditing',
|
3847 | InlayHint = 'inlayHint',
|
3848 | InlineValue = 'inlineValue',
|
3849 | TypeHierarchy = 'typeHierarchy'
|
3850 | }
|
3851 |
|
3852 | /**
|
3853 | * The completion item provider interface defines the contract between extensions and
|
3854 | * [IntelliSense](https://code.visualstudio.com/docs/editor/intellisense).
|
3855 | *
|
3856 | * Providers can delay the computation of the [`detail`](#CompletionItem.detail)
|
3857 | * and [`documentation`](#CompletionItem.documentation) properties by implementing the
|
3858 | * [`resolveCompletionItem`](#CompletionItemProvider.resolveCompletionItem)-function. However, properties that
|
3859 | * are needed for the initial sorting and filtering, like `sortText`, `filterText`, `insertText`, and `range`, must
|
3860 | * not be changed during resolve.
|
3861 | *
|
3862 | * Providers are asked for completions either explicitly by a user gesture or -depending on the configuration-
|
3863 | * implicitly when typing words or trigger characters.
|
3864 | */
|
3865 | export interface CompletionItemProvider {
|
3866 | /**
|
3867 | * Provide completion items for the given position and document.
|
3868 | *
|
3869 | * @param document The document in which the command was invoked.
|
3870 | * @param position The position at which the command was invoked.
|
3871 | * @param token A cancellation token.
|
3872 | * @param context How the completion was triggered.
|
3873 | *
|
3874 | * @return An array of completions, a [completion list](#CompletionList), or a thenable that resolves to either.
|
3875 | * The lack of a result can be signaled by returning `undefined`, `null`, or an empty array.
|
3876 | */
|
3877 | provideCompletionItems(
|
3878 | document: LinesTextDocument,
|
3879 | position: Position,
|
3880 | token: CancellationToken,
|
3881 | context?: CompletionContext
|
3882 | ): ProviderResult<CompletionItem[] | CompletionList>
|
3883 |
|
3884 | /**
|
3885 | * Given a completion item fill in more data, like [doc-comment](#CompletionItem.documentation)
|
3886 | * or [details](#CompletionItem.detail).
|
3887 | *
|
3888 | * The editor will only resolve a completion item once.
|
3889 | *
|
3890 | * @param item A completion item currently active in the UI.
|
3891 | * @param token A cancellation token.
|
3892 | * @return The resolved completion item or a thenable that resolves to of such. It is OK to return the given
|
3893 | * `item`. When no result is returned, the given `item` will be used.
|
3894 | */
|
3895 | resolveCompletionItem?(
|
3896 | item: CompletionItem,
|
3897 | token: CancellationToken
|
3898 | ): ProviderResult<CompletionItem>
|
3899 | }
|
3900 |
|
3901 | /**
|
3902 | * The hover provider interface defines the contract between extensions and
|
3903 | * the [hover](https://code.visualstudio.com/docs/editor/intellisense)-feature.
|
3904 | */
|
3905 | export interface HoverProvider {
|
3906 | /**
|
3907 | * Provide a hover for the given position and document. Multiple hovers at the same
|
3908 | * position will be merged by the editor. A hover can have a range which defaults
|
3909 | * to the word range at the position when omitted.
|
3910 | *
|
3911 | * @param document The document in which the command was invoked.
|
3912 | * @param position The position at which the command was invoked.
|
3913 | * @param token A cancellation token.
|
3914 | * @return A hover or a thenable that resolves to such. The lack of a result can be
|
3915 | * signaled by returning `undefined` or `null`.
|
3916 | */
|
3917 | provideHover(
|
3918 | document: LinesTextDocument,
|
3919 | position: Position,
|
3920 | token: CancellationToken
|
3921 | ): ProviderResult<Hover>
|
3922 | }
|
3923 |
|
3924 | /**
|
3925 | * The definition provider interface defines the contract between extensions and
|
3926 | * the [go to definition](https://code.visualstudio.com/docs/editor/editingevolved#_go-to-definition)
|
3927 | * and peek definition features.
|
3928 | */
|
3929 | export interface DefinitionProvider {
|
3930 | /**
|
3931 | * Provide the definition of the symbol at the given position and document.
|
3932 | *
|
3933 | * @param document The document in which the command was invoked.
|
3934 | * @param position The position at which the command was invoked.
|
3935 | * @param token A cancellation token.
|
3936 | * @return A definition or a thenable that resolves to such. The lack of a result can be
|
3937 | * signaled by returning `undefined` or `null`.
|
3938 | */
|
3939 | provideDefinition(
|
3940 | document: LinesTextDocument,
|
3941 | position: Position,
|
3942 | token: CancellationToken
|
3943 | ): ProviderResult<Definition | DefinitionLink[]>
|
3944 | }
|
3945 |
|
3946 | /**
|
3947 | * The definition provider interface defines the contract between extensions and
|
3948 | * the [go to definition](https://code.visualstudio.com/docs/editor/editingevolved#_go-to-definition)
|
3949 | * and peek definition features.
|
3950 | */
|
3951 | export interface DeclarationProvider {
|
3952 | /**
|
3953 | * Provide the declaration of the symbol at the given position and document.
|
3954 | */
|
3955 | provideDeclaration(
|
3956 | document: LinesTextDocument,
|
3957 | position: Position,
|
3958 | token: CancellationToken
|
3959 | ): ProviderResult<Definition | DefinitionLink[]>
|
3960 | }
|
3961 |
|
3962 | /**
|
3963 | * The signature help provider interface defines the contract between extensions and
|
3964 | * the [parameter hints](https://code.visualstudio.com/docs/editor/intellisense)-feature.
|
3965 | */
|
3966 | export interface SignatureHelpProvider {
|
3967 | /**
|
3968 | * Provide help for the signature at the given position and document.
|
3969 | *
|
3970 | * @param document The document in which the command was invoked.
|
3971 | * @param position The position at which the command was invoked.
|
3972 | * @param token A cancellation token.
|
3973 | * @return Signature help or a thenable that resolves to such. The lack of a result can be
|
3974 | * signaled by returning `undefined` or `null`.
|
3975 | */
|
3976 | provideSignatureHelp(
|
3977 | document: LinesTextDocument,
|
3978 | position: Position,
|
3979 | token: CancellationToken,
|
3980 | context: SignatureHelpContext
|
3981 | ): ProviderResult<SignatureHelp>
|
3982 | }
|
3983 |
|
3984 | /**
|
3985 | * The type definition provider defines the contract between extensions and
|
3986 | * the go to type definition feature.
|
3987 | */
|
3988 | export interface TypeDefinitionProvider {
|
3989 | /**
|
3990 | * Provide the type definition of the symbol at the given position and document.
|
3991 | *
|
3992 | * @param document The document in which the command was invoked.
|
3993 | * @param position The position at which the command was invoked.
|
3994 | * @param token A cancellation token.
|
3995 | * @return A definition or a thenable that resolves to such. The lack of a result can be
|
3996 | * signaled by returning `undefined` or `null`.
|
3997 | */
|
3998 | provideTypeDefinition(
|
3999 | document: LinesTextDocument,
|
4000 | position: Position,
|
4001 | token: CancellationToken
|
4002 | ): ProviderResult<Definition | DefinitionLink[]>
|
4003 | }
|
4004 |
|
4005 | /**
|
4006 | * Value-object that contains additional information when
|
4007 | * requesting references.
|
4008 | */
|
4009 | export interface ReferenceContext {
|
4010 | /**
|
4011 | * Include the declaration of the current symbol.
|
4012 | */
|
4013 | includeDeclaration: boolean
|
4014 | }
|
4015 |
|
4016 | /**
|
4017 | * The reference provider interface defines the contract between extensions and
|
4018 | * the [find references](https://code.visualstudio.com/docs/editor/editingevolved#_peek)-feature.
|
4019 | */
|
4020 | export interface ReferenceProvider {
|
4021 | /**
|
4022 | * Provide a set of project-wide references for the given position and document.
|
4023 | *
|
4024 | * @param document The document in which the command was invoked.
|
4025 | * @param position The position at which the command was invoked.
|
4026 | * @param context
|
4027 | * @param token A cancellation token.
|
4028 | * @return An array of locations or a thenable that resolves to such. The lack of a result can be
|
4029 | * signaled by returning `undefined`, `null`, or an empty array.
|
4030 | */
|
4031 | provideReferences(
|
4032 | document: LinesTextDocument,
|
4033 | position: Position,
|
4034 | context: ReferenceContext,
|
4035 | token: CancellationToken
|
4036 | ): ProviderResult<Location[]>
|
4037 | }
|
4038 |
|
4039 | /**
|
4040 | * Folding context (for future use)
|
4041 | */
|
4042 | export interface FoldingContext {}
|
4043 |
|
4044 | /**
|
4045 | * The folding range provider interface defines the contract between extensions and
|
4046 | * [Folding](https://code.visualstudio.com/docs/editor/codebasics#_folding) in the editor.
|
4047 | */
|
4048 | export interface FoldingRangeProvider {
|
4049 | /**
|
4050 | * Returns a list of folding ranges or null and undefined if the provider
|
4051 | * does not want to participate or was cancelled.
|
4052 | *
|
4053 | * @param document The document in which the command was invoked.
|
4054 | * @param context Additional context information (for future use)
|
4055 | * @param token A cancellation token.
|
4056 | */
|
4057 | provideFoldingRanges(
|
4058 | document: LinesTextDocument,
|
4059 | context: FoldingContext,
|
4060 | token: CancellationToken
|
4061 | ): ProviderResult<FoldingRange[]>
|
4062 | }
|
4063 |
|
4064 | /**
|
4065 | * The document symbol provider interface defines the contract between extensions and
|
4066 | * the [go to symbol](https://code.visualstudio.com/docs/editor/editingevolved#_go-to-symbol)-feature.
|
4067 | */
|
4068 | export interface DocumentSymbolProvider {
|
4069 | /**
|
4070 | * Provide symbol information for the given document.
|
4071 | *
|
4072 | * @param document The document in which the command was invoked.
|
4073 | * @param token A cancellation token.
|
4074 | * @return An array of document highlights or a thenable that resolves to such. The lack of a result can be
|
4075 | * signaled by returning `undefined`, `null`, or an empty array.
|
4076 | */
|
4077 | provideDocumentSymbols(
|
4078 | document: LinesTextDocument,
|
4079 | token: CancellationToken
|
4080 | ): ProviderResult<SymbolInformation[] | DocumentSymbol[]>
|
4081 | }
|
4082 |
|
4083 | /**
|
4084 | * The implementation provider interface defines the contract between extensions and
|
4085 | * the go to implementation feature.
|
4086 | */
|
4087 | export interface ImplementationProvider {
|
4088 | /**
|
4089 | * Provide the implementations of the symbol at the given position and document.
|
4090 | *
|
4091 | * @param document The document in which the command was invoked.
|
4092 | * @param position The position at which the command was invoked.
|
4093 | * @param token A cancellation token.
|
4094 | * @return A definition or a thenable that resolves to such. The lack of a result can be
|
4095 | * signaled by returning `undefined` or `null`.
|
4096 | */
|
4097 | provideImplementation(
|
4098 | document: LinesTextDocument,
|
4099 | position: Position,
|
4100 | token: CancellationToken
|
4101 | ): ProviderResult<Definition | DefinitionLink[]>
|
4102 | }
|
4103 |
|
4104 | /**
|
4105 | * The workspace symbol provider interface defines the contract between extensions and
|
4106 | * the [symbol search](https://code.visualstudio.com/docs/editor/editingevolved#_open-symbol-by-name)-feature.
|
4107 | */
|
4108 | export interface WorkspaceSymbolProvider {
|
4109 | /**
|
4110 | * Project-wide search for a symbol matching the given query string. It is up to the provider
|
4111 | * how to search given the query string, like substring, indexOf etc. To improve performance implementors can
|
4112 | * skip the [location](#SymbolInformation.location) of symbols and implement `resolveWorkspaceSymbol` to do that
|
4113 | * later.
|
4114 | *
|
4115 | * The `query`-parameter should be interpreted in a *relaxed way* as the editor will apply its own highlighting
|
4116 | * and scoring on the results. A good rule of thumb is to match case-insensitive and to simply check that the
|
4117 | * characters of *query* appear in their order in a candidate symbol. Don't use prefix, substring, or similar
|
4118 | * strict matching.
|
4119 | *
|
4120 | * @param query A non-empty query string.
|
4121 | * @param token A cancellation token.
|
4122 | * @return An array of document highlights or a thenable that resolves to such. The lack of a result can be
|
4123 | * signaled by returning `undefined`, `null`, or an empty array.
|
4124 | */
|
4125 | provideWorkspaceSymbols(
|
4126 | query: string,
|
4127 | token: CancellationToken
|
4128 | ): ProviderResult<SymbolInformation[]>
|
4129 |
|
4130 | /**
|
4131 | * Given a symbol fill in its [location](#SymbolInformation.location). This method is called whenever a symbol
|
4132 | * is selected in the UI. Providers can implement this method and return incomplete symbols from
|
4133 | * [`provideWorkspaceSymbols`](#WorkspaceSymbolProvider.provideWorkspaceSymbols) which often helps to improve
|
4134 | * performance.
|
4135 | *
|
4136 | * @param symbol The symbol that is to be resolved. Guaranteed to be an instance of an object returned from an
|
4137 | * earlier call to `provideWorkspaceSymbols`.
|
4138 | * @param token A cancellation token.
|
4139 | * @return The resolved symbol or a thenable that resolves to that. When no result is returned,
|
4140 | * the given `symbol` is used.
|
4141 | */
|
4142 | resolveWorkspaceSymbol?(
|
4143 | symbol: SymbolInformation,
|
4144 | token: CancellationToken
|
4145 | ): ProviderResult<SymbolInformation>
|
4146 | }
|
4147 |
|
4148 | /**
|
4149 | * The rename provider interface defines the contract between extensions and
|
4150 | * the [rename](https://code.visualstudio.com/docs/editor/editingevolved#_rename-symbol)-feature.
|
4151 | */
|
4152 | export interface RenameProvider {
|
4153 | /**
|
4154 | * Provide an edit that describes changes that have to be made to one
|
4155 | * or many resources to rename a symbol to a different name.
|
4156 | *
|
4157 | * @param document The document in which the command was invoked.
|
4158 | * @param position The position at which the command was invoked.
|
4159 | * @param newName The new name of the symbol. If the given name is not valid, the provider must return a rejected promise.
|
4160 | * @param token A cancellation token.
|
4161 | * @return A workspace edit or a thenable that resolves to such. The lack of a result can be
|
4162 | * signaled by returning `undefined` or `null`.
|
4163 | */
|
4164 | provideRenameEdits(
|
4165 | document: LinesTextDocument,
|
4166 | position: Position,
|
4167 | newName: string,
|
4168 | token: CancellationToken
|
4169 | ): ProviderResult<WorkspaceEdit>
|
4170 |
|
4171 | /**
|
4172 | * Optional function for resolving and validating a position *before* running rename. The result can
|
4173 | * be a range or a range and a placeholder text. The placeholder text should be the identifier of the symbol
|
4174 | * which is being renamed - when omitted the text in the returned range is used.
|
4175 | *
|
4176 | * @param document The document in which rename will be invoked.
|
4177 | * @param position The position at which rename will be invoked.
|
4178 | * @param token A cancellation token.
|
4179 | * @return The range or range and placeholder text of the identifier that is to be renamed. The lack of a result can signaled by returning `undefined` or `null`.
|
4180 | */
|
4181 | prepareRename?(
|
4182 | document: LinesTextDocument,
|
4183 | position: Position,
|
4184 | token: CancellationToken
|
4185 | ): ProviderResult<Range | { range: Range; placeholder: string }>
|
4186 | }
|
4187 |
|
4188 | /**
|
4189 | * The document formatting provider interface defines the contract between extensions and
|
4190 | * the formatting-feature.
|
4191 | */
|
4192 | export interface DocumentFormattingEditProvider {
|
4193 | /**
|
4194 | * Provide formatting edits for a whole document.
|
4195 | *
|
4196 | * @param document The document in which the command was invoked.
|
4197 | * @param options Options controlling formatting.
|
4198 | * @param token A cancellation token.
|
4199 | * @return A set of text edits or a thenable that resolves to such. The lack of a result can be
|
4200 | * signaled by returning `undefined`, `null`, or an empty array.
|
4201 | */
|
4202 | provideDocumentFormattingEdits(
|
4203 | document: LinesTextDocument,
|
4204 | options: FormattingOptions,
|
4205 | token: CancellationToken
|
4206 | ): ProviderResult<TextEdit[]>
|
4207 | }
|
4208 |
|
4209 | /**
|
4210 | * The document formatting provider interface defines the contract between extensions and
|
4211 | * the formatting-feature.
|
4212 | */
|
4213 | export interface DocumentRangeFormattingEditProvider {
|
4214 | /**
|
4215 | * Provide formatting edits for a range in a document.
|
4216 | *
|
4217 | * The given range is a hint and providers can decide to format a smaller
|
4218 | * or larger range. Often this is done by adjusting the start and end
|
4219 | * of the range to full syntax nodes.
|
4220 | *
|
4221 | * @param document The document in which the command was invoked.
|
4222 | * @param range The range which should be formatted.
|
4223 | * @param options Options controlling formatting.
|
4224 | * @param token A cancellation token.
|
4225 | * @return A set of text edits or a thenable that resolves to such. The lack of a result can be
|
4226 | * signaled by returning `undefined`, `null`, or an empty array.
|
4227 | */
|
4228 | provideDocumentRangeFormattingEdits(
|
4229 | document: LinesTextDocument,
|
4230 | range: Range,
|
4231 | options: FormattingOptions,
|
4232 | token: CancellationToken
|
4233 | ): ProviderResult<TextEdit[]>
|
4234 | }
|
4235 |
|
4236 | /**
|
4237 | * The code action interface defines the contract between extensions and
|
4238 | * the [light bulb](https://code.visualstudio.com/docs/editor/editingevolved#_code-action) feature.
|
4239 | *
|
4240 | * A code action can be any command that is [known](#commands.getCommands) to the system.
|
4241 | */
|
4242 | export interface CodeActionProvider<T extends CodeAction = CodeAction> {
|
4243 | /**
|
4244 | * Provide commands for the given document and range.
|
4245 | *
|
4246 | * @param document The document in which the command was invoked.
|
4247 | * @param range The selector or range for which the command was invoked. This will always be a selection if
|
4248 | * there is a currently active editor.
|
4249 | * @param context Context carrying additional information.
|
4250 | * @param token A cancellation token.
|
4251 | * @return An array of commands, quick fixes, or refactorings or a thenable of such. The lack of a result can be
|
4252 | * signaled by returning `undefined`, `null`, or an empty array.
|
4253 | */
|
4254 | provideCodeActions(
|
4255 | document: LinesTextDocument,
|
4256 | range: Range,
|
4257 | context: CodeActionContext,
|
4258 | token: CancellationToken
|
4259 | ): ProviderResult<(Command | CodeAction)[]>
|
4260 |
|
4261 | /**
|
4262 | * Given a code action fill in its [`edit`](#CodeAction.edit)-property. Changes to
|
4263 | * all other properties, like title, are ignored. A code action that has an edit
|
4264 | * will not be resolved.
|
4265 | *
|
4266 | * @param codeAction A code action.
|
4267 | * @param token A cancellation token.
|
4268 | * @return The resolved code action or a thenable that resolves to such. It is OK to return the given
|
4269 | * `item`. When no result is returned, the given `item` will be used.
|
4270 | */
|
4271 | resolveCodeAction?(codeAction: T, token: CancellationToken): ProviderResult<T>
|
4272 | }
|
4273 |
|
4274 | /**
|
4275 | * Metadata about the type of code actions that a [CodeActionProvider](#CodeActionProvider) providers
|
4276 | */
|
4277 | export interface CodeActionProviderMetadata {
|
4278 | /**
|
4279 | * [CodeActionKinds](#CodeActionKind) that this provider may return.
|
4280 | *
|
4281 | * The list of kinds may be generic, such as `CodeActionKind.Refactor`, or the provider
|
4282 | * may list our every specific kind they provide, such as `CodeActionKind.Refactor.Extract.append('function`)`
|
4283 | */
|
4284 | readonly providedCodeActionKinds?: ReadonlyArray<string>
|
4285 | }
|
4286 |
|
4287 | /**
|
4288 | * The document highlight provider interface defines the contract between extensions and
|
4289 | * the word-highlight-feature.
|
4290 | */
|
4291 | export interface DocumentHighlightProvider {
|
4292 |
|
4293 | /**
|
4294 | * Provide a set of document highlights, like all occurrences of a variable or
|
4295 | * all exit-points of a function.
|
4296 | *
|
4297 | * @param document The document in which the command was invoked.
|
4298 | * @param position The position at which the command was invoked.
|
4299 | * @param token A cancellation token.
|
4300 | * @return An array of document highlights or a thenable that resolves to such. The lack of a result can be
|
4301 | * signaled by returning `undefined`, `null`, or an empty array.
|
4302 | */
|
4303 | provideDocumentHighlights(
|
4304 | document: LinesTextDocument,
|
4305 | position: Position,
|
4306 | token: CancellationToken
|
4307 | ): ProviderResult<DocumentHighlight[]>
|
4308 | }
|
4309 |
|
4310 | /**
|
4311 | * The document link provider defines the contract between extensions and feature of showing
|
4312 | * links in the editor.
|
4313 | */
|
4314 | export interface DocumentLinkProvider {
|
4315 |
|
4316 | /**
|
4317 | * Provide links for the given document. Note that the editor ships with a default provider that detects
|
4318 | * `http(s)` and `file` links.
|
4319 | *
|
4320 | * @param document The document in which the command was invoked.
|
4321 | * @param token A cancellation token.
|
4322 | * @return An array of [document links](#DocumentLink) or a thenable that resolves to such. The lack of a result
|
4323 | * can be signaled by returning `undefined`, `null`, or an empty array.
|
4324 | */
|
4325 | provideDocumentLinks(document: LinesTextDocument, token: CancellationToken): ProviderResult<DocumentLink[]>
|
4326 |
|
4327 | /**
|
4328 | * Given a link fill in its [target](#DocumentLink.target). This method is called when an incomplete
|
4329 | * link is selected in the UI. Providers can implement this method and return incomple links
|
4330 | * (without target) from the [`provideDocumentLinks`](#DocumentLinkProvider.provideDocumentLinks) method which
|
4331 | * often helps to improve performance.
|
4332 | *
|
4333 | * @param link The link that is to be resolved.
|
4334 | * @param token A cancellation token.
|
4335 | */
|
4336 | resolveDocumentLink?(link: DocumentLink, token: CancellationToken): ProviderResult<DocumentLink>
|
4337 | }
|
4338 |
|
4339 | /**
|
4340 | * A code lens provider adds [commands](#Command) to source text. The commands will be shown
|
4341 | * as dedicated horizontal lines in between the source text.
|
4342 | */
|
4343 | export interface CodeLensProvider {
|
4344 |
|
4345 | /**
|
4346 | * Compute a list of [lenses](#CodeLens). This call should return as fast as possible and if
|
4347 | * computing the commands is expensive implementors should only return code lens objects with the
|
4348 | * range set and implement [resolve](#CodeLensProvider.resolveCodeLens).
|
4349 | *
|
4350 | * @param document The document in which the command was invoked.
|
4351 | * @param token A cancellation token.
|
4352 | * @return An array of code lenses or a thenable that resolves to such. The lack of a result can be
|
4353 | * signaled by returning `undefined`, `null`, or an empty array.
|
4354 | */
|
4355 | provideCodeLenses(document: LinesTextDocument, token: CancellationToken): ProviderResult<CodeLens[]>
|
4356 |
|
4357 | /**
|
4358 | * This function will be called for each visible code lens, usually when scrolling and after
|
4359 | * calls to [compute](#CodeLensProvider.provideCodeLenses)-lenses.
|
4360 | *
|
4361 | * @param codeLens code lens that must be resolved.
|
4362 | * @param token A cancellation token.
|
4363 | * @return The given, resolved code lens or thenable that resolves to such.
|
4364 | */
|
4365 | resolveCodeLens?(codeLens: CodeLens, token: CancellationToken): ProviderResult<CodeLens>
|
4366 | }
|
4367 |
|
4368 | /**
|
4369 | * The document formatting provider interface defines the contract between extensions and
|
4370 | * the formatting-feature.
|
4371 | */
|
4372 | export interface OnTypeFormattingEditProvider {
|
4373 |
|
4374 | /**
|
4375 | * Provide formatting edits after a character has been typed.
|
4376 | *
|
4377 | * The given position and character should hint to the provider
|
4378 | * what range the position to expand to, like find the matching `{`
|
4379 | * when `}` has been entered.
|
4380 | *
|
4381 | * @param document The document in which the command was invoked.
|
4382 | * @param position The position at which the command was invoked.
|
4383 | * @param ch The character that has been typed.
|
4384 | * @param options Options controlling formatting.
|
4385 | * @param token A cancellation token.
|
4386 | * @return A set of text edits or a thenable that resolves to such. The lack of a result can be
|
4387 | * signaled by returning `undefined`, `null`, or an empty array.
|
4388 | */
|
4389 | provideOnTypeFormattingEdits(document: LinesTextDocument, position: Position, ch: string, options: FormattingOptions, token: CancellationToken): ProviderResult<TextEdit[]>
|
4390 | }
|
4391 |
|
4392 | /**
|
4393 | * The document color provider defines the contract between extensions and feature of
|
4394 | * picking and modifying colors in the editor.
|
4395 | */
|
4396 | export interface DocumentColorProvider {
|
4397 |
|
4398 | /**
|
4399 | * Provide colors for the given document.
|
4400 | *
|
4401 | * @param document The document in which the command was invoked.
|
4402 | * @param token A cancellation token.
|
4403 | * @return An array of [color information](#ColorInformation) or a thenable that resolves to such. The lack of a result
|
4404 | * can be signaled by returning `undefined`, `null`, or an empty array.
|
4405 | */
|
4406 | provideDocumentColors(document: LinesTextDocument, token: CancellationToken): ProviderResult<ColorInformation[]>
|
4407 |
|
4408 | /**
|
4409 | * Provide [representations](#ColorPresentation) for a color.
|
4410 | *
|
4411 | * @param color The color to show and insert.
|
4412 | * @param context A context object with additional information
|
4413 | * @param token A cancellation token.
|
4414 | * @return An array of color presentations or a thenable that resolves to such. The lack of a result
|
4415 | * can be signaled by returning `undefined`, `null`, or an empty array.
|
4416 | */
|
4417 | provideColorPresentations(color: Color, context: { document: LinesTextDocument; range: Range }, token: CancellationToken): ProviderResult<ColorPresentation[]>
|
4418 | }
|
4419 |
|
4420 | export interface TextDocumentContentProvider {
|
4421 |
|
4422 | /**
|
4423 | * An event to signal a resource has changed.
|
4424 | */
|
4425 | onDidChange?: Event<Uri>
|
4426 |
|
4427 | /**
|
4428 | * Provide textual content for a given uri.
|
4429 | *
|
4430 | * The editor will use the returned string-content to create a readonly
|
4431 | * [document](#LinesTextDocument). Resources allocated should be released when
|
4432 | * the corresponding document has been [closed](#workspace.onDidCloseTextDocument).
|
4433 | *
|
4434 | * @param uri An uri which scheme matches the scheme this provider was [registered](#workspace.registerTextDocumentContentProvider) for.
|
4435 | * @param token A cancellation token.
|
4436 | * @return A string or a thenable that resolves to such.
|
4437 | */
|
4438 | provideTextDocumentContent(uri: Uri, token: CancellationToken): ProviderResult<string>
|
4439 | }
|
4440 |
|
4441 | export interface SelectionRangeProvider {
|
4442 | /**
|
4443 | * Provide selection ranges starting at a given position. The first range must [contain](#Range.contains)
|
4444 | * position and subsequent ranges must contain the previous range.
|
4445 | */
|
4446 | provideSelectionRanges(document: LinesTextDocument, positions: Position[], token: CancellationToken): ProviderResult<SelectionRange[]>
|
4447 | }
|
4448 |
|
4449 | /**
|
4450 | * The call hierarchy provider interface describes the contract between extensions
|
4451 | * and the call hierarchy feature which allows to browse calls and caller of function,
|
4452 | * methods, constructor etc.
|
4453 | */
|
4454 | export interface CallHierarchyProvider {
|
4455 |
|
4456 | /**
|
4457 | * Bootstraps call hierarchy by returning the item that is denoted by the given document
|
4458 | * and position. This item will be used as entry into the call graph. Providers should
|
4459 | * return `undefined` or `null` when there is no item at the given location.
|
4460 | *
|
4461 | * @param document The document in which the command was invoked.
|
4462 | * @param position The position at which the command was invoked.
|
4463 | * @param token A cancellation token.
|
4464 | * @returns A call hierarchy item or a thenable that resolves to such. The lack of a result can be
|
4465 | * signaled by returning `undefined` or `null`.
|
4466 | */
|
4467 | prepareCallHierarchy(document: LinesTextDocument, position: Position, token: CancellationToken): ProviderResult<CallHierarchyItem | CallHierarchyItem[]>
|
4468 |
|
4469 | /**
|
4470 | * Provide all incoming calls for an item, e.g all callers for a method. In graph terms this describes directed
|
4471 | * and annotated edges inside the call graph, e.g the given item is the starting node and the result is the nodes
|
4472 | * that can be reached.
|
4473 | *
|
4474 | * @param item The hierarchy item for which incoming calls should be computed.
|
4475 | * @param token A cancellation token.
|
4476 | * @returns A set of incoming calls or a thenable that resolves to such. The lack of a result can be
|
4477 | * signaled by returning `undefined` or `null`.
|
4478 | */
|
4479 | provideCallHierarchyIncomingCalls(item: CallHierarchyItem, token: CancellationToken): ProviderResult<CallHierarchyIncomingCall[]>
|
4480 |
|
4481 | /**
|
4482 | * Provide all outgoing calls for an item, e.g call calls to functions, methods, or constructors from the given item. In
|
4483 | * graph terms this describes directed and annotated edges inside the call graph, e.g the given item is the starting
|
4484 | * node and the result is the nodes that can be reached.
|
4485 | *
|
4486 | * @param item The hierarchy item for which outgoing calls should be computed.
|
4487 | * @param token A cancellation token.
|
4488 | * @returns A set of outgoing calls or a thenable that resolves to such. The lack of a result can be
|
4489 | * signaled by returning `undefined` or `null`.
|
4490 | */
|
4491 | provideCallHierarchyOutgoingCalls(item: CallHierarchyItem, token: CancellationToken): ProviderResult<CallHierarchyOutgoingCall[]>
|
4492 | }
|
4493 |
|
4494 | /**
|
4495 | * The document semantic tokens provider interface defines the contract between extensions and
|
4496 | * semantic tokens.
|
4497 | */
|
4498 | export interface DocumentSemanticTokensProvider {
|
4499 | /**
|
4500 | * An optional event to signal that the semantic tokens from this provider have changed.
|
4501 | */
|
4502 | // TODO: SemantiTokens
|
4503 | onDidChangeSemanticTokens?: Event<void>
|
4504 |
|
4505 | /**
|
4506 | * Tokens in a file are represented as an array of integers. The position of each token is expressed relative to
|
4507 | * the token before it, because most tokens remain stable relative to each other when edits are made in a file.
|
4508 | *
|
4509 | * ---
|
4510 | * In short, each token takes 5 integers to represent, so a specific token `i` in the file consists of the following array indices:
|
4511 | *
|
4512 | * - at index `5*i` - `deltaLine`: token line number, relative to the previous token
|
4513 | * - at index `5*i+1` - `deltaStart`: token start character, relative to the previous token (relative to 0 or the previous token's start if they are on the same line)
|
4514 | * - at index `5*i+2` - `length`: the length of the token. A token cannot be multiline.
|
4515 | * - at index `5*i+3` - `tokenType`: will be looked up in `SemanticTokensLegend.tokenTypes`. We currently ask that `tokenType` < 65536.
|
4516 | * - at index `5*i+4` - `tokenModifiers`: each set bit will be looked up in `SemanticTokensLegend.tokenModifiers`
|
4517 | *
|
4518 | * ---
|
4519 | * ### How to encode tokens
|
4520 | *
|
4521 | * Here is an example for encoding a file with 3 tokens in a uint32 array:
|
4522 | * ```
|
4523 | * { line: 2, startChar: 5, length: 3, tokenType: "property", tokenModifiers: ["private", "static"] },
|
4524 | * { line: 2, startChar: 10, length: 4, tokenType: "type", tokenModifiers: [] },
|
4525 | * { line: 5, startChar: 2, length: 7, tokenType: "class", tokenModifiers: [] }
|
4526 | * ```
|
4527 | *
|
4528 | * 1. First of all, a legend must be devised. This legend must be provided up-front and capture all possible token types.
|
4529 | * For this example, we will choose the following legend which must be passed in when registering the provider:
|
4530 | * ```
|
4531 | * tokenTypes: ['property', 'type', 'class'],
|
4532 | * tokenModifiers: ['private', 'static']
|
4533 | * ```
|
4534 | *
|
4535 | * 2. The first transformation step is to encode `tokenType` and `tokenModifiers` as integers using the legend. Token types are looked
|
4536 | * up by index, so a `tokenType` value of `1` means `tokenTypes[1]`. Multiple token modifiers can be set by using bit flags,
|
4537 | * so a `tokenModifier` value of `3` is first viewed as binary `0b00000011`, which means `[tokenModifiers[0], tokenModifiers[1]]` because
|
4538 | * bits 0 and 1 are set. Using this legend, the tokens now are:
|
4539 | * ```
|
4540 | * { line: 2, startChar: 5, length: 3, tokenType: 0, tokenModifiers: 3 },
|
4541 | * { line: 2, startChar: 10, length: 4, tokenType: 1, tokenModifiers: 0 },
|
4542 | * { line: 5, startChar: 2, length: 7, tokenType: 2, tokenModifiers: 0 }
|
4543 | * ```
|
4544 | *
|
4545 | * 3. The next step is to represent each token relative to the previous token in the file. In this case, the second token
|
4546 | * is on the same line as the first token, so the `startChar` of the second token is made relative to the `startChar`
|
4547 | * of the first token, so it will be `10 - 5`. The third token is on a different line than the second token, so the
|
4548 | * `startChar` of the third token will not be altered:
|
4549 | * ```
|
4550 | * { deltaLine: 2, deltaStartChar: 5, length: 3, tokenType: 0, tokenModifiers: 3 },
|
4551 | * { deltaLine: 0, deltaStartChar: 5, length: 4, tokenType: 1, tokenModifiers: 0 },
|
4552 | * { deltaLine: 3, deltaStartChar: 2, length: 7, tokenType: 2, tokenModifiers: 0 }
|
4553 | * ```
|
4554 | *
|
4555 | * 4. Finally, the last step is to inline each of the 5 fields for a token in a single array, which is a memory friendly representation:
|
4556 | * ```
|
4557 | * // 1st token, 2nd token, 3rd token
|
4558 | * [ 2,5,3,0,3, 0,5,4,1,0, 3,2,7,2,0 ]
|
4559 | * ```
|
4560 | *
|
4561 | * @see [SemanticTokensBuilder](#SemanticTokensBuilder) for a helper to encode tokens as integers.
|
4562 | * *NOTE*: When doing edits, it is possible that multiple edits occur until VS Code decides to invoke the semantic tokens provider.
|
4563 | * *NOTE*: If the provider cannot temporarily compute semantic tokens, it can indicate this by throwing an error with the message 'Busy'.
|
4564 | */
|
4565 | provideDocumentSemanticTokens(document: LinesTextDocument, token: CancellationToken): ProviderResult<SemanticTokens>
|
4566 |
|
4567 | /**
|
4568 | * Instead of always returning all the tokens in a file, it is possible for a `DocumentSemanticTokensProvider` to implement
|
4569 | * this method (`provideDocumentSemanticTokensEdits`) and then return incremental updates to the previously provided semantic tokens.
|
4570 | *
|
4571 | * ---
|
4572 | * ### How tokens change when the document changes
|
4573 | *
|
4574 | * Suppose that `provideDocumentSemanticTokens` has previously returned the following semantic tokens:
|
4575 | * ```
|
4576 | * // 1st token, 2nd token, 3rd token
|
4577 | * [ 2,5,3,0,3, 0,5,4,1,0, 3,2,7,2,0 ]
|
4578 | * ```
|
4579 | *
|
4580 | * Also suppose that after some edits, the new semantic tokens in a file are:
|
4581 | * ```
|
4582 | * // 1st token, 2nd token, 3rd token
|
4583 | * [ 3,5,3,0,3, 0,5,4,1,0, 3,2,7,2,0 ]
|
4584 | * ```
|
4585 | * It is possible to express these new tokens in terms of an edit applied to the previous tokens:
|
4586 | * ```
|
4587 | * [ 2,5,3,0,3, 0,5,4,1,0, 3,2,7,2,0 ] // old tokens
|
4588 | * [ 3,5,3,0,3, 0,5,4,1,0, 3,2,7,2,0 ] // new tokens
|
4589 | *
|
4590 | * edit: { start: 0, deleteCount: 1, data: [3] } // replace integer at offset 0 with 3
|
4591 | * ```
|
4592 | *
|
4593 | * *NOTE*: If the provider cannot compute `SemanticTokensEdits`, it can "give up" and return all the tokens in the document again.
|
4594 | * *NOTE*: All edits in `SemanticTokensEdits` contain indices in the old integers array, so they all refer to the previous result state.
|
4595 | */
|
4596 | provideDocumentSemanticTokensEdits?(document: LinesTextDocument, previousResultId: string, token: CancellationToken): ProviderResult<SemanticTokens | SemanticTokensDelta>
|
4597 | }
|
4598 |
|
4599 | /**
|
4600 | * The document range semantic tokens provider interface defines the contract between extensions and
|
4601 | * semantic tokens.
|
4602 | */
|
4603 | export interface DocumentRangeSemanticTokensProvider {
|
4604 | /**
|
4605 | * @see [provideDocumentSemanticTokens](#DocumentSemanticTokensProvider.provideDocumentSemanticTokens).
|
4606 | */
|
4607 | provideDocumentRangeSemanticTokens(document: LinesTextDocument, range: Range, token: CancellationToken): ProviderResult<SemanticTokens>
|
4608 | }
|
4609 |
|
4610 | export interface LinkedEditingRangeProvider {
|
4611 | /**
|
4612 | * For a given position in a document, returns the range of the symbol at the position and all ranges
|
4613 | * that have the same content. A change to one of the ranges can be applied to all other ranges if the new content
|
4614 | * is valid. An optional word pattern can be returned with the result to describe valid contents.
|
4615 | * If no result-specific word pattern is provided, the word pattern from the language configuration is used.
|
4616 | *
|
4617 | * @param document The document in which the provider was invoked.
|
4618 | * @param position The position at which the provider was invoked.
|
4619 | * @param token A cancellation token.
|
4620 | * @return A list of ranges that can be edited together
|
4621 | */
|
4622 | provideLinkedEditingRanges(document: LinesTextDocument, position: Position, token: CancellationToken): ProviderResult<LinkedEditingRanges>
|
4623 | }
|
4624 |
|
4625 | /**
|
4626 | * The inlay hints provider interface defines the contract between extensions and
|
4627 | * the inlay hints feature.
|
4628 | */
|
4629 | export interface InlayHintsProvider<T extends InlayHint = InlayHint> {
|
4630 |
|
4631 | /**
|
4632 | * An optional event to signal that inlay hints from this provider have changed.
|
4633 | */
|
4634 | onDidChangeInlayHints?: Event<void>
|
4635 |
|
4636 | /**
|
4637 | * Provide inlay hints for the given range and document.
|
4638 | *
|
4639 | * *Note* that inlay hints that are not {@link Range.contains contained} by the given range are ignored.
|
4640 | *
|
4641 | * @param document The document in which the command was invoked.
|
4642 | * @param range The range for which inlay hints should be computed.
|
4643 | * @param token A cancellation token.
|
4644 | * @return An array of inlay hints or a thenable that resolves to such.
|
4645 | */
|
4646 | provideInlayHints(document: TextDocument, range: Range, token: CancellationToken): ProviderResult<T[]>
|
4647 |
|
4648 | /**
|
4649 | * Given an inlay hint fill in {@link InlayHint.tooltip tooltip}, {@link InlayHint.textEdits text edits},
|
4650 | * or complete label {@link InlayHintLabelPart parts}.
|
4651 | *
|
4652 | * *Note* that the editor will resolve an inlay hint at most once.
|
4653 | *
|
4654 | * @param hint An inlay hint.
|
4655 | * @param token A cancellation token.
|
4656 | * @return The resolved inlay hint or a thenable that resolves to such. It is OK to return the given `item`. When no result is returned, the given `item` will be used.
|
4657 | */
|
4658 | resolveInlayHint?(hint: T, token: CancellationToken): ProviderResult<T>
|
4659 | }
|
4660 | // }}
|
4661 |
|
4662 | // Classes {{
|
4663 | /**
|
4664 | * An error type that should be used to signal cancellation of an operation.
|
4665 | *
|
4666 | * This type can be used in response to a {@link CancellationToken cancellation token}
|
4667 | * being cancelled or when an operation is being cancelled by the
|
4668 | * executor of that operation.
|
4669 | */
|
4670 | export class CancellationError extends Error {
|
4671 |
|
4672 | /**
|
4673 | * Creates a new cancellation error.
|
4674 | */
|
4675 | constructor()
|
4676 | }
|
4677 |
|
4678 | /**
|
4679 | * A semantic tokens builder can help with creating a `SemanticTokens` instance
|
4680 | * which contains delta encoded semantic tokens.
|
4681 | */
|
4682 | export class SemanticTokensBuilder {
|
4683 | constructor(legend?: SemanticTokensLegend)
|
4684 |
|
4685 | /**
|
4686 | * Add another token.
|
4687 | *
|
4688 | * @public
|
4689 | * @param line The token start line number (absolute value).
|
4690 | * @param char The token start character (absolute value).
|
4691 | * @param length The token length in characters.
|
4692 | * @param tokenType The encoded token type.
|
4693 | * @param tokenModifiers The encoded token modifiers.
|
4694 | */
|
4695 | push(line: number, char: number, length: number, tokenType: number, tokenModifiers?: number): void
|
4696 | /**
|
4697 | * Add another token. Use only when providing a legend.
|
4698 | *
|
4699 | * @public
|
4700 | * @param range The range of the token. Must be single-line.
|
4701 | * @param tokenType The token type.
|
4702 | * @param tokenModifiers The token modifiers.
|
4703 | */
|
4704 | push(range: Range, tokenType: string, tokenModifiers?: string[]): void
|
4705 |
|
4706 | /**
|
4707 | * Finish and create a `SemanticTokens` instance.
|
4708 | *
|
4709 | * @public
|
4710 | */
|
4711 | build(resultId?: string): SemanticTokens
|
4712 | }
|
4713 |
|
4714 | export interface Document {
|
4715 | readonly buffer: Buffer
|
4716 | /**
|
4717 | * Document is attached to vim.
|
4718 | */
|
4719 | readonly attached: boolean
|
4720 | /**
|
4721 | * Is command line document.
|
4722 | */
|
4723 | readonly isCommandLine: boolean
|
4724 | /**
|
4725 | * `buftype` option of buffer.
|
4726 | */
|
4727 | readonly buftype: string
|
4728 | /**
|
4729 | * Text document that synchronized.
|
4730 | */
|
4731 | readonly textDocument: LinesTextDocument
|
4732 | /**
|
4733 | * Fired when document change.
|
4734 | */
|
4735 | readonly onDocumentChange: Event<DidChangeTextDocumentParams>
|
4736 | /**
|
4737 | * Get current buffer changedtick.
|
4738 | */
|
4739 | readonly changedtick: number
|
4740 | /**
|
4741 | * Scheme of document.
|
4742 | */
|
4743 | readonly schema: string
|
4744 | /**
|
4745 | * Line count of current buffer.
|
4746 | */
|
4747 | readonly lineCount: number
|
4748 | /**
|
4749 | * Window ID when buffer create, could be -1 when no window associated.
|
4750 | */
|
4751 | readonly winid: number
|
4752 | /**
|
4753 | * Returns if current document is opended with previewwindow
|
4754 | */
|
4755 | readonly previewwindow: boolean
|
4756 | /**
|
4757 | * Check if document changed after last synchronize
|
4758 | */
|
4759 | readonly dirty: boolean
|
4760 | /**
|
4761 | * Buffer number
|
4762 | */
|
4763 | readonly bufnr: number
|
4764 | /**
|
4765 | * Content of textDocument.
|
4766 | */
|
4767 | readonly content: string
|
4768 | /**
|
4769 | * Converted filetype.
|
4770 | */
|
4771 | readonly filetype: string
|
4772 | /**
|
4773 | * Main filetype of buffer, first part when buffer filetype contains dots.
|
4774 | * Same as filetype most of the time.
|
4775 | */
|
4776 | readonly languageId: string
|
4777 | readonly uri: string
|
4778 | readonly version: number
|
4779 | /**
|
4780 | * Apply text edits to document. `nvim_buf_set_text()` is used when possible
|
4781 | *
|
4782 | * @param {TextEdit[]} edits
|
4783 | * @param {boolean} joinUndo - Join further changes with the previous undo block by `:undojoin`.
|
4784 | * @param {boolean | Position} move - Move the cursor when true or from custom position.
|
4785 | * @returns {Promise<void>}
|
4786 | */
|
4787 | applyEdits(edits: TextEdit[], joinUndo?: boolean, move?: boolean | Position): Promise<void>
|
4788 |
|
4789 | /**
|
4790 | * Change individual lines.
|
4791 | *
|
4792 | * @param {[number, string][]} lines
|
4793 | * @returns {void}
|
4794 | */
|
4795 | changeLines(lines: [number, string][]): Promise<void>
|
4796 |
|
4797 | /**
|
4798 | * Get offset from lnum & col
|
4799 | */
|
4800 | getOffset(lnum: number, col: number): number
|
4801 |
|
4802 | /**
|
4803 | * Check string is word.
|
4804 | */
|
4805 | isWord(word: string): boolean
|
4806 |
|
4807 | /**
|
4808 | * Word range at position.
|
4809 | *
|
4810 | * @param {Position} position
|
4811 | * @param {string} extraChars Extra characters that should be keyword.
|
4812 | * @param {boolean} current Use current lines instead of textDocument, default to true.
|
4813 | * @returns {Range | null}
|
4814 | */
|
4815 | getWordRangeAtPosition(position: Position, extraChars?: string, current?: boolean): Range | null
|
4816 |
|
4817 | /**
|
4818 | * Get ranges of word in textDocument.
|
4819 | */
|
4820 | getSymbolRanges(word: string): Range[]
|
4821 |
|
4822 | /**
|
4823 | * Get line for buffer
|
4824 | *
|
4825 | * @param {number} line 0 based line index.
|
4826 | * @param {boolean} current Use textDocument lines when false, default to true.
|
4827 | * @returns {string}
|
4828 | */
|
4829 | getline(line: number, current?: boolean): string
|
4830 |
|
4831 | /**
|
4832 | * Get range of current lines, zero indexed, end exclude.
|
4833 | */
|
4834 | getLines(start?: number, end?: number): string[]
|
4835 |
|
4836 | /**
|
4837 | * Get variable value by key, defined by `b:coc_{key}`
|
4838 | */
|
4839 | getVar<T>(key: string, defaultValue?: T): T
|
4840 |
|
4841 | /**
|
4842 | * Get position from lnum & col
|
4843 | */
|
4844 | getPosition(lnum: number, col: number): Position
|
4845 |
|
4846 | /**
|
4847 | * Adjust col with new valid character before position.
|
4848 | */
|
4849 | fixStartcol(position: Position, valids: string[]): number
|
4850 |
|
4851 | /**
|
4852 | * Get current content text.
|
4853 | */
|
4854 | getDocumentContent(): string
|
4855 | }
|
4856 |
|
4857 | /**
|
4858 | * Represents a {@link TextEditor text editor}'s {@link TextEditor.options options}.
|
4859 | */
|
4860 | export interface TextEditorOptions {
|
4861 | /**
|
4862 | * The size in spaces a tab takes. This is used for two purposes:
|
4863 | * - the rendering width of a tab character;
|
4864 | * - the number of spaces to insert when {@link TextEditorOptions.insertSpaces insertSpaces} is true.
|
4865 | *
|
4866 | * When getting a text editor's options, this property will always be a number (resolved).
|
4867 | */
|
4868 | tabSize: number
|
4869 | /**
|
4870 | * When pressing Tab insert {@link TextEditorOptions.tabSize n} spaces.
|
4871 | * When getting a text editor's options, this property will always be a boolean (resolved).
|
4872 | */
|
4873 | insertSpaces: boolean
|
4874 | }
|
4875 |
|
4876 | /**
|
4877 | * Represents an editor that is attached to a {@link TextDocument document}.
|
4878 | */
|
4879 | export interface TextEditor {
|
4880 | /**
|
4881 | * The tabpagenr of current editor.
|
4882 | */
|
4883 | readonly tabpagenr: number
|
4884 | /**
|
4885 | * The window id of current editor.
|
4886 | */
|
4887 | readonly winid: number
|
4888 | /**
|
4889 | * The window number of current editor.
|
4890 | */
|
4891 | readonly winnr: number
|
4892 | /**
|
4893 | * The document associated with this text editor. The document will be the same for the entire lifetime of this text editor.
|
4894 | */
|
4895 | readonly document: Document
|
4896 | /**
|
4897 | * The current visible ranges in the editor (vertically).
|
4898 | * This accounts only for vertical scrolling, and not for horizontal scrolling.
|
4899 | */
|
4900 | readonly visibleRanges: readonly Range[]
|
4901 | /**
|
4902 | * Text editor options.
|
4903 | */
|
4904 | readonly options: TextEditorOptions
|
4905 | }
|
4906 |
|
4907 | export interface Documentation {
|
4908 | /**
|
4909 | * Filetype used for highlight, markdown is supported.
|
4910 | */
|
4911 | filetype: string
|
4912 | /**
|
4913 | * Content of document.
|
4914 | */
|
4915 | content: string
|
4916 | /**
|
4917 | * Byte offset (0 based) that should be undelined.
|
4918 | */
|
4919 | active?: [number, number]
|
4920 | highlights?: HighlightItem[]
|
4921 | }
|
4922 |
|
4923 | /**
|
4924 | * A file glob pattern to match file paths against. This can either be a glob pattern string
|
4925 | * (like `**/*.{ts,js}` or `*.{ts,js}`) or a {@link RelativePattern relative pattern}.
|
4926 | *
|
4927 | * Glob patterns can have the following syntax:
|
4928 | * * `*` to match one or more characters in a path segment
|
4929 | * * `?` to match on one character in a path segment
|
4930 | * * `**` to match any number of path segments, including none
|
4931 | * * `{}` to group conditions (e.g. `**/*.{ts,js}` matches all TypeScript and JavaScript files)
|
4932 | * * `[]` to declare a range of characters to match in a path segment (e.g., `example.[0-9]` to match on `example.0`, `example.1`, …)
|
4933 | * * `[!...]` to negate a range of characters to match in a path segment (e.g., `example.[!0-9]` to match on `example.a`, `example.b`, but not `example.0`)
|
4934 | *
|
4935 | * Note: a backslash (`\`) is not valid within a glob pattern. If you have an existing file
|
4936 | * path to match against, consider to use the {@link RelativePattern relative pattern} support
|
4937 | * that takes care of converting any backslash into slash. Otherwise, make sure to convert
|
4938 | * any backslash to slash when creating the glob pattern.
|
4939 | */
|
4940 | export type GlobPattern = string | RelativePattern
|
4941 |
|
4942 | /**
|
4943 | * A relative pattern is a helper to construct glob patterns that are matched
|
4944 | * relatively to a base file path. The base path can either be an absolute file
|
4945 | * path as string or uri or a {@link WorkspaceFolder workspace folder}, which is the
|
4946 | * preferred way of creating the relative pattern.
|
4947 | */
|
4948 | export class RelativePattern {
|
4949 |
|
4950 | /**
|
4951 | * A base file path to which this pattern will be matched against relatively.
|
4952 | */
|
4953 | baseUri: Uri
|
4954 |
|
4955 | /**
|
4956 | * A file glob pattern like `*.{ts,js}` that will be matched on file paths
|
4957 | * relative to the base path.
|
4958 | *
|
4959 | * Example: Given a base of `/home/work/folder` and a file path of `/home/work/folder/index.js`,
|
4960 | * the file glob pattern will match on `index.js`.
|
4961 | */
|
4962 | pattern: string
|
4963 |
|
4964 | /**
|
4965 | * Creates a new relative pattern object with a base file path and pattern to match. This pattern
|
4966 | * will be matched on file paths relative to the base.
|
4967 | *
|
4968 | * Example:
|
4969 | * ```ts
|
4970 | * const folder = vscode.workspace.workspaceFolders?.[0];
|
4971 | * if (folder) {
|
4972 | *
|
4973 | * // Match any TypeScript file in the root of this workspace folder
|
4974 | * const pattern1 = new vscode.RelativePattern(folder, '*.ts');
|
4975 | *
|
4976 | * // Match any TypeScript file in `someFolder` inside this workspace folder
|
4977 | * const pattern2 = new vscode.RelativePattern(folder, 'someFolder/*.ts');
|
4978 | * }
|
4979 | * ```
|
4980 | *
|
4981 | * @param base A base to which this pattern will be matched against relatively. It is recommended
|
4982 | * to pass in a {@link WorkspaceFolder workspace folder} if the pattern should match inside the workspace.
|
4983 | * Otherwise, a uri or string should only be used if the pattern is for a file path outside the workspace.
|
4984 | * @param pattern A file glob pattern like `*.{ts,js}` that will be matched on paths relative to the base.
|
4985 | */
|
4986 | constructor(base: WorkspaceFolder | Uri | string, pattern: string)
|
4987 | }
|
4988 |
|
4989 | /**
|
4990 | * Build buffer with lines and highlights
|
4991 | */
|
4992 | export class Highlighter {
|
4993 | constructor(srcId?: number)
|
4994 | /**
|
4995 | * Add a line with highlight group.
|
4996 | */
|
4997 | addLine(line: string, hlGroup?: string): void
|
4998 | /**
|
4999 | * Add lines without highlights.
|
5000 | */
|
5001 | addLines(lines: string[]): void
|
5002 | /**
|
5003 | * Add text with highlight.
|
5004 | */
|
5005 | addText(text: string, hlGroup?: string): void
|
5006 | /**
|
5007 | * Get line count
|
5008 | */
|
5009 | get length(): number
|
5010 | /**
|
5011 | * Render lines to buffer at specified range.
|
5012 | * Since notifications is used, use `nvim.pauseNotification` & `nvim.resumeNotification`
|
5013 | * when you need to wait for the request finish.
|
5014 | *
|
5015 | * @param {Buffer} buffer
|
5016 | * @param {number} start
|
5017 | * @param {number} end
|
5018 | * @returns {void}
|
5019 | */
|
5020 | render(buffer: Buffer, start?: number, end?: number): void
|
5021 | }
|
5022 |
|
5023 | export interface ListConfiguration {
|
5024 | get<T>(key: string, defaultValue?: T): T
|
5025 | previousKey(): string
|
5026 | nextKey(): string
|
5027 | dispose(): void
|
5028 | }
|
5029 |
|
5030 | export interface ListActionOptions {
|
5031 | /**
|
5032 | * No prompt stop and window switch when invoked.
|
5033 | */
|
5034 | persist?: boolean
|
5035 | /**
|
5036 | * Reload list after action invoked.
|
5037 | */
|
5038 | reload?: boolean
|
5039 | /**
|
5040 | * Support multiple items as execute argument.
|
5041 | */
|
5042 | parallel?: boolean
|
5043 | /**
|
5044 | * Tab positioned list should be persisted (no window switch) on action invoke.
|
5045 | */
|
5046 | tabPersist?: boolean
|
5047 | }
|
5048 |
|
5049 | export interface CommandTaskOption {
|
5050 | /**
|
5051 | * Command to run.
|
5052 | */
|
5053 | cmd: string
|
5054 | /**
|
5055 | * Arguments of command.
|
5056 | */
|
5057 | args: string[]
|
5058 | /**
|
5059 | * Current working directory.
|
5060 | */
|
5061 | cwd?: string
|
5062 | env?: NodeJS.ProcessEnv
|
5063 | /**
|
5064 | * Runs for each line, return undefined for invalid item.
|
5065 | */
|
5066 | onLine: (line: string) => ListItem | undefined
|
5067 | }
|
5068 |
|
5069 | export abstract class BasicList implements IList {
|
5070 | /**
|
5071 | * Unique name, must be provided by implementation class.
|
5072 | */
|
5073 | name: string
|
5074 | /**
|
5075 | * Default action name invoked by <cr> by default, must be provided by implementation class.
|
5076 | */
|
5077 | defaultAction: string
|
5078 | /**
|
5079 | * Registered actions.
|
5080 | */
|
5081 | readonly actions: ListAction[]
|
5082 | /**
|
5083 | * Arguments configuration of list.
|
5084 | */
|
5085 | options: ListArgument[]
|
5086 | protected nvim: Neovim
|
5087 | protected disposables: Disposable[]
|
5088 | protected config: ListConfiguration
|
5089 | constructor(nvim: Neovim)
|
5090 | /**
|
5091 | * Should align columns when true.
|
5092 | */
|
5093 | get alignColumns(): boolean
|
5094 | get hlGroup(): string
|
5095 | get previewHeight(): string
|
5096 | get splitRight(): boolean
|
5097 | /**
|
5098 | * Parse argument string array for argument object from `this.options`.
|
5099 | * Could be used inside `this.loadItems()`
|
5100 | */
|
5101 | protected parseArguments(args: string[]): { [key: string]: string | boolean }
|
5102 | /**
|
5103 | * Get configurations of current list
|
5104 | */
|
5105 | protected getConfig(): WorkspaceConfiguration
|
5106 | /**
|
5107 | * Add an action
|
5108 | */
|
5109 | protected addAction(name: string, fn: (item: ListItem, context: ListContext) => ProviderResult<void>, options?: ListActionOptions): void
|
5110 | /**
|
5111 | * Add action that support multiple selection.
|
5112 | */
|
5113 | protected addMultipleAction(name: string, fn: (item: ListItem[], context: ListContext) => ProviderResult<void>, options?: ListActionOptions): void
|
5114 | /**
|
5115 | * Create task from command task option.
|
5116 | */
|
5117 | protected createCommandTask(opt: CommandTaskOption): ListTask
|
5118 | /**
|
5119 | * Add location related actions, should be called in constructor.
|
5120 | */
|
5121 | protected addLocationActions(): void
|
5122 | protected convertLocation(location: Location | LocationWithLine | string): Promise<Location>
|
5123 | /**
|
5124 | * Jump to location
|
5125 | *
|
5126 | * @method
|
5127 | */
|
5128 | protected jumpTo(location: Location | LocationWithLine | string, command?: string): Promise<void>
|
5129 | /**
|
5130 | * Preview location.
|
5131 | *
|
5132 | * @method
|
5133 | */
|
5134 | protected previewLocation(location: Location, context: ListContext): Promise<void>
|
5135 | /**
|
5136 | * Preview lines.
|
5137 | *
|
5138 | * @method
|
5139 | */
|
5140 | protected preview(options: PreviewOptions, context: ListContext): Promise<void>
|
5141 | /**
|
5142 | * Use for syntax highlights, invoked after buffer loaded.
|
5143 | */
|
5144 | doHighlight(): void
|
5145 | /**
|
5146 | * Invoked for listItems or listTask, could throw error when failed to load.
|
5147 | */
|
5148 | abstract loadItems(context: ListContext, token?: CancellationToken): Promise<ListItem[] | ListTask | null | undefined>
|
5149 | }
|
5150 |
|
5151 | export class Mutex {
|
5152 | /**
|
5153 | * Returns true when task is running.
|
5154 | */
|
5155 | get busy(): boolean
|
5156 | /**
|
5157 | * Resolved release function that must be called after task finish.
|
5158 | */
|
5159 | acquire(): Promise<() => void>
|
5160 | /**
|
5161 | * Captrue the async task function that ensures to be executed one by one.
|
5162 | */
|
5163 | use<T>(f: () => Promise<T>): Promise<T>
|
5164 | }
|
5165 | // }}
|
5166 |
|
5167 | // functions {{
|
5168 |
|
5169 | export interface AnsiItem {
|
5170 | foreground?: string
|
5171 | background?: string
|
5172 | bold?: boolean
|
5173 | italic?: boolean
|
5174 | underline?: boolean
|
5175 | text: string
|
5176 | }
|
5177 |
|
5178 | export interface ParsedUrlQueryInput {
|
5179 | [key: string]: unknown
|
5180 | }
|
5181 |
|
5182 | export interface FetchOptions {
|
5183 | /**
|
5184 | * Default to 'GET'
|
5185 | */
|
5186 | method?: string
|
5187 | /**
|
5188 | * Default no timeout
|
5189 | */
|
5190 | timeout?: number
|
5191 | /**
|
5192 | * Always return buffer instead of parsed response.
|
5193 | */
|
5194 | buffer?: boolean
|
5195 | /**
|
5196 | * Data send to server.
|
5197 | */
|
5198 | data?: string | { [key: string]: any } | Buffer
|
5199 | /**
|
5200 | * Plain object added as query of url
|
5201 | */
|
5202 | query?: ParsedUrlQueryInput
|
5203 | headers?: any
|
5204 | /**
|
5205 | * User for http basic auth, should use with password
|
5206 | */
|
5207 | user?: string
|
5208 | /**
|
5209 | * Password for http basic auth, should use with user
|
5210 | */
|
5211 | password?: string
|
5212 | }
|
5213 |
|
5214 | export interface DownloadOptions extends Omit<FetchOptions, 'buffer'> {
|
5215 | /**
|
5216 | * Folder that contains downloaded file or extracted files by untar or unzip
|
5217 | */
|
5218 | dest: string
|
5219 | /**
|
5220 | * Remove the specified number of leading path elements for *untar* only, default to `1`.
|
5221 | */
|
5222 | strip?: number
|
5223 | /**
|
5224 | * algorithm for check etag header with response data, used by `crypto.createHash()`.
|
5225 | */
|
5226 | etagAlgorithm?: string
|
5227 | /**
|
5228 | * If true, use untar for `.tar.gz` filename
|
5229 | */
|
5230 | extract?: boolean | 'untar' | 'unzip'
|
5231 | onProgress?: (percent: string) => void
|
5232 | }
|
5233 |
|
5234 | export type ResponseResult = string | Buffer | {
|
5235 | [name: string]: any
|
5236 | }
|
5237 |
|
5238 | /**
|
5239 | * Parse ansi result from string contains ansi characters.
|
5240 | */
|
5241 | export function ansiparse(str: string): AnsiItem[]
|
5242 |
|
5243 | /**
|
5244 | * Send request to server for response, supports:
|
5245 | *
|
5246 | * - Send json data and parse json response.
|
5247 | * - Throw error for failed response statusCode.
|
5248 | * - Timeout support (no timeout by default).
|
5249 | * - Send buffer (as data) and receive data (as response).
|
5250 | * - Proxy support from user configuration & environment.
|
5251 | * - Redirect support, limited to 3.
|
5252 | * - Support of gzip & deflate response content.
|
5253 | *
|
5254 | * @return Parsed object if response content type is application/json, text if content type starts with `text/`
|
5255 | */
|
5256 | export function fetch(url: string | URL, options?: FetchOptions, token?: CancellationToken): Promise<ResponseResult>
|
5257 |
|
5258 | /**
|
5259 | * Download file from url, with optional untar/unzip support.
|
5260 | *
|
5261 | * Note: you may need to set `strip` to 0 when using untar as extract method.
|
5262 | *
|
5263 | * @param {string} url
|
5264 | * @param {DownloadOptions} options contains dest folder and optional onProgress callback
|
5265 | */
|
5266 | export function download(url: string | URL, options: DownloadOptions, token?: CancellationToken): Promise<string>
|
5267 |
|
5268 | interface ExecOptions {
|
5269 | cwd?: string
|
5270 | env?: NodeJS.ProcessEnv
|
5271 | shell?: string
|
5272 | timeout?: number
|
5273 | maxBuffer?: number
|
5274 | killSignal?: string
|
5275 | uid?: number
|
5276 | gid?: number
|
5277 | windowsHide?: boolean
|
5278 | }
|
5279 |
|
5280 | /**
|
5281 | * Dispose all disposables.
|
5282 | */
|
5283 | export function disposeAll(disposables: Disposable[]): void
|
5284 |
|
5285 | /**
|
5286 | * Concurrent run async functions with limit support.
|
5287 | */
|
5288 | export function concurrent<T>(arr: T[], fn: (val: T) => Promise<void>, limit?: number): Promise<void>
|
5289 |
|
5290 | /**
|
5291 | * Create promise resolved after ms milliseconds.
|
5292 | */
|
5293 | export function wait(ms: number): Promise<any>
|
5294 |
|
5295 | /**
|
5296 | * Run command with `child_process.exec`
|
5297 | */
|
5298 | export function runCommand(cmd: string, opts?: ExecOptions, timeout?: number): Promise<string>
|
5299 |
|
5300 | /**
|
5301 | * Check if process with pid is running
|
5302 | */
|
5303 | export function isRunning(pid: number): boolean
|
5304 |
|
5305 | /**
|
5306 | * Check if command is executable.
|
5307 | */
|
5308 | export function executable(command: string): boolean
|
5309 |
|
5310 | /**
|
5311 | * Watch single file for change, the filepath needs to be exists file.
|
5312 | *
|
5313 | * @param filepath Full path of file.
|
5314 | * @param onChange Handler on file change detected.
|
5315 | */
|
5316 | export function watchFile(filepath: string, onChange: () => void): Disposable
|
5317 | // }}
|
5318 |
|
5319 | // commands module {{
|
5320 | export interface CommandItem {
|
5321 | id: string
|
5322 | internal?: boolean
|
5323 | execute(...args: any[]): any
|
5324 | }
|
5325 | /**
|
5326 | * Namespace for dealing with commands of coc.nvim
|
5327 | */
|
5328 | export namespace commands {
|
5329 | /**
|
5330 | * Registered commands.
|
5331 | */
|
5332 | export const commandList: CommandItem[]
|
5333 |
|
5334 | /**
|
5335 | * Execute specified command.
|
5336 | *
|
5337 | * @deprecated use `executeCommand()` instead.
|
5338 | */
|
5339 | export function execute(command: { name: string, arguments?: any[] }): void
|
5340 |
|
5341 | /**
|
5342 | * Check if command is registered.
|
5343 | *
|
5344 | * @param id Unique id of command.
|
5345 | */
|
5346 | export function has(id: string): boolean
|
5347 |
|
5348 | /**
|
5349 | * Registers a command that can be invoked via a keyboard shortcut,
|
5350 | * a menu item, an action, or directly.
|
5351 | *
|
5352 | * Registering a command with an existing command identifier twice
|
5353 | * will cause an error.
|
5354 | *
|
5355 | * @param command A unique identifier for the command.
|
5356 | * @param impl A command handler function.
|
5357 | * @param thisArg The `this` context used when invoking the handler function.
|
5358 | * @return Disposable which unregisters this command on disposal.
|
5359 | */
|
5360 | export function registerCommand(id: string, impl: (...args: any[]) => void, thisArg?: any, internal?: boolean): Disposable
|
5361 |
|
5362 | /**
|
5363 | * Executes the command denoted by the given command identifier.
|
5364 | *
|
5365 | * * *Note 1:* When executing an editor command not all types are allowed to
|
5366 | * be passed as arguments. Allowed are the primitive types `string`, `boolean`,
|
5367 | * `number`, `undefined`, and `null`, as well as [`Position`](#Position), [`Range`](#Range), [`URI`](#URI) and [`Location`](#Location).
|
5368 | * * *Note 2:* There are no restrictions when executing commands that have been contributed
|
5369 | * by extensions.
|
5370 | *
|
5371 | * @param command Identifier of the command to execute.
|
5372 | * @param rest Parameters passed to the command function.
|
5373 | * @return A promise that resolves to the returned value of the given command. `undefined` when
|
5374 | * the command handler function doesn't return anything.
|
5375 | */
|
5376 | export function executeCommand<T>(command: string, ...rest: any[]): Promise<T>
|
5377 |
|
5378 | /**
|
5379 | * Open uri with external tool, use `open` on mac, use `xdg-open` on linux.
|
5380 | */
|
5381 | export function executeCommand(command: 'vscode.open', uri: string | Uri): Promise<void>
|
5382 |
|
5383 | /**
|
5384 | * Reload current buffer by `:edit` command.
|
5385 | */
|
5386 | export function executeCommand(command: 'workbench.action.reloadWindow'): Promise<void>
|
5387 |
|
5388 | /**
|
5389 | * Insert snippet at range of current buffer.
|
5390 | *
|
5391 | * @param edit Contains snippet text and range to replace.
|
5392 | */
|
5393 | export function executeCommand(command: 'editor.action.insertSnippet', edit: TextEdit, ultisnip?: UltiSnippetOption): Promise<boolean>
|
5394 |
|
5395 | /**
|
5396 | * Invoke specified code action.
|
5397 | */
|
5398 | export function executeCommand(command: 'editor.action.doCodeAction', action: CodeAction): Promise<void>
|
5399 |
|
5400 | /**
|
5401 | * Trigger coc.nvim's completion at current cursor position.
|
5402 | */
|
5403 | export function executeCommand(command: 'editor.action.triggerSuggest'): Promise<void>
|
5404 |
|
5405 | /**
|
5406 | * Trigger signature help at current cursor position.
|
5407 | */
|
5408 | export function executeCommand(command: 'editor.action.triggerParameterHints'): Promise<void>
|
5409 |
|
5410 | /**
|
5411 | * Add ranges to cursors session for multiple cursors.
|
5412 | */
|
5413 | export function executeCommand(command: 'editor.action.addRanges', ranges: Range[]): Promise<void>
|
5414 |
|
5415 | /**
|
5416 | * Restart coc.nvim service by `:CocRestart` command.
|
5417 | */
|
5418 | export function executeCommand(command: 'editor.action.restart'): Promise<void>
|
5419 |
|
5420 | /**
|
5421 | * Show locations by location list or vim's quickfix list.
|
5422 | */
|
5423 | export function executeCommand(command: 'editor.action.showReferences', filepath: string | undefined, position: Position | undefined, locations: Location[]): Promise<void>
|
5424 |
|
5425 | /**
|
5426 | * Invoke rename action at position of specified uri.
|
5427 | */
|
5428 | export function executeCommand(command: 'editor.action.rename', uri: string, position: Position): Promise<void>
|
5429 |
|
5430 | /**
|
5431 | * Run format action for current buffer.
|
5432 | */
|
5433 | export function executeCommand(command: 'editor.action.format'): Promise<void>
|
5434 | }
|
5435 | // }}
|
5436 |
|
5437 | // events module {{
|
5438 | type EventResult = void | Promise<void>
|
5439 | type MoveEvents = 'CursorMoved' | 'CursorMovedI' | 'CursorHold' | 'CursorHoldI'
|
5440 | type BufEvents = 'BufHidden' | 'BufEnter' | 'BufWritePost'
|
5441 | | 'InsertLeave' | 'TermOpen' | 'InsertEnter'
|
5442 | | 'BufCreate' | 'BufUnload' | 'BufWritePre' | 'Enter'
|
5443 | type EmptyEvents = 'FocusGained' | 'FocusLost' | 'InsertSnippet'
|
5444 | type InsertChangeEvents = 'TextChangedP' | 'TextChangedI'
|
5445 | type TaskEvents = 'TaskExit' | 'TaskStderr' | 'TaskStdout'
|
5446 | type WindowEvents = 'WinLeave' | 'WinEnter'
|
5447 | type AllEvents = BufEvents | EmptyEvents | MoveEvents | TaskEvents | WindowEvents | InsertChangeEvents | 'CompleteDone' | 'TextChanged' | 'MenuPopupChanged' | 'InsertCharPre' | 'FileType' | 'BufWinEnter' | 'BufWinLeave' | 'VimResized' | 'DirChanged' | 'OptionSet' | 'Command' | 'BufReadCmd' | 'GlobalChange' | 'InputChar' | 'WinLeave' | 'MenuInput' | 'PromptInsert' | 'FloatBtnClick' | 'InsertSnippet' | 'PromptKeyPress'
|
5448 | type OptionValue = string | number | boolean
|
5449 | type PromptWidowKeys = 'C-j' | 'C-k' | 'C-n' | 'C-p' | 'up' | 'down'
|
5450 |
|
5451 | export interface CursorPosition {
|
5452 | readonly bufnr: number
|
5453 | readonly lnum: number
|
5454 | readonly col: number
|
5455 | readonly insert: boolean
|
5456 | }
|
5457 |
|
5458 | export interface InsertChange {
|
5459 | /**
|
5460 | * 1 based line number
|
5461 | */
|
5462 | readonly lnum: number
|
5463 | /**
|
5464 | * 1 based column number
|
5465 | */
|
5466 | readonly col: number
|
5467 | /**
|
5468 | * Text before cursor.
|
5469 | */
|
5470 | readonly pre: string
|
5471 | /**
|
5472 | * Insert character that cause change of this time.
|
5473 | */
|
5474 | readonly insertChar: string | undefined
|
5475 | readonly changedtick: number
|
5476 | }
|
5477 |
|
5478 | export interface PopupChangeEvent {
|
5479 | /**
|
5480 | * 0 based index of item in the list.
|
5481 | */
|
5482 | readonly index: number
|
5483 | /**
|
5484 | * Word of item.
|
5485 | */
|
5486 | readonly word: string
|
5487 | /**
|
5488 | * Height of pum.
|
5489 | */
|
5490 | readonly height: number
|
5491 | /**
|
5492 | * Width of pum.
|
5493 | */
|
5494 | readonly width: number
|
5495 | /**
|
5496 | * Screen row of pum.
|
5497 | */
|
5498 | readonly row: number
|
5499 | /**
|
5500 | * Screen col of pum.
|
5501 | */
|
5502 | readonly col: number
|
5503 | /**
|
5504 | * Total length of completion list.
|
5505 | */
|
5506 | readonly size: number
|
5507 | /**
|
5508 | * Scollbar in the pum.
|
5509 | */
|
5510 | readonly scrollbar: boolean
|
5511 | /**
|
5512 | * Word is inserted.
|
5513 | */
|
5514 | readonly inserted: boolean
|
5515 | /**
|
5516 | * Caused by selection change (not initial or completed)
|
5517 | */
|
5518 | readonly move: boolean
|
5519 | }
|
5520 |
|
5521 | /**
|
5522 | * Used for listen to events send from vim.
|
5523 | */
|
5524 | export namespace events {
|
5525 | /**
|
5526 | * Latest cursor position.
|
5527 | */
|
5528 | export const cursor: Readonly<CursorPosition>
|
5529 | /**
|
5530 | * Latest pum position, is true when pum positioned above current line.
|
5531 | */
|
5532 | export const pumAlignTop: boolean
|
5533 | /**
|
5534 | * Insert mode detected by latest events.
|
5535 | */
|
5536 | export const insertMode: boolean
|
5537 |
|
5538 | /**
|
5539 | * Popup menu is visible.
|
5540 | */
|
5541 | export const pumvisible: boolean
|
5542 |
|
5543 | /**
|
5544 | * Wait for any of event in events to fire, resolve undefined when timeout or CancellationToken requested.
|
5545 | * @param events Event names to wait.
|
5546 | * @param timeoutOrToken Timeout in miniseconds or CancellationToken.
|
5547 | * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
|
5548 | */
|
5549 | export function race(events: AllEvents[], timeoutOrToken?: number | CancellationToken): Promise<{ name: AllEvents, args: unknown[] } | undefined>
|
5550 |
|
5551 | /**
|
5552 | * Attach handler to buffer events.
|
5553 | */
|
5554 | export function on(event: BufEvents, handler: (bufnr: number) => EventResult, thisArg?: any, disposables?: Disposable[]): Disposable
|
5555 | /**
|
5556 | * Attach handler to mouse move events.
|
5557 | */
|
5558 | export function on(event: MoveEvents, handler: (bufnr: number, cursor: [number, number]) => EventResult, thisArg?: any, disposables?: Disposable[]): Disposable
|
5559 | /**
|
5560 | * Attach handler to TextChangedI or TextChangedP.
|
5561 | */
|
5562 | export function on(event: InsertChangeEvents, handler: (bufnr: number, info: InsertChange) => EventResult, thisArg?: any, disposables?: Disposable[]): Disposable
|
5563 | /**
|
5564 | * Attach handler to window event.
|
5565 | */
|
5566 | export function on(event: WindowEvents, handler: (winid: number) => EventResult, thisArg?: any, disposables?: Disposable[]): Disposable
|
5567 | /**
|
5568 | * Attach handler to float button click.
|
5569 | */
|
5570 | export function on(event: 'FloatBtnClick', handler: (bufnr: number, index: number) => EventResult, thisArg?: any, disposables?: Disposable[]): Disposable
|
5571 | /**
|
5572 | * Attach handler to keypress in prompt window.
|
5573 | * Key could only be 'C-j', 'C-k', 'C-n', 'C-p', 'up' and 'down'
|
5574 | */
|
5575 | export function on(event: 'PromptKeyPress', handler: (bufnr: number, key: PromptWidowKeys) => EventResult, thisArg?: any, disposables?: Disposable[]): Disposable
|
5576 | /**
|
5577 | * Fired on vim's TextChanged event.
|
5578 | */
|
5579 | export function on(event: 'TextChanged', handler: (bufnr: number, changedtick: number) => EventResult, thisArg?: any, disposables?: Disposable[]): Disposable
|
5580 | export function on(event: 'TaskExit', handler: (id: string, code: number) => EventResult, thisArg?: any, disposables?: Disposable[]): Disposable
|
5581 | export function on(event: 'TaskStderr' | 'TaskStdout', handler: (id: string, lines: string[]) => EventResult, thisArg?: any, disposables?: Disposable[]): Disposable
|
5582 | /**
|
5583 | * Fired on vim's BufReadCmd event.
|
5584 | */
|
5585 | export function on(event: 'BufReadCmd', handler: (scheme: string, fullpath: string) => EventResult, thisArg?: any, disposables?: Disposable[]): Disposable
|
5586 | /**
|
5587 | * Fired on vim's VimResized event.
|
5588 | */
|
5589 | export function on(event: 'VimResized', handler: (columns: number, lines: number) => EventResult, thisArg?: any, disposables?: Disposable[]): Disposable
|
5590 | export function on(event: 'MenuPopupChanged', handler: (event: PopupChangeEvent, cursorline: number) => EventResult, thisArg?: any, disposables?: Disposable[]): Disposable
|
5591 | export function on(event: 'CompleteDone', handler: (item: CompleteDoneItem | {}) => EventResult, thisArg?: any, disposables?: Disposable[]): Disposable
|
5592 | export function on(event: 'InsertCharPre', handler: (character: string) => EventResult, thisArg?: any, disposables?: Disposable[]): Disposable
|
5593 | export function on(event: 'FileType', handler: (filetype: string, bufnr: number) => EventResult, thisArg?: any, disposables?: Disposable[]): Disposable
|
5594 | export function on(event: 'BufWinEnter' | 'BufWinLeave', handler: (bufnr: number, winid: number) => EventResult, thisArg?: any, disposables?: Disposable[]): Disposable
|
5595 | export function on(event: 'DirChanged', handler: (cwd: string) => EventResult, thisArg?: any, disposables?: Disposable[]): Disposable
|
5596 | export function on(event: 'OptionSet' | 'GlobalChange', handler: (option: string, oldVal: OptionValue, newVal: OptionValue) => EventResult, thisArg?: any, disposables?: Disposable[]): Disposable
|
5597 | export function on(event: 'InputChar', handler: (session: string, character: string, mode: number) => EventResult, thisArg?: any, disposables?: Disposable[]): Disposable
|
5598 | export function on(event: 'PromptInsert', handler: (value: string, bufnr: number) => EventResult, thisArg?: any, disposables?: Disposable[]): Disposable
|
5599 | export function on(event: 'Command', handler: (name: string) => EventResult, thisArg?: any, disposables?: Disposable[]): Disposable
|
5600 |
|
5601 | /**
|
5602 | * Fired after user insert character and made change to the buffer.
|
5603 | * Fired after TextChangedI & TextChangedP event.
|
5604 | */
|
5605 | export function on(event: 'TextInsert', handler: (bufnr: number, info: InsertChange, character: string) => EventResult, thisArg?: any, disposables?: Disposable[]): Disposable
|
5606 |
|
5607 | export function on(event: EmptyEvents, handler: () => EventResult, thisArg?: any, disposables?: Disposable[]): Disposable
|
5608 |
|
5609 | export function on(event: AllEvents[], handler: (...args: unknown[]) => EventResult, thisArg?: any, disposables?: Disposable[]): Disposable
|
5610 | }
|
5611 | // }}
|
5612 |
|
5613 | // file events {{
|
5614 | /**
|
5615 | * An event that is fired after files are created.
|
5616 | */
|
5617 | export interface FileCreateEvent {
|
5618 |
|
5619 | /**
|
5620 | * The files that got created.
|
5621 | */
|
5622 | readonly files: ReadonlyArray<Uri>
|
5623 | }
|
5624 |
|
5625 | /**
|
5626 | * An event that is fired when files are going to be created.
|
5627 | *
|
5628 | * To make modifications to the workspace before the files are created,
|
5629 | * call the [`waitUntil](#FileWillCreateEvent.waitUntil)-function with a
|
5630 | * thenable that resolves to a [workspace edit](#WorkspaceEdit).
|
5631 | */
|
5632 | export interface FileWillCreateEvent {
|
5633 |
|
5634 | /**
|
5635 | * A cancellation token.
|
5636 | */
|
5637 | readonly token: CancellationToken
|
5638 |
|
5639 | /**
|
5640 | * The files that are going to be created.
|
5641 | */
|
5642 | readonly files: ReadonlyArray<Uri>
|
5643 |
|
5644 | /**
|
5645 | * Allows to pause the event and to apply a [workspace edit](#WorkspaceEdit).
|
5646 | *
|
5647 | * *Note:* This function can only be called during event dispatch and not
|
5648 | * in an asynchronous manner:
|
5649 | *
|
5650 | * ```ts
|
5651 | * workspace.onWillCreateFiles(event => {
|
5652 | * // async, will *throw* an error
|
5653 | * setTimeout(() => event.waitUntil(promise));
|
5654 | *
|
5655 | * // sync, OK
|
5656 | * event.waitUntil(promise);
|
5657 | * })
|
5658 | * ```
|
5659 | *
|
5660 | * @param thenable A thenable that delays saving.
|
5661 | */
|
5662 | waitUntil(thenable: Thenable<WorkspaceEdit | any>): void
|
5663 | }
|
5664 |
|
5665 | /**
|
5666 | * An event that is fired when files are going to be deleted.
|
5667 | *
|
5668 | * To make modifications to the workspace before the files are deleted,
|
5669 | * call the [`waitUntil](#FileWillCreateEvent.waitUntil)-function with a
|
5670 | * thenable that resolves to a [workspace edit](#WorkspaceEdit).
|
5671 | */
|
5672 | export interface FileWillDeleteEvent {
|
5673 |
|
5674 | /**
|
5675 | * The files that are going to be deleted.
|
5676 | */
|
5677 | readonly files: ReadonlyArray<Uri>
|
5678 |
|
5679 | /**
|
5680 | * Allows to pause the event and to apply a [workspace edit](#WorkspaceEdit).
|
5681 | *
|
5682 | * *Note:* This function can only be called during event dispatch and not
|
5683 | * in an asynchronous manner:
|
5684 | *
|
5685 | * ```ts
|
5686 | * workspace.onWillCreateFiles(event => {
|
5687 | * // async, will *throw* an error
|
5688 | * setTimeout(() => event.waitUntil(promise));
|
5689 | *
|
5690 | * // sync, OK
|
5691 | * event.waitUntil(promise);
|
5692 | * })
|
5693 | * ```
|
5694 | *
|
5695 | * @param thenable A thenable that delays saving.
|
5696 | */
|
5697 | waitUntil(thenable: Thenable<WorkspaceEdit | any>): void
|
5698 | }
|
5699 |
|
5700 | /**
|
5701 | * An event that is fired after files are deleted.
|
5702 | */
|
5703 | export interface FileDeleteEvent {
|
5704 |
|
5705 | /**
|
5706 | * The files that got deleted.
|
5707 | */
|
5708 | readonly files: ReadonlyArray<Uri>
|
5709 | }
|
5710 |
|
5711 | /**
|
5712 | * An event that is fired after files are renamed.
|
5713 | */
|
5714 | export interface FileRenameEvent {
|
5715 |
|
5716 | /**
|
5717 | * The files that got renamed.
|
5718 | */
|
5719 | readonly files: ReadonlyArray<{ oldUri: Uri, newUri: Uri }>
|
5720 | }
|
5721 |
|
5722 | /**
|
5723 | * An event that is fired when files are going to be renamed.
|
5724 | *
|
5725 | * To make modifications to the workspace before the files are renamed,
|
5726 | * call the [`waitUntil](#FileWillCreateEvent.waitUntil)-function with a
|
5727 | * thenable that resolves to a [workspace edit](#WorkspaceEdit).
|
5728 | */
|
5729 | export interface FileWillRenameEvent {
|
5730 |
|
5731 | /**
|
5732 | * The files that are going to be renamed.
|
5733 | */
|
5734 | readonly files: ReadonlyArray<{ oldUri: Uri, newUri: Uri }>
|
5735 |
|
5736 | /**
|
5737 | * Allows to pause the event and to apply a [workspace edit](#WorkspaceEdit).
|
5738 | *
|
5739 | * *Note:* This function can only be called during event dispatch and not
|
5740 | * in an asynchronous manner:
|
5741 | *
|
5742 | * ```ts
|
5743 | * workspace.onWillCreateFiles(event => {
|
5744 | * // async, will *throw* an error
|
5745 | * setTimeout(() => event.waitUntil(promise));
|
5746 | *
|
5747 | * // sync, OK
|
5748 | * event.waitUntil(promise);
|
5749 | * })
|
5750 | * ```
|
5751 | *
|
5752 | * @param thenable A thenable that delays saving.
|
5753 | */
|
5754 | waitUntil(thenable: Thenable<WorkspaceEdit | any>): void
|
5755 | }
|
5756 | // }}
|
5757 |
|
5758 | // languages module {{
|
5759 | export interface DocumentSymbolProviderMetadata {
|
5760 | /**
|
5761 | * A human-readable string that is shown when multiple outlines trees show for one document.
|
5762 | */
|
5763 | label?: string
|
5764 | }
|
5765 |
|
5766 | export namespace languages {
|
5767 | /**
|
5768 | * Create a diagnostics collection.
|
5769 | *
|
5770 | * @param name The [name](#DiagnosticCollection.name) of the collection.
|
5771 | * @return A new diagnostic collection.
|
5772 | */
|
5773 | export function createDiagnosticCollection(name?: string): DiagnosticCollection
|
5774 |
|
5775 | /**
|
5776 | * Register a formatting provider that works on type. The provider is active when the user enables the setting `coc.preferences.formatOnType`.
|
5777 | *
|
5778 | * Multiple providers can be registered for a language. In that case providers are sorted
|
5779 | * by their [score](#languages.match) and the best-matching provider is used. Failure
|
5780 | * of the selected provider will cause a failure of the whole operation.
|
5781 | *
|
5782 | * @param selector A selector that defines the documents this provider is applicable to.
|
5783 | * @param provider An on type formatting edit provider.
|
5784 | * @param triggerCharacters Trigger character that should trigger format on type.
|
5785 | * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
|
5786 | */
|
5787 | export function registerOnTypeFormattingEditProvider(selector: DocumentSelector, provider: OnTypeFormattingEditProvider, triggerCharacters: string[]): Disposable
|
5788 |
|
5789 | /**
|
5790 | * Register a completion provider.
|
5791 | *
|
5792 | * Multiple providers can be registered for a language. In that case providers are sorted
|
5793 | * by their [score](#languages.match) and groups of equal score are sequentially asked for
|
5794 | * completion items. The process stops when one or many providers of a group return a
|
5795 | * result. A failing provider (rejected promise or exception) will not fail the whole
|
5796 | * operation.
|
5797 | *
|
5798 | * A completion item provider can be associated with a set of `triggerCharacters`. When trigger
|
5799 | * characters are being typed, completions are requested but only from providers that registered
|
5800 | * the typed character. Because of that trigger characters should be different than [word characters](#LanguageConfiguration.wordPattern),
|
5801 | * a common trigger character is `.` to trigger member completions.
|
5802 | *
|
5803 | * @param name Name of completion source.
|
5804 | * @param shortcut Shortcut used in completion menu.
|
5805 | * @param selector Document selector of created completion source.
|
5806 | * @param provider A completion provider.
|
5807 | * @param triggerCharacters Trigger completion when the user types one of the characters.
|
5808 | * @param priority Higher priority would shown first.
|
5809 | * @param allCommitCharacters Commit characters of completion source.
|
5810 | * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
|
5811 | */
|
5812 | export function registerCompletionItemProvider(name: string, shortcut: string, selector: DocumentSelector | null, provider: CompletionItemProvider, triggerCharacters?: string[], priority?: number, allCommitCharacters?: string[]): Disposable
|
5813 |
|
5814 | /**
|
5815 | * Register a code action provider.
|
5816 | *
|
5817 | * Multiple providers can be registered for a language. In that case providers are asked in
|
5818 | * parallel and the results are merged. A failing provider (rejected promise or exception) will
|
5819 | * not cause a failure of the whole operation.
|
5820 | *
|
5821 | * @param selector A selector that defines the documents this provider is applicable to.
|
5822 | * @param provider A code action provider.
|
5823 | * @param clientId Optional id of language client.
|
5824 | * @param codeActionKinds Optional supported code action kinds.
|
5825 | * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
|
5826 | */
|
5827 | export function registerCodeActionProvider(selector: DocumentSelector, provider: CodeActionProvider, clientId: string | undefined, codeActionKinds?: string[]): Disposable
|
5828 |
|
5829 | /**
|
5830 | * Register a hover provider.
|
5831 | *
|
5832 | * Multiple providers can be registered for a language. In that case providers are asked in
|
5833 | * parallel and the results are merged. A failing provider (rejected promise or exception) will
|
5834 | * not cause a failure of the whole operation.
|
5835 | *
|
5836 | * @param selector A selector that defines the documents this provider is applicable to.
|
5837 | * @param provider A hover provider.
|
5838 | * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
|
5839 | */
|
5840 | export function registerHoverProvider(selector: DocumentSelector, provider: HoverProvider): Disposable
|
5841 |
|
5842 | /**
|
5843 | * Register a selection range provider.
|
5844 | *
|
5845 | * Multiple providers can be registered for a language. In that case providers are asked in
|
5846 | * parallel and the results are merged. A failing provider (rejected promise or exception) will
|
5847 | * not cause a failure of the whole operation.
|
5848 | *
|
5849 | * @param selector A selector that defines the documents this provider is applicable to.
|
5850 | * @param provider A selection range provider.
|
5851 | * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
|
5852 | */
|
5853 | export function registerSelectionRangeProvider(selector: DocumentSelector, provider: SelectionRangeProvider): Disposable
|
5854 |
|
5855 | /**
|
5856 | * Register a signature help provider.
|
5857 | *
|
5858 | * Multiple providers can be registered for a language. In that case providers are sorted
|
5859 | * by their [score](#languages.match) and called sequentially until a provider returns a
|
5860 | * valid result.
|
5861 | *
|
5862 | * @param selector A selector that defines the documents this provider is applicable to.
|
5863 | * @param provider A signature help provider.
|
5864 | * @param triggerCharacters Trigger signature help when the user types one of the characters, like `,` or `(`.
|
5865 | * @param metadata Information about the provider.
|
5866 | * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
|
5867 | */
|
5868 | export function registerSignatureHelpProvider(selector: DocumentSelector, provider: SignatureHelpProvider, triggerCharacters?: string[]): Disposable
|
5869 |
|
5870 | /**
|
5871 | * Register a document symbol provider.
|
5872 | *
|
5873 | * Multiple providers can be registered for a language. In that case providers only first provider
|
5874 | * are asked for result.
|
5875 | *
|
5876 | * @param selector A selector that defines the documents this provider is applicable to.
|
5877 | * @param provider A document symbol provider.
|
5878 | * @param metadata Optional meta data.
|
5879 | * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
|
5880 | */
|
5881 | export function registerDocumentSymbolProvider(selector: DocumentSelector, provider: DocumentSymbolProvider, metadata?: DocumentSymbolProviderMetadata): Disposable
|
5882 |
|
5883 | /**
|
5884 | * Register a folding range provider.
|
5885 | *
|
5886 | * Multiple providers can be registered for a language. In that case providers only first provider
|
5887 | * are asked for result.
|
5888 | *
|
5889 | * A failing provider (rejected promise or exception) will
|
5890 | * not cause a failure of the whole operation.
|
5891 | *
|
5892 | * @param selector A selector that defines the documents this provider is applicable to.
|
5893 | * @param provider A folding range provider.
|
5894 | * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
|
5895 | */
|
5896 | export function registerFoldingRangeProvider(selector: DocumentSelector, provider: FoldingRangeProvider): Disposable
|
5897 |
|
5898 | /**
|
5899 | * Register a document highlight provider.
|
5900 | *
|
5901 | * Multiple providers can be registered for a language. In that case providers are sorted
|
5902 | * by their [score](#languages.match) and groups sequentially asked for document highlights.
|
5903 | * The process stops when a provider returns a `non-falsy` or `non-failure` result.
|
5904 | *
|
5905 | * @param selector A selector that defines the documents this provider is applicable to.
|
5906 | * @param provider A document highlight provider.
|
5907 | * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
|
5908 | */
|
5909 | export function registerDocumentHighlightProvider(selector: DocumentSelector, provider: DocumentHighlightProvider): Disposable
|
5910 |
|
5911 | /**
|
5912 | * Register a code lens provider.
|
5913 | *
|
5914 | * Multiple providers can be registered for a language. In that case providers are asked in
|
5915 | * parallel and the results are merged. A failing provider (rejected promise or exception) will
|
5916 | * not cause a failure of the whole operation.
|
5917 | *
|
5918 | * @param selector A selector that defines the documents this provider is applicable to.
|
5919 | * @param provider A code lens provider.
|
5920 | * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
|
5921 | */
|
5922 | export function registerCodeLensProvider(selector: DocumentSelector, provider: CodeLensProvider): Disposable
|
5923 |
|
5924 | /**
|
5925 | * Register a document link provider.
|
5926 | *
|
5927 | * Multiple providers can be registered for a language. In that case providers are asked in
|
5928 | * parallel and the results are merged. A failing provider (rejected promise or exception) will
|
5929 | * not cause a failure of the whole operation.
|
5930 | *
|
5931 | * @param selector A selector that defines the documents this provider is applicable to.
|
5932 | * @param provider A document link provider.
|
5933 | * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
|
5934 | */
|
5935 | export function registerDocumentLinkProvider(selector: DocumentSelector, provider: DocumentLinkProvider): Disposable
|
5936 |
|
5937 | /**
|
5938 | * Register a color provider.
|
5939 | *
|
5940 | * Multiple providers can be registered for a language. In that case providers are asked in
|
5941 | * parallel and the results are merged. A failing provider (rejected promise or exception) will
|
5942 | * not cause a failure of the whole operation.
|
5943 | *
|
5944 | * @param selector A selector that defines the documents this provider is applicable to.
|
5945 | * @param provider A color provider.
|
5946 | * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
|
5947 | */
|
5948 | export function registerDocumentColorProvider(selector: DocumentSelector, provider: DocumentColorProvider): Disposable
|
5949 |
|
5950 | /**
|
5951 | * Register a definition provider.
|
5952 | *
|
5953 | * Multiple providers can be registered for a language. In that case providers are asked in
|
5954 | * parallel and the results are merged. A failing provider (rejected promise or exception) will
|
5955 | * not cause a failure of the whole operation.
|
5956 | *
|
5957 | * @param selector A selector that defines the documents this provider is applicable to.
|
5958 | * @param provider A definition provider.
|
5959 | * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
|
5960 | */
|
5961 | export function registerDefinitionProvider(selector: DocumentSelector, provider: DefinitionProvider): Disposable
|
5962 |
|
5963 | /**
|
5964 | * Register a declaration provider.
|
5965 | *
|
5966 | * Multiple providers can be registered for a language. In that case providers are asked in
|
5967 | * parallel and the results are merged. A failing provider (rejected promise or exception) will
|
5968 | * not cause a failure of the whole operation.
|
5969 | *
|
5970 | * @param selector A selector that defines the documents this provider is applicable to.
|
5971 | * @param provider A declaration provider.
|
5972 | * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
|
5973 | */
|
5974 | export function registerDeclarationProvider(selector: DocumentSelector, provider: DeclarationProvider): Disposable
|
5975 |
|
5976 |
|
5977 | /**
|
5978 | * Register a type definition provider.
|
5979 | *
|
5980 | * Multiple providers can be registered for a language. In that case providers are asked in
|
5981 | * parallel and the results are merged. A failing provider (rejected promise or exception) will
|
5982 | * not cause a failure of the whole operation.
|
5983 | *
|
5984 | * @param selector A selector that defines the documents this provider is applicable to.
|
5985 | * @param provider A type definition provider.
|
5986 | * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
|
5987 | */
|
5988 | export function registerTypeDefinitionProvider(selector: DocumentSelector, provider: TypeDefinitionProvider): Disposable
|
5989 |
|
5990 | /**
|
5991 | * Register an implementation provider.
|
5992 | *
|
5993 | * Multiple providers can be registered for a language. In that case providers are asked in
|
5994 | * parallel and the results are merged. A failing provider (rejected promise or exception) will
|
5995 | * not cause a failure of the whole operation.
|
5996 | *
|
5997 | * @param selector A selector that defines the documents this provider is applicable to.
|
5998 | * @param provider An implementation provider.
|
5999 | * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
|
6000 | */
|
6001 | export function registerImplementationProvider(selector: DocumentSelector, provider: ImplementationProvider): Disposable
|
6002 |
|
6003 | /**
|
6004 | * Register a reference provider.
|
6005 | *
|
6006 | * Multiple providers can be registered for a language. In that case providers are asked in
|
6007 | * parallel and the results are merged. A failing provider (rejected promise or exception) will
|
6008 | * not cause a failure of the whole operation.
|
6009 | *
|
6010 | * @param selector A selector that defines the documents this provider is applicable to.
|
6011 | * @param provider A reference provider.
|
6012 | * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
|
6013 | */
|
6014 | export function registerReferencesProvider(selector: DocumentSelector, provider: ReferenceProvider): Disposable
|
6015 |
|
6016 | /**
|
6017 | * Register a rename provider.
|
6018 | *
|
6019 | * Multiple providers can be registered for a language. In that case providers are sorted
|
6020 | * by their [score](#workspace.match) and asked in sequence. The first provider producing a result
|
6021 | * defines the result of the whole operation.
|
6022 | *
|
6023 | * @param selector A selector that defines the documents this provider is applicable to.
|
6024 | * @param provider A rename provider.
|
6025 | * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
|
6026 | */
|
6027 | export function registerRenameProvider(selector: DocumentSelector, provider: RenameProvider): Disposable
|
6028 |
|
6029 | /**
|
6030 | * Register a workspace symbol provider.
|
6031 | *
|
6032 | * Multiple providers can be registered. In that case providers are asked in parallel and
|
6033 | * the results are merged. A failing provider (rejected promise or exception) will not cause
|
6034 | * a failure of the whole operation.
|
6035 | *
|
6036 | * @param provider A workspace symbol provider.
|
6037 | * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
|
6038 | */
|
6039 | export function registerWorkspaceSymbolProvider(provider: WorkspaceSymbolProvider): Disposable
|
6040 |
|
6041 | /**
|
6042 | * Register a formatting provider for a document.
|
6043 | *
|
6044 | * Multiple providers can be registered for a language. In that case providers are sorted
|
6045 | * by their priority. Failure of the selected provider will cause a failure of the whole operation.
|
6046 | *
|
6047 | * @param selector A selector that defines the documents this provider is applicable to.
|
6048 | * @param provider A document formatting edit provider.
|
6049 | * @param priority default to 0.
|
6050 | * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
|
6051 | */
|
6052 | export function registerDocumentFormatProvider(selector: DocumentSelector, provider: DocumentFormattingEditProvider, priority?: number): Disposable
|
6053 |
|
6054 | /**
|
6055 | * Register a formatting provider for a document range.
|
6056 | *
|
6057 | * *Note:* A document range provider is also a [document formatter](#DocumentFormattingEditProvider)
|
6058 | * which means there is no need to [register](#languages.registerDocumentFormattingEditProvider) a document
|
6059 | * formatter when also registering a range provider.
|
6060 | *
|
6061 | * Multiple providers can be registered for a language. In that case provider with highest priority is used.
|
6062 | * Failure of the selected provider will cause a failure of the whole operation.
|
6063 | *
|
6064 | * @param selector A selector that defines the documents this provider is applicable to.
|
6065 | * @param provider A document range formatting edit provider.
|
6066 | * @param priority default to 0.
|
6067 | * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
|
6068 | */
|
6069 | export function registerDocumentRangeFormatProvider(selector: DocumentSelector, provider: DocumentRangeFormattingEditProvider, priority?: number): Disposable
|
6070 |
|
6071 | /**
|
6072 | * Register a call hierarchy provider.
|
6073 | *
|
6074 | * @param selector A selector that defines the documents this provider is applicable to.
|
6075 | * @param provider A call hierarchy provider.
|
6076 | * @return A {@link Disposable} that unregisters this provider when being disposed.
|
6077 | */
|
6078 | export function registerCallHierarchyProvider(selector: DocumentSelector, provider: CallHierarchyProvider): Disposable
|
6079 |
|
6080 | /**
|
6081 | * Register a semantic tokens provider for a whole document.
|
6082 | *
|
6083 | * Multiple providers can be registered for a language. In that case providers are sorted
|
6084 | * by their {@link languages.match score} and the best-matching provider is used. Failure
|
6085 | * of the selected provider will cause a failure of the whole operation.
|
6086 | *
|
6087 | * @param selector A selector that defines the documents this provider is applicable to.
|
6088 | * @param provider A document semantic tokens provider.
|
6089 | * @return A {@link Disposable} that unregisters this provider when being disposed.
|
6090 | */
|
6091 | export function registerDocumentSemanticTokensProvider(selector: DocumentSelector, provider: DocumentSemanticTokensProvider, legend: SemanticTokensLegend): Disposable
|
6092 |
|
6093 | /**
|
6094 | * Register a semantic tokens provider for a document range.
|
6095 | *
|
6096 | * *Note:* If a document has both a `DocumentSemanticTokensProvider` and a `DocumentRangeSemanticTokensProvider`,
|
6097 | * the range provider will be invoked only initially, for the time in which the full document provider takes
|
6098 | * to resolve the first request. Once the full document provider resolves the first request, the semantic tokens
|
6099 | * provided via the range provider will be discarded and from that point forward, only the document provider
|
6100 | * will be used.
|
6101 | *
|
6102 | * Multiple providers can be registered for a language. In that case providers are sorted
|
6103 | * by their {@link languages.match score} and the best-matching provider is used. Failure
|
6104 | * of the selected provider will cause a failure of the whole operation.
|
6105 | *
|
6106 | * @param selector A selector that defines the documents this provider is applicable to.
|
6107 | * @param provider A document range semantic tokens provider.
|
6108 | * @return A {@link Disposable} that unregisters this provider when being disposed.
|
6109 | */
|
6110 | export function registerDocumentRangeSemanticTokensProvider(selector: DocumentSelector, provider: DocumentRangeSemanticTokensProvider, legend: SemanticTokensLegend): Disposable
|
6111 |
|
6112 | /**
|
6113 | * Register a linked editing range provider.
|
6114 | *
|
6115 | * Multiple providers can be registered for a language. In that case providers are sorted
|
6116 | * by their {@link languages.match score} and the best-matching provider that has a result is used. Failure
|
6117 | * of the selected provider will cause a failure of the whole operation.
|
6118 | *
|
6119 | * @param selector A selector that defines the documents this provider is applicable to.
|
6120 | * @param provider A linked editing range provider.
|
6121 | * @return A {@link Disposable} that unregisters this provider when being disposed.
|
6122 | */
|
6123 | export function registerLinkedEditingRangeProvider(selector: DocumentSelector, provider: LinkedEditingRangeProvider): Disposable
|
6124 |
|
6125 | /**
|
6126 | * Register a inlay hints provider.
|
6127 | *
|
6128 | * Multiple providers can be registered for a language. In that case providers are asked in
|
6129 | * parallel and the results are merged. A failing provider (rejected promise or exception) will
|
6130 | * not cause a failure of the whole operation.
|
6131 | *
|
6132 | * @param selector A selector that defines the documents this provider is applicable to.
|
6133 | * @param provider An inlay hints provider.
|
6134 | * @return A {@link Disposable} that unregisters this provider when being disposed.
|
6135 | */
|
6136 | export function registerInlayHintsProvider(selector: DocumentSelector, provider: InlayHintsProvider): Disposable
|
6137 | }
|
6138 | // }}
|
6139 |
|
6140 | // services module {{
|
6141 | export enum ServiceStat {
|
6142 | Initial,
|
6143 | Starting,
|
6144 | StartFailed,
|
6145 | Running,
|
6146 | Stopping,
|
6147 | Stopped,
|
6148 | }
|
6149 |
|
6150 | export interface IServiceProvider {
|
6151 | // unique service id
|
6152 | id: string
|
6153 | name: string
|
6154 | client?: LanguageClient
|
6155 | selector: DocumentSelector
|
6156 | // current state
|
6157 | state: ServiceStat
|
6158 | start(): Promise<void>
|
6159 | dispose(): void
|
6160 | stop(): Promise<void> | void
|
6161 | restart(): Promise<void> | void
|
6162 | onServiceReady: Event<void>
|
6163 | }
|
6164 |
|
6165 | export namespace services {
|
6166 | /**
|
6167 | * Register languageClient as service provider.
|
6168 | */
|
6169 | export function registerLanguageClient(client: LanguageClient): Disposable
|
6170 | /**
|
6171 | * @deprecated use registerLanguageClient instead.
|
6172 | */
|
6173 | export function registLanguageClient(client: LanguageClient): Disposable
|
6174 | /**
|
6175 | * Register service, nothing happens when `service.id` already exists.
|
6176 | */
|
6177 | export function register(service: IServiceProvider): Disposable
|
6178 | /**
|
6179 | * @deprecated use register instead.
|
6180 | */
|
6181 | export function regist(service: IServiceProvider): Disposable
|
6182 | /**
|
6183 | * Get service by id.
|
6184 | */
|
6185 | export function getService(id: string): IServiceProvider
|
6186 | /**
|
6187 | * Stop service by id.
|
6188 | */
|
6189 | export function stop(id: string): Promise<void>
|
6190 | /**
|
6191 | * Stop running service or start stopped service.
|
6192 | */
|
6193 | export function toggle(id: string): Promise<void>
|
6194 | }
|
6195 | // }}
|
6196 |
|
6197 | // sources module {{
|
6198 | /**
|
6199 | * Source options to create source that could respect configuration from `coc.source.{name}`
|
6200 | */
|
6201 | export type SourceConfig = Omit<ISource, 'shortcut' | 'priority' | 'triggerOnly' | 'triggerCharacters' | 'triggerPatterns' | 'enable' | 'filetypes' | 'disableSyntaxes'>
|
6202 |
|
6203 | export interface SourceStat {
|
6204 | name: string
|
6205 | priority: number
|
6206 | triggerCharacters: string[]
|
6207 | type: 'native' | 'remote' | 'service'
|
6208 | shortcut: string
|
6209 | filepath: string
|
6210 | disabled: boolean
|
6211 | filetypes: string[]
|
6212 | }
|
6213 |
|
6214 | export enum SourceType {
|
6215 | Native,
|
6216 | Remote,
|
6217 | Service,
|
6218 | }
|
6219 |
|
6220 | export interface CompleteResult {
|
6221 | items: VimCompleteItem[]
|
6222 | isIncomplete?: boolean
|
6223 | startcol?: number
|
6224 | source?: string
|
6225 | priority?: number
|
6226 | }
|
6227 |
|
6228 | // option on complete & should_complete
|
6229 | export interface CompleteOption {
|
6230 | /**
|
6231 | * Current buffer number.
|
6232 | */
|
6233 | readonly bufnr: number
|
6234 | /**
|
6235 | * Current line.
|
6236 | */
|
6237 | readonly line: string
|
6238 | /**
|
6239 | * Column to start completion, determined by iskeyword options of buffer.
|
6240 | */
|
6241 | readonly col: number
|
6242 | /**
|
6243 | * Input text.
|
6244 | */
|
6245 | readonly input: string
|
6246 | readonly filetype: string
|
6247 | readonly filepath: string
|
6248 | /**
|
6249 | * Word under cursor.
|
6250 | */
|
6251 | readonly word: string
|
6252 | /**
|
6253 | * Trigger character, could be empty string.
|
6254 | */
|
6255 | readonly triggerCharacter: string
|
6256 | /**
|
6257 | * Col of cursor, 1 based.
|
6258 | */
|
6259 | readonly colnr: number
|
6260 | readonly linenr: number
|
6261 | readonly synname: string
|
6262 | /**
|
6263 | * Black list words specified by user.
|
6264 | */
|
6265 | readonly blacklist: string[]
|
6266 | /**
|
6267 | * Buffer changetick
|
6268 | */
|
6269 | readonly changedtick: number
|
6270 | /**
|
6271 | * Is trigger for in complete completion.
|
6272 | */
|
6273 | readonly triggerForInComplete?: boolean
|
6274 | }
|
6275 |
|
6276 | export interface ISource {
|
6277 | /**
|
6278 | * Identifier name
|
6279 | */
|
6280 | name: string
|
6281 | /**
|
6282 | * @deprecated use documentSelector instead.
|
6283 | */
|
6284 | filetypes?: string[]
|
6285 | /**
|
6286 | * Filters of document.
|
6287 | */
|
6288 | documentSelector?: DocumentSelector
|
6289 | enable?: boolean
|
6290 | shortcut?: string
|
6291 | priority?: number
|
6292 | sourceType?: SourceType
|
6293 | /**
|
6294 | * Should only be used when completion is triggered, requirs `triggerPatterns` or `triggerCharacters` defined.
|
6295 | */
|
6296 | triggerOnly?: boolean
|
6297 | triggerCharacters?: string[]
|
6298 | // regex to detect trigger completion, ignored when triggerCharacters exists.
|
6299 | triggerPatterns?: RegExp[]
|
6300 | disableSyntaxes?: string[]
|
6301 | filepath?: string
|
6302 | // should the first character always match
|
6303 | firstMatch?: boolean
|
6304 | refresh?(): Promise<void>
|
6305 | /**
|
6306 | * For disable/enable
|
6307 | */
|
6308 | toggle?(): void
|
6309 |
|
6310 | /**
|
6311 | * Triggered on BufEnter, used for cache normally
|
6312 | */
|
6313 | onEnter?(bufnr: number): void
|
6314 |
|
6315 | /**
|
6316 | * Check if this source should doComplete
|
6317 | *
|
6318 | * @public
|
6319 | * @param {CompleteOption} opt
|
6320 | * @returns {Promise<boolean> }
|
6321 | */
|
6322 | shouldComplete?(opt: CompleteOption): Promise<boolean>
|
6323 |
|
6324 | /**
|
6325 | * Run completion
|
6326 | *
|
6327 | * @public
|
6328 | * @param {CompleteOption} opt
|
6329 | * @param {CancellationToken} token
|
6330 | * @returns {Promise<CompleteResult | null>}
|
6331 | */
|
6332 | doComplete(opt: CompleteOption, token: CancellationToken): ProviderResult<CompleteResult>
|
6333 |
|
6334 | /**
|
6335 | * Action for complete item on complete item selected
|
6336 | *
|
6337 | * @public
|
6338 | * @param {VimCompleteItem} item
|
6339 | * @param {CancellationToken} token
|
6340 | * @returns {Promise<void>}
|
6341 | */
|
6342 | onCompleteResolve?(item: VimCompleteItem, token: CancellationToken): ProviderResult<void>
|
6343 |
|
6344 | /**
|
6345 | * Action for complete item on complete done
|
6346 | *
|
6347 | * @public
|
6348 | * @param {VimCompleteItem} item
|
6349 | * @returns {Promise<void>}
|
6350 | */
|
6351 | onCompleteDone?(item: VimCompleteItem, opt: CompleteOption): ProviderResult<void>
|
6352 |
|
6353 | shouldCommit?(item: VimCompleteItem, character: string): boolean
|
6354 | }
|
6355 |
|
6356 | export namespace sources {
|
6357 | /**
|
6358 | * Names of registered sources.
|
6359 | */
|
6360 | export const names: ReadonlyArray<string>
|
6361 | export const sources: ReadonlyArray<ISource>
|
6362 | /**
|
6363 | * Check if source exists by name.
|
6364 | */
|
6365 | export function has(name: string): boolean
|
6366 | /**
|
6367 | * Get source by name.
|
6368 | */
|
6369 | export function getSource(name: string): ISource | null
|
6370 |
|
6371 | /**
|
6372 | * Add source to sources list.
|
6373 | *
|
6374 | * Note: Use `sources.createSource()` to register new source is recommended for
|
6375 | * user configuration support.
|
6376 | */
|
6377 | export function addSource(source: ISource): Disposable
|
6378 |
|
6379 | /**
|
6380 | * Create source by source config, configurations starts with `coc.source.{name}`
|
6381 | * are automatically supported.
|
6382 | *
|
6383 | * `name` and `doComplete()` must be provided in config.
|
6384 | */
|
6385 | export function createSource(config: SourceConfig): Disposable
|
6386 |
|
6387 | /**
|
6388 | * Get list of all source stats.
|
6389 | */
|
6390 | export function sourceStats(): SourceStat[]
|
6391 |
|
6392 | /**
|
6393 | * Call refresh for _name_ source or all sources.
|
6394 | */
|
6395 | export function refresh(name?: string): Promise<void>
|
6396 |
|
6397 | /**
|
6398 | * Toggle state of _name_ source.
|
6399 | */
|
6400 | export function toggleSource(name: string): void
|
6401 |
|
6402 | /**
|
6403 | * Remove source by name.
|
6404 | */
|
6405 | export function removeSource(name: string): void
|
6406 | }
|
6407 | // }}
|
6408 |
|
6409 | // TreeView related {{
|
6410 | export interface TreeItemLabel {
|
6411 | label: string
|
6412 | highlights?: [number, number][]
|
6413 | }
|
6414 |
|
6415 | export interface TreeItemIcon {
|
6416 | text: string
|
6417 | hlGroup: string
|
6418 | }
|
6419 |
|
6420 | /**
|
6421 | * Collapsible state of the tree item
|
6422 | */
|
6423 | export enum TreeItemCollapsibleState {
|
6424 | /**
|
6425 | * Determines an item can be neither collapsed nor expanded. Implies it has no children.
|
6426 | */
|
6427 | None = 0,
|
6428 | /**
|
6429 | * Determines an item is collapsed
|
6430 | */
|
6431 | Collapsed = 1,
|
6432 | /**
|
6433 | * Determines an item is expanded
|
6434 | */
|
6435 | Expanded = 2
|
6436 | }
|
6437 |
|
6438 | export class TreeItem {
|
6439 | /**
|
6440 | * A human-readable string describing this item. When `falsy`, it is derived from {@link TreeItem.resourceUri resourceUri}.
|
6441 | */
|
6442 | label?: string | TreeItemLabel
|
6443 |
|
6444 | /**
|
6445 | * Description rendered less prominently after label.
|
6446 | */
|
6447 | description?: string
|
6448 |
|
6449 | /**
|
6450 | * The icon path or {@link ThemeIcon} for the tree item.
|
6451 | * When `falsy`, {@link ThemeIcon.Folder Folder Theme Icon} is assigned, if item is collapsible otherwise {@link ThemeIcon.File File Theme Icon}.
|
6452 | * When a file or folder {@link ThemeIcon} is specified, icon is derived from the current file icon theme for the specified theme icon using {@link TreeItem.resourceUri resourceUri} (if provided).
|
6453 | */
|
6454 | icon?: TreeItemIcon
|
6455 |
|
6456 | /**
|
6457 | * Optional id for the tree item that has to be unique across tree. The id is used to preserve the selection and expansion state of the tree item.
|
6458 | *
|
6459 | * If not provided, an id is generated using the tree item's resourceUri when exists. **Note** that when labels change, ids will change and that selection and expansion state cannot be kept stable anymore.
|
6460 | */
|
6461 | id?: string
|
6462 |
|
6463 | /**
|
6464 | * The {@link Uri} of the resource representing this item.
|
6465 | *
|
6466 | * Will be used to derive the {@link TreeItem.label label}, when it is not provided.
|
6467 | * Will be used to derive the icon from current file icon theme, when {@link TreeItem.iconPath iconPath} has {@link ThemeIcon} value.
|
6468 | */
|
6469 | resourceUri?: Uri
|
6470 |
|
6471 | /**
|
6472 | * The tooltip text when you hover over this item.
|
6473 | */
|
6474 | tooltip?: string | MarkupContent
|
6475 |
|
6476 | /**
|
6477 | * The {@link Command} that should be executed when the tree item is selected.
|
6478 | *
|
6479 | * Please use `vscode.open` or `vscode.diff` as command IDs when the tree item is opening
|
6480 | * something in the editor. Using these commands ensures that the resulting editor will
|
6481 | * appear consistent with how other built-in trees open editors.
|
6482 | */
|
6483 | command?: Command
|
6484 |
|
6485 | /**
|
6486 | * {@link TreeItemCollapsibleState} of the tree item.
|
6487 | */
|
6488 | collapsibleState?: TreeItemCollapsibleState
|
6489 |
|
6490 | /**
|
6491 | * @param label A human-readable string describing this item
|
6492 | * @param collapsibleState {@link TreeItemCollapsibleState} of the tree item. Default is {@link TreeItemCollapsibleState.None}
|
6493 | */
|
6494 | constructor(label: string | TreeItemLabel, collapsibleState?: TreeItemCollapsibleState)
|
6495 |
|
6496 | /**
|
6497 | * @param resourceUri The {@link Uri} of the resource representing this item.
|
6498 | * @param collapsibleState {@link TreeItemCollapsibleState} of the tree item. Default is {@link TreeItemCollapsibleState.None}
|
6499 | */
|
6500 | constructor(resourceUri: Uri, collapsibleState?: TreeItemCollapsibleState)
|
6501 | }
|
6502 |
|
6503 | /**
|
6504 | * Action resolved by {@link TreeDataProvider}
|
6505 | */
|
6506 | export interface TreeItemAction<T> {
|
6507 | /**
|
6508 | * Label text in menu.
|
6509 | */
|
6510 | title: string
|
6511 | handler: (item: T) => ProviderResult<void>
|
6512 | }
|
6513 |
|
6514 | /**
|
6515 | * Options for creating a {@link TreeView}
|
6516 | */
|
6517 | export interface TreeViewOptions<T> {
|
6518 | /**
|
6519 | * bufhidden option for TreeView, default to 'wipe'
|
6520 | */
|
6521 | bufhidden?: 'hide' | 'unload' | 'delete' | 'wipe'
|
6522 | /**
|
6523 | * Fixed width for window, default to true
|
6524 | */
|
6525 | winfixwidth?: boolean
|
6526 | /**
|
6527 | * Enable filter feature, default to false
|
6528 | */
|
6529 | enableFilter?: boolean
|
6530 | /**
|
6531 | * Disable indent of leaves without children, default to false
|
6532 | */
|
6533 | disableLeafIndent?: boolean
|
6534 | /**
|
6535 | * A data provider that provides tree data.
|
6536 | */
|
6537 | treeDataProvider: TreeDataProvider<T>
|
6538 | /**
|
6539 | * Whether the tree supports multi-select. When the tree supports multi-select and a command is executed from the tree,
|
6540 | * the first argument to the command is the tree item that the command was executed on and the second argument is an
|
6541 | * array containing all selected tree items.
|
6542 | */
|
6543 | canSelectMany?: boolean
|
6544 | }
|
6545 |
|
6546 | /**
|
6547 | * The event that is fired when an element in the {@link TreeView} is expanded or collapsed
|
6548 | */
|
6549 | export interface TreeViewExpansionEvent<T> {
|
6550 |
|
6551 | /**
|
6552 | * Element that is expanded or collapsed.
|
6553 | */
|
6554 | readonly element: T
|
6555 |
|
6556 | }
|
6557 |
|
6558 | /**
|
6559 | * The event that is fired when there is a change in {@link TreeView.selection tree view's selection}
|
6560 | */
|
6561 | export interface TreeViewSelectionChangeEvent<T> {
|
6562 |
|
6563 | /**
|
6564 | * Selected elements.
|
6565 | */
|
6566 | readonly selection: T[]
|
6567 |
|
6568 | }
|
6569 |
|
6570 | /**
|
6571 | * The event that is fired when there is a change in {@link TreeView.visible tree view's visibility}
|
6572 | */
|
6573 | export interface TreeViewVisibilityChangeEvent {
|
6574 |
|
6575 | /**
|
6576 | * `true` if the {@link TreeView tree view} is visible otherwise `false`.
|
6577 | */
|
6578 | readonly visible: boolean
|
6579 |
|
6580 | }
|
6581 |
|
6582 | /**
|
6583 | * Represents a Tree view
|
6584 | */
|
6585 | export interface TreeView<T> extends Disposable {
|
6586 |
|
6587 | /**
|
6588 | * Event that is fired when an element is expanded
|
6589 | */
|
6590 | readonly onDidExpandElement: Event<TreeViewExpansionEvent<T>>
|
6591 |
|
6592 | /**
|
6593 | * Event that is fired when an element is collapsed
|
6594 | */
|
6595 | readonly onDidCollapseElement: Event<TreeViewExpansionEvent<T>>
|
6596 |
|
6597 | /**
|
6598 | * Currently selected elements.
|
6599 | */
|
6600 | readonly selection: T[]
|
6601 |
|
6602 | /**
|
6603 | * Event that is fired when the {@link TreeView.selection selection} has changed
|
6604 | */
|
6605 | readonly onDidChangeSelection: Event<TreeViewSelectionChangeEvent<T>>
|
6606 |
|
6607 | /**
|
6608 | * Event that is fired when {@link TreeView.visible visibility} has changed
|
6609 | */
|
6610 | readonly onDidChangeVisibility: Event<TreeViewVisibilityChangeEvent>
|
6611 |
|
6612 | /**
|
6613 | * `true` if the {@link TreeView tree view} is visible otherwise `false`.
|
6614 | *
|
6615 | * **NOTE:** is `true` when TreeView visible on other tab.
|
6616 | */
|
6617 | readonly visible: boolean
|
6618 |
|
6619 | /**
|
6620 | * Window id used by TreeView.
|
6621 | */
|
6622 | readonly windowId: number | undefined
|
6623 |
|
6624 | /**
|
6625 | * An optional human-readable message that will be rendered in the view.
|
6626 | * Setting the message to null, undefined, or empty string will remove the message from the view.
|
6627 | */
|
6628 | message?: string
|
6629 |
|
6630 | /**
|
6631 | * The tree view title is initially taken from viewId of TreeView
|
6632 | * Changes to the title property will be properly reflected in the UI in the title of the view.
|
6633 | */
|
6634 | title?: string
|
6635 |
|
6636 | /**
|
6637 | * An optional human-readable description which is rendered less prominently in the title of the view.
|
6638 | * Setting the title description to null, undefined, or empty string will remove the description from the view.
|
6639 | */
|
6640 | description?: string
|
6641 |
|
6642 | /**
|
6643 | * Reveals the given element in the tree view.
|
6644 | * If the tree view is not visible then the tree view is shown and element is revealed.
|
6645 | *
|
6646 | * By default revealed element is selected.
|
6647 | * In order to not to select, set the option `select` to `false`.
|
6648 | * In order to focus, set the option `focus` to `true`.
|
6649 | * In order to expand the revealed element, set the option `expand` to `true`. To expand recursively set `expand` to the number of levels to expand.
|
6650 | * **NOTE:** You can expand only to 3 levels maximum.
|
6651 | *
|
6652 | * **NOTE:** The {@link TreeDataProvider} that the `TreeView` {@link window.createTreeView is registered with} with must implement {@link TreeDataProvider.getParent getParent} method to access this API.
|
6653 | */
|
6654 | reveal(element: T, options?: { select?: boolean, focus?: boolean, expand?: boolean | number }): Thenable<void>
|
6655 |
|
6656 | /**
|
6657 | * Create tree view in new window.
|
6658 | *
|
6659 | * **NOTE:** TreeView with same viewId in current tab would be disposed.
|
6660 | *
|
6661 | * @param splitCommand The command to open TreeView window, default to 'belowright 30vs'
|
6662 | * @return `true` if window shown.
|
6663 | */
|
6664 | show(splitCommand?: string): Promise<boolean>
|
6665 | }
|
6666 |
|
6667 | /**
|
6668 | * A data provider that provides tree data
|
6669 | */
|
6670 | export interface TreeDataProvider<T> {
|
6671 | /**
|
6672 | * An optional event to signal that an element or root has changed.
|
6673 | * This will trigger the view to update the changed element/root and its children recursively (if shown).
|
6674 | * To signal that root has changed, do not pass any argument or pass `undefined` or `null`.
|
6675 | */
|
6676 | onDidChangeTreeData?: Event<T | undefined | null | void>
|
6677 |
|
6678 | /**
|
6679 | * Get {@link TreeItem} representation of the `element`
|
6680 | *
|
6681 | * @param element The element for which {@link TreeItem} representation is asked for.
|
6682 | * @return {@link TreeItem} representation of the element
|
6683 | */
|
6684 | getTreeItem(element: T): TreeItem | Thenable<TreeItem>
|
6685 |
|
6686 | /**
|
6687 | * Get the children of `element` or root if no element is passed.
|
6688 | *
|
6689 | * @param element The element from which the provider gets children. Can be `undefined`.
|
6690 | * @return Children of `element` or root if no element is passed.
|
6691 | */
|
6692 | getChildren(element?: T): ProviderResult<T[]>
|
6693 |
|
6694 | /**
|
6695 | * Optional method to return the parent of `element`.
|
6696 | * Return `null` or `undefined` if `element` is a child of root.
|
6697 | *
|
6698 | * **NOTE:** This method should be implemented in order to access {@link TreeView.reveal reveal} API.
|
6699 | *
|
6700 | * @param element The element for which the parent has to be returned.
|
6701 | * @return Parent of `element`.
|
6702 | */
|
6703 | getParent?(element: T): ProviderResult<T>
|
6704 |
|
6705 | /**
|
6706 | * Called on hover to resolve the {@link TreeItem.tooltip TreeItem} property if it is undefined.
|
6707 | * Called on tree item click/open to resolve the {@link TreeItem.command TreeItem} property if it is undefined.
|
6708 | * Only properties that were undefined can be resolved in `resolveTreeItem`.
|
6709 | * Functionality may be expanded later to include being called to resolve other missing
|
6710 | * properties on selection and/or on open.
|
6711 | *
|
6712 | * Will only ever be called once per TreeItem.
|
6713 | *
|
6714 | * onDidChangeTreeData should not be triggered from within resolveTreeItem.
|
6715 | *
|
6716 | * *Note* that this function is called when tree items are already showing in the UI.
|
6717 | * Because of that, no property that changes the presentation (label, description, etc.)
|
6718 | * can be changed.
|
6719 | *
|
6720 | * @param item Undefined properties of `item` should be set then `item` should be returned.
|
6721 | * @param element The object associated with the TreeItem.
|
6722 | * @param token A cancellation token.
|
6723 | * @return The resolved tree item or a thenable that resolves to such. It is OK to return the given
|
6724 | * `item`. When no result is returned, the given `item` will be used.
|
6725 | */
|
6726 | resolveTreeItem?(item: TreeItem, element: T, token: CancellationToken): ProviderResult<TreeItem>
|
6727 |
|
6728 | /**
|
6729 | * Called with current element to resolve actions.
|
6730 | * Called when user press 'actions' key.
|
6731 | *
|
6732 | * @param item Resolved item.
|
6733 | * @param element The object under cursor.
|
6734 | */
|
6735 | resolveActions?(item: TreeItem, element: T): ProviderResult<TreeItemAction<T>[]>
|
6736 | }
|
6737 | // }}
|
6738 |
|
6739 | // workspace module {{
|
6740 | /**
|
6741 | * An event describing the change in Configuration
|
6742 | */
|
6743 | export interface ConfigurationChangeEvent {
|
6744 |
|
6745 | /**
|
6746 | * Returns `true` if the given section for the given resource (if provided) is affected.
|
6747 | *
|
6748 | * @param section Configuration name, supports _dotted_ names.
|
6749 | * @param resource A resource URI.
|
6750 | * @return `true` if the given section for the given resource (if provided) is affected.
|
6751 | */
|
6752 | affectsConfiguration(section: string, scope?: ConfigurationScope): boolean
|
6753 | }
|
6754 |
|
6755 | export interface WillSaveEvent extends TextDocumentWillSaveEvent {
|
6756 | /**
|
6757 | * Allows to pause the event loop and to apply [pre-save-edits](#TextEdit).
|
6758 | * Edits of subsequent calls to this function will be applied in order. The
|
6759 | * edits will be *ignored* if concurrent modifications of the document happened.
|
6760 | *
|
6761 | * *Note:* This function can only be called during event dispatch and not
|
6762 | * in an asynchronous manner:
|
6763 | *
|
6764 | * ```ts
|
6765 | * workspace.onWillSaveTextDocument(event => {
|
6766 | * // async, will *throw* an error
|
6767 | * setTimeout(() => event.waitUntil(promise));
|
6768 | *
|
6769 | * // sync, OK
|
6770 | * event.waitUntil(promise);
|
6771 | * })
|
6772 | * ```
|
6773 | *
|
6774 | * @param thenable A thenable that resolves to [pre-save-edits](#TextEdit).
|
6775 | */
|
6776 | waitUntil(thenable: Thenable<TextEdit[] | any>): void
|
6777 | }
|
6778 |
|
6779 | export interface KeymapOption {
|
6780 | /**
|
6781 | * Use request instead of notify, default true
|
6782 | */
|
6783 | sync: boolean
|
6784 | /**
|
6785 | * Cancel completion before invoke callback, default true
|
6786 | */
|
6787 | cancel: boolean
|
6788 | /**
|
6789 | * Use <silent> for keymap, default false
|
6790 | */
|
6791 | silent: boolean
|
6792 | /**
|
6793 | * Enable repeat support for repeat.vim, default false
|
6794 | */
|
6795 | repeat: boolean
|
6796 | }
|
6797 |
|
6798 | export interface DidChangeTextDocumentParams {
|
6799 | /**
|
6800 | * The document that did change. The version number points
|
6801 | * to the version after all provided content changes have
|
6802 | * been applied.
|
6803 | */
|
6804 | readonly textDocument: {
|
6805 | version: number
|
6806 | uri: string
|
6807 | }
|
6808 | /**
|
6809 | * The actual content changes. The content changes describe single state changes
|
6810 | * to the document. So if there are two content changes c1 (at array index 0) and
|
6811 | * c2 (at array index 1) for a document in state S then c1 moves the document from
|
6812 | * S to S' and c2 from S' to S''. So c1 is computed on the state S and c2 is computed
|
6813 | * on the state S'.
|
6814 | */
|
6815 | readonly contentChanges: ReadonlyArray<TextDocumentContentChange>
|
6816 | /**
|
6817 | * Buffer number of document.
|
6818 | */
|
6819 | readonly bufnr: number
|
6820 | /**
|
6821 | * Original content before change
|
6822 | */
|
6823 | readonly original: string
|
6824 | /**
|
6825 | * Original lines before change
|
6826 | */
|
6827 | readonly originalLines: ReadonlyArray<string>
|
6828 | }
|
6829 |
|
6830 | export interface EditerState {
|
6831 | document: LinesTextDocument
|
6832 | position: Position
|
6833 | }
|
6834 |
|
6835 | export type MapMode = 'n' | 'i' | 'v' | 'x' | 's' | 'o'
|
6836 |
|
6837 | export interface Autocmd {
|
6838 | /**
|
6839 | * Vim event or event set.
|
6840 | */
|
6841 | event: string | string[]
|
6842 | /**
|
6843 | * Callback functions that called with evaled arguments.
|
6844 | */
|
6845 | callback: Function
|
6846 | /**
|
6847 | * Match pattern, default to `*`.
|
6848 | */
|
6849 | pattern?: string
|
6850 | /**
|
6851 | * Vim expression that eval to arguments of callback, default to `[]`
|
6852 | */
|
6853 | arglist?: string[]
|
6854 | /**
|
6855 | * Use request when `true`, use notification by default.
|
6856 | */
|
6857 | request?: boolean
|
6858 | /**
|
6859 | * `this` of callback.
|
6860 | */
|
6861 | thisArg?: any
|
6862 | }
|
6863 |
|
6864 | export interface Env {
|
6865 | /**
|
6866 | * |runtimepath| option of (neo)vim.
|
6867 | */
|
6868 | readonly runtimepath: string
|
6869 | /**
|
6870 | * |virtualText| support in (neo)vim, needs nvim >= 0.5.0 or vim >= 9.0067
|
6871 | */
|
6872 | readonly virtualText: boolean
|
6873 | /**
|
6874 | * |guicursor| option of (neo)vim
|
6875 | */
|
6876 | readonly guicursor: string
|
6877 | /**
|
6878 | * Could use float window on neovim, always false on vim.
|
6879 | */
|
6880 | readonly floating: boolean
|
6881 | /**
|
6882 | * |sign_place()| and |sign_unplace()| can be used when true.
|
6883 | */
|
6884 | readonly sign: boolean
|
6885 | /**
|
6886 | * Root directory of extensions.
|
6887 | */
|
6888 | readonly extensionRoot: string
|
6889 | /**
|
6890 | * Process id of (neo)vim.
|
6891 | */
|
6892 | readonly pid: number
|
6893 | /**
|
6894 | * Total columns of screen.
|
6895 | */
|
6896 | readonly columns: number
|
6897 | /**
|
6898 | * Total lines of screen.
|
6899 | */
|
6900 | readonly lines: number
|
6901 | /**
|
6902 | * Is true when |CompleteChanged| event is supported.
|
6903 | */
|
6904 | readonly pumevent: boolean
|
6905 | /**
|
6906 | * |cmdheight| option of (neo)vim.
|
6907 | */
|
6908 | readonly cmdheight: number
|
6909 | /**
|
6910 | * Value of |g:coc_filetype_map|
|
6911 | */
|
6912 | readonly filetypeMap: { [index: string]: string }
|
6913 | /**
|
6914 | * Is true when not using neovim.
|
6915 | */
|
6916 | readonly isVim: boolean
|
6917 | /**
|
6918 | * Is cygvim when true.
|
6919 | */
|
6920 | readonly isCygwin: boolean
|
6921 | /**
|
6922 | * Is macvim when true.
|
6923 | */
|
6924 | readonly isMacvim: boolean
|
6925 | /**
|
6926 | * Is true when iTerm.app is used on mac.
|
6927 | */
|
6928 | readonly isiTerm: boolean
|
6929 | /**
|
6930 | * version of (neo)vim, on vim it's like: 8020750, on neoivm it's like: 0.5.0
|
6931 | */
|
6932 | readonly version: string
|
6933 | /**
|
6934 | * |v:progpath| value, could be empty.
|
6935 | */
|
6936 | readonly progpath: string
|
6937 | /**
|
6938 | * Is true when dialog feature is supported, which need vim >= 8.2.750 or neovim >= 0.4.0
|
6939 | */
|
6940 | readonly dialog: boolean
|
6941 | /**
|
6942 | * Is true when vim's textprop is supported.
|
6943 | */
|
6944 | readonly textprop: boolean
|
6945 | }
|
6946 |
|
6947 | /**
|
6948 | * Store & retrieve most recent used items.
|
6949 | */
|
6950 | export interface Mru {
|
6951 | /**
|
6952 | * Load iems from mru file
|
6953 | */
|
6954 |
|
6955 | load(): Promise<string[]>
|
6956 | /**
|
6957 | * Add item to mru file.
|
6958 | */
|
6959 | add(item: string): Promise<void>
|
6960 |
|
6961 | /**
|
6962 | * Remove item from mru file.
|
6963 | */
|
6964 |
|
6965 | remove(item: string): Promise<void>
|
6966 |
|
6967 | /**
|
6968 | * Remove the data file.
|
6969 | */
|
6970 | clean(): Promise<void>
|
6971 | }
|
6972 |
|
6973 | /**
|
6974 | * Option to create task that runs in (neo)vim.
|
6975 | */
|
6976 | export interface TaskOptions {
|
6977 | /**
|
6978 | * The command to run, without arguments
|
6979 | */
|
6980 | cmd: string
|
6981 | /**
|
6982 | * Arguments of command.
|
6983 | */
|
6984 | args?: string[]
|
6985 | /**
|
6986 | * Current working directory of the task, Default to current vim's cwd.
|
6987 | */
|
6988 | cwd?: string
|
6989 | /**
|
6990 | * Additional environment key-value pairs.
|
6991 | */
|
6992 | env?: { [key: string]: string }
|
6993 | /**
|
6994 | * Use pty when true.
|
6995 | */
|
6996 | pty?: boolean
|
6997 | /**
|
6998 | * Detach child process when true.
|
6999 | */
|
7000 | detach?: boolean
|
7001 | }
|
7002 |
|
7003 | /**
|
7004 | * Controls long running task started by (neo)vim.
|
7005 | * Useful to keep the task running after CocRestart.
|
7006 | */
|
7007 | export interface Task extends Disposable {
|
7008 | /**
|
7009 | * Fired on task exit with exit code.
|
7010 | */
|
7011 | onExit: Event<number>
|
7012 | /**
|
7013 | * Fired with lines on stdout received.
|
7014 | */
|
7015 | onStdout: Event<string[]>
|
7016 | /**
|
7017 | * Fired with lines on stderr received.
|
7018 | */
|
7019 | onStderr: Event<string[]>
|
7020 | /**
|
7021 | * Start task, task will be restarted when already running.
|
7022 | *
|
7023 | * @param {TaskOptions} opts
|
7024 | * @returns {Promise<boolean>}
|
7025 | */
|
7026 | start(opts: TaskOptions): Promise<boolean>
|
7027 | /**
|
7028 | * Stop task by SIGTERM or SIGKILL
|
7029 | */
|
7030 | stop(): Promise<void>
|
7031 | /**
|
7032 | * Check if the task is running.
|
7033 | */
|
7034 | running: Promise<boolean>
|
7035 | }
|
7036 |
|
7037 | /**
|
7038 | * A simple json database.
|
7039 | */
|
7040 | export interface JsonDB {
|
7041 | filepath: string
|
7042 | /**
|
7043 | * Get data by key.
|
7044 | *
|
7045 | * @param {string} key unique key allows dot notation.
|
7046 | * @returns {any}
|
7047 | */
|
7048 | fetch(key: string): any
|
7049 | /**
|
7050 | * Check if key exists
|
7051 | *
|
7052 | * @param {string} key unique key allows dot notation.
|
7053 | */
|
7054 | exists(key: string): boolean
|
7055 | /**
|
7056 | * Delete data by key
|
7057 | *
|
7058 | * @param {string} key unique key allows dot notation.
|
7059 | */
|
7060 | delete(key: string): void
|
7061 | /**
|
7062 | * Save data with key
|
7063 | */
|
7064 | push(key: string, data: number | null | boolean | string | { [index: string]: any }): void
|
7065 | /**
|
7066 | * Empty db file.
|
7067 | */
|
7068 | clear(): void
|
7069 | /**
|
7070 | * Remove db file.
|
7071 | */
|
7072 | destroy(): void
|
7073 | }
|
7074 |
|
7075 | export interface RenameEvent {
|
7076 | oldUri: Uri
|
7077 | newUri: Uri
|
7078 | }
|
7079 |
|
7080 | export interface FileSystemWatcher {
|
7081 | readonly ignoreCreateEvents: boolean
|
7082 | readonly ignoreChangeEvents: boolean
|
7083 | readonly ignoreDeleteEvents: boolean
|
7084 | readonly onDidCreate: Event<Uri>
|
7085 | readonly onDidChange: Event<Uri>
|
7086 | readonly onDidDelete: Event<Uri>
|
7087 | readonly onDidRename: Event<RenameEvent>
|
7088 | dispose(): void
|
7089 | }
|
7090 |
|
7091 | export type ConfigurationScope = string | null | Uri | TextDocument | WorkspaceFolder | { uri?: string; languageId?: string }
|
7092 |
|
7093 | export interface ConfigurationInspect<T> {
|
7094 | key: string
|
7095 | defaultValue?: T
|
7096 | globalValue?: T
|
7097 | workspaceValue?: T
|
7098 | workspaceFolderValue?: T
|
7099 | }
|
7100 |
|
7101 | export interface WorkspaceConfiguration {
|
7102 | /**
|
7103 | * Return a value from this configuration.
|
7104 | *
|
7105 | * @param section Configuration name, supports _dotted_ names.
|
7106 | * @return The value `section` denotes or `undefined`.
|
7107 | */
|
7108 | get<T>(section: string): T | undefined
|
7109 |
|
7110 | /**
|
7111 | * Return a value from this configuration.
|
7112 | *
|
7113 | * @param section Configuration name, supports _dotted_ names.
|
7114 | * @param defaultValue A value should be returned when no value could be found, is `undefined`.
|
7115 | * @return The value `section` denotes or the default.
|
7116 | */
|
7117 | get<T>(section: string, defaultValue: T): T
|
7118 |
|
7119 | /**
|
7120 | * Check if this configuration has a certain value.
|
7121 | *
|
7122 | * @param section Configuration name, supports _dotted_ names.
|
7123 | * @return `true` if the section doesn't resolve to `undefined`.
|
7124 | */
|
7125 | has(section: string): boolean
|
7126 |
|
7127 | /**
|
7128 | * Retrieve all information about a configuration setting. A configuration value
|
7129 | * often consists of a *default* value, a global or installation-wide value,
|
7130 | * a workspace-specific value
|
7131 | *
|
7132 | * *Note:* The configuration name must denote a leaf in the configuration tree
|
7133 | * (`editor.fontSize` vs `editor`) otherwise no result is returned.
|
7134 | *
|
7135 | * @param section Configuration name, supports _dotted_ names.
|
7136 | * @return Information about a configuration setting or `undefined`.
|
7137 | */
|
7138 | inspect<T>(section: string): ConfigurationInspect<T> | undefined
|
7139 | /**
|
7140 | * Update a configuration value. The updated configuration values are persisted.
|
7141 | *
|
7142 | *
|
7143 | * @param section Configuration name, supports _dotted_ names.
|
7144 | * @param value The new value.
|
7145 | * @param isUser if true, always update user configuration
|
7146 | */
|
7147 | update(section: string, value: any, isUser?: boolean): Thenable<void>
|
7148 |
|
7149 | /**
|
7150 | * Readable dictionary that backs this configuration.
|
7151 | */
|
7152 | readonly [key: string]: any
|
7153 | }
|
7154 |
|
7155 | export interface BufferSyncItem {
|
7156 | /**
|
7157 | * Called on buffer unload.
|
7158 | */
|
7159 | dispose: () => void
|
7160 | /**
|
7161 | * Called on buffer content change.
|
7162 | */
|
7163 | onChange?(e: DidChangeTextDocumentParams): void
|
7164 | /**
|
7165 | * Called on TextChangedI & TextChanged events.
|
7166 | */
|
7167 | onTextChange?(): void
|
7168 | }
|
7169 |
|
7170 | export interface BufferSync<T extends BufferSyncItem> {
|
7171 | /**
|
7172 | * Current items.
|
7173 | */
|
7174 | readonly items: Iterable<T>
|
7175 | /**
|
7176 | * Get created item by uri
|
7177 | */
|
7178 | getItem(uri: string): T | undefined
|
7179 | /**
|
7180 | * Get created item by bufnr
|
7181 | */
|
7182 | getItem(bufnr: number): T | undefined
|
7183 | dispose: () => void
|
7184 | }
|
7185 |
|
7186 | export interface FuzzyMatchResult {
|
7187 | score: number,
|
7188 | positions: Uint32Array
|
7189 | }
|
7190 |
|
7191 | export interface FuzzyMatchHighlights {
|
7192 | score: number
|
7193 | highlights: AnsiHighlight[]
|
7194 | }
|
7195 |
|
7196 | /**
|
7197 | * An array representing a fuzzy match.
|
7198 | *
|
7199 | * 0. the score
|
7200 | * 1. the offset at which matching started
|
7201 | * 2. `<match_pos_N>`
|
7202 | * 3. `<match_pos_1>`
|
7203 | * 4. `<match_pos_0>` etc
|
7204 | */
|
7205 | export type FuzzyScore = [score: number, wordStart: number, ...matches: number[]]
|
7206 |
|
7207 | export interface FuzzyScoreOptions {
|
7208 | readonly boostFullMatch: boolean
|
7209 | /**
|
7210 | * Allows first match to be a weak match
|
7211 | */
|
7212 | readonly firstMatchCanBeWeak: boolean
|
7213 | }
|
7214 |
|
7215 | /**
|
7216 | * Match kinds could be:
|
7217 | *
|
7218 | * - 'aggressive' with fixed match for permutations.
|
7219 | * - 'any' fast match with first 13 characters only.
|
7220 | * - 'normal' nothing special.
|
7221 | */
|
7222 | export type FuzzyKind = 'normal' | 'aggressive' | 'any'
|
7223 |
|
7224 | export type ScoreFunction = (word: string, wordPos?: number) => FuzzyScore | undefined
|
7225 |
|
7226 | export interface FuzzyMatch {
|
7227 |
|
7228 | /**
|
7229 | * Create 0 index byte spans from matched text and FuzzyScore.
|
7230 | * Mostly used for create {@link HighlightItem highlight items}.
|
7231 | *
|
7232 | * @param {string} text The matched text for count bytes.
|
7233 | * @param {FuzzyScore} score
|
7234 | * @returns {Iterable<[number, number]>}
|
7235 | */
|
7236 | matchScoreSpans(text: string, score: FuzzyScore): Iterable<[number, number]>
|
7237 |
|
7238 | /**
|
7239 | *
|
7240 | * Create a score function
|
7241 | *
|
7242 | * @param {string} pattern The pattern to match.
|
7243 | * @param {number} patternPos Start character index of pattern.
|
7244 | * @param {FuzzyScoreOptions} options Optional option.
|
7245 | * @param {FuzzyKind} kind Use 'normal' when undefined.
|
7246 | * @returns {ScoreFunction}
|
7247 | */
|
7248 | createScoreFunction(pattern: string, patternPos: number, options?: FuzzyScoreOptions, kind?: FuzzyKind): ScoreFunction
|
7249 |
|
7250 | /**
|
7251 | * Initialize match by set the match pattern and matchSeq.
|
7252 | *
|
7253 | * @param {string} pattern The match pattern Limited length to 256.
|
7254 | * @param {boolean} matchSeq Match the sequence characters instead of split pattern by white spaces.
|
7255 | * @returns {void}
|
7256 | */
|
7257 | setPattern(pattern: string, matchSeq?: boolean): void
|
7258 | /**
|
7259 | * Get the match result of text including score and character index
|
7260 | * positions, return undefined when no match found.
|
7261 | *
|
7262 | * @param {string} text Content to match
|
7263 | * @returns {FuzzyMatchResult | undefined}
|
7264 | */
|
7265 | match(text: string): FuzzyMatchResult | undefined
|
7266 | /**
|
7267 | * Match character positions to column spans.
|
7268 | * Better than matchHighlights method by reduce iteration.
|
7269 | *
|
7270 | * @param {string} text Context to match
|
7271 | * @param {ArrayLike<number>} positions Matched character index positions.
|
7272 | * @param {number} max Maximum column number to calculate
|
7273 | * @returns {Iterable<[number, number]>}
|
7274 | */
|
7275 | matchSpans(text: string, positions: ArrayLike<number>, max?: number): Iterable<[number, number]>
|
7276 | /**
|
7277 | * Get the match highlights result, including score and highlight items.
|
7278 | * Return undefined when no match found.
|
7279 | *
|
7280 | * @param {string} text Content to match
|
7281 | * @returns {FuzzyMatchHighlights | undefined}
|
7282 | */
|
7283 | matchHighlights(text: string, hlGroup: string): FuzzyMatchHighlights | undefined
|
7284 | }
|
7285 |
|
7286 | export namespace workspace {
|
7287 | export const nvim: Neovim
|
7288 | /**
|
7289 | * Current buffer number, could be wrong since vim could not send autocmd as expected.
|
7290 | *
|
7291 | * @deprecated will be removed in the feature.
|
7292 | */
|
7293 | export const bufnr: number
|
7294 | /**
|
7295 | * Current document.
|
7296 | */
|
7297 | export const document: Promise<Document>
|
7298 | /**
|
7299 | * Environments or current (neo)vim.
|
7300 | */
|
7301 | export const env: Env
|
7302 | /**
|
7303 | * Float window or popup can work.
|
7304 | */
|
7305 | export const floatSupported: boolean
|
7306 | /**
|
7307 | * Current working directory of vim.
|
7308 | */
|
7309 | export const cwd: string
|
7310 | /**
|
7311 | * Current workspace root.
|
7312 | */
|
7313 | export const root: string
|
7314 | /**
|
7315 | * @deprecated aliased to root.
|
7316 | */
|
7317 | export const rootPath: string
|
7318 | /**
|
7319 | * Not neovim when true.
|
7320 | */
|
7321 | export const isVim: boolean
|
7322 | /**
|
7323 | * Is neovim when true.
|
7324 | */
|
7325 | export const isNvim: boolean
|
7326 | /**
|
7327 | * All filetypes of loaded documents.
|
7328 | */
|
7329 | export const filetypes: ReadonlySet<string>
|
7330 | /**
|
7331 | * All languageIds of loaded documents.
|
7332 | */
|
7333 | export const languageIds: ReadonlySet<string>
|
7334 | /**
|
7335 | * Root directory of coc.nvim
|
7336 | */
|
7337 | export const pluginRoot: string
|
7338 | /**
|
7339 | * Exists channel names.
|
7340 | */
|
7341 | export const channelNames: ReadonlyArray<string>
|
7342 | /**
|
7343 | * Loaded documents that attached.
|
7344 | */
|
7345 | export const documents: ReadonlyArray<Document>
|
7346 | /**
|
7347 | * Current document array.
|
7348 | */
|
7349 | export const textDocuments: ReadonlyArray<LinesTextDocument>
|
7350 | /**
|
7351 | * Current workspace folders.
|
7352 | */
|
7353 | export const workspaceFolders: ReadonlyArray<WorkspaceFolder>
|
7354 | /**
|
7355 | * Directory paths of workspaceFolders.
|
7356 | */
|
7357 | export const folderPaths: ReadonlyArray<string>
|
7358 | /**
|
7359 | * Current workspace folder, could be null when vim started from user's home.
|
7360 | *
|
7361 | * @deprecated
|
7362 | */
|
7363 | export const workspaceFolder: WorkspaceFolder | null
|
7364 | export const onDidCreateFiles: Event<FileCreateEvent>
|
7365 | export const onDidRenameFiles: Event<FileRenameEvent>
|
7366 | export const onDidDeleteFiles: Event<FileDeleteEvent>
|
7367 | export const onWillCreateFiles: Event<FileWillCreateEvent>
|
7368 | export const onWillRenameFiles: Event<FileWillRenameEvent>
|
7369 | export const onWillDeleteFiles: Event<FileWillDeleteEvent>
|
7370 | /**
|
7371 | * Event fired on workspace folder change.
|
7372 | */
|
7373 | export const onDidChangeWorkspaceFolders: Event<WorkspaceFoldersChangeEvent>
|
7374 | /**
|
7375 | * Event fired after document create.
|
7376 | */
|
7377 | export const onDidOpenTextDocument: Event<LinesTextDocument & { bufnr: number }>
|
7378 | /**
|
7379 | * Event fired after document unload.
|
7380 | */
|
7381 | export const onDidCloseTextDocument: Event<LinesTextDocument & { bufnr: number }>
|
7382 | /**
|
7383 | * Event fired on document change.
|
7384 | */
|
7385 | export const onDidChangeTextDocument: Event<DidChangeTextDocumentParams>
|
7386 | /**
|
7387 | * Event fired before document save.
|
7388 | */
|
7389 | export const onWillSaveTextDocument: Event<WillSaveEvent>
|
7390 | /**
|
7391 | * Event fired after document save.
|
7392 | */
|
7393 | export const onDidSaveTextDocument: Event<LinesTextDocument>
|
7394 |
|
7395 | /**
|
7396 | * Event fired on configuration change. Configuration change could by many
|
7397 | * reasons, including:
|
7398 | *
|
7399 | * - Changes detected from `coc-settings.json`.
|
7400 | * - Change to document that using another configuration file.
|
7401 | * - Configuration change by call update API of WorkspaceConfiguration.
|
7402 | */
|
7403 | export const onDidChangeConfiguration: Event<ConfigurationChangeEvent>
|
7404 |
|
7405 | /**
|
7406 | * Fired when vim's runtimepath change detected.
|
7407 | */
|
7408 | export const onDidRuntimePathChange: Event<ReadonlyArray<string>>
|
7409 |
|
7410 | /**
|
7411 | * Returns a path that is relative to the workspace folder or folders.
|
7412 | *
|
7413 | * When there are no {@link workspace.workspaceFolders workspace folders} or when the path
|
7414 | * is not contained in them, the input is returned.
|
7415 | *
|
7416 | * @param pathOrUri A path or uri. When a uri is given its {@link Uri.fsPath fsPath} is used.
|
7417 | * @param includeWorkspaceFolder When `true` and when the given path is contained inside a
|
7418 | * workspace folder the name of the workspace is prepended. Defaults to `true` when there are
|
7419 | * multiple workspace folders and `false` otherwise.
|
7420 | * @return A path relative to the root or the input.
|
7421 | */
|
7422 | export function asRelativePath(pathOrUri: string | Uri, includeWorkspaceFolder?: boolean): string
|
7423 |
|
7424 | /**
|
7425 | * Opens a document. Will return early if this document is already open. Otherwise
|
7426 | * the document is loaded and the {@link workspace.onDidOpenTextDocument didOpen}-event fires.
|
7427 | *
|
7428 | * The document is denoted by an {@link Uri}. Depending on the {@link Uri.scheme scheme} the
|
7429 | * following rules apply:
|
7430 | * * `file`-scheme: Open a file on disk (`openTextDocument(Uri.file(path))`). Will be rejected if the file
|
7431 | * does not exist or cannot be loaded.
|
7432 | * * `untitled`-scheme: Open a blank untitled file with associated path (`openTextDocument(Uri.file(path).with({ scheme: 'untitled' }))`).
|
7433 | * The language will be derived from the file name.
|
7434 | * * For all other schemes contributed {@link TextDocumentContentProvider text document content providers} and
|
7435 | * {@link FileSystemProvider file system providers} are consulted.
|
7436 | *
|
7437 | * *Note* that the lifecycle of the returned document is owned by the editor and not by the extension. That means an
|
7438 | * {@linkcode workspace.onDidCloseTextDocument onDidClose}-event can occur at any time after opening it.
|
7439 | *
|
7440 | * @param uri Identifies the resource to open.
|
7441 | * @return A promise that resolves to a {@link Document document}.
|
7442 | */
|
7443 | export function openTextDocument(uri: Uri): Thenable<Document>
|
7444 |
|
7445 | /**
|
7446 | * A short-hand for `openTextDocument(Uri.file(fileName))`.
|
7447 | *
|
7448 | * @see {@link openTextDocument}
|
7449 | * @param fileName A name of a file on disk.
|
7450 | * @return A promise that resolves to a {@link Document document}.
|
7451 | */
|
7452 | export function openTextDocument(fileName: string): Thenable<Document>
|
7453 |
|
7454 | /**
|
7455 | * Create new namespace id by name.
|
7456 | *
|
7457 | * @deprecated Latest neovim requires namespace created by neoivm.
|
7458 | */
|
7459 | export function createNameSpace(name: string): number
|
7460 |
|
7461 | /**
|
7462 | * Get display cell count of text on vim.
|
7463 | * Control character below 0x80 are considered as 1.
|
7464 | *
|
7465 | * @param text Text to display.
|
7466 | * @return The cells count.
|
7467 | */
|
7468 | export function getDisplayWidth(text: string, cache?: boolean): number
|
7469 | /**
|
7470 | * Like vim's has(), but for version check only.
|
7471 | * Check patch on neovim and check nvim on vim would return false.
|
7472 | *
|
7473 | * For example:
|
7474 | * - has('nvim-0.6.0')
|
7475 | * - has('patch-7.4.248')
|
7476 | */
|
7477 | export function has(feature: string): boolean
|
7478 |
|
7479 | /**
|
7480 | * Register autocmd on vim.
|
7481 | *
|
7482 | * Note: avoid request autocmd when possible since vim could be blocked
|
7483 | * forever when request triggered during request.
|
7484 | */
|
7485 | export function registerAutocmd(autocmd: Autocmd): Disposable
|
7486 |
|
7487 | /**
|
7488 | * Watch for vim's global option change.
|
7489 | */
|
7490 | export function watchOption(key: string, callback: (oldValue: any, newValue: any) => Thenable<void> | void, disposables?: Disposable[]): void
|
7491 |
|
7492 | /**
|
7493 | * Watch for vim's global variable change, works on neovim only.
|
7494 | */
|
7495 | export function watchGlobal(key: string, callback?: (oldValue: any, newValue: any) => Thenable<void> | void, disposables?: Disposable[]): void
|
7496 |
|
7497 | /**
|
7498 | * Check if selector match document.
|
7499 | */
|
7500 | export function match(selector: DocumentSelector, document: LinesTextDocument): number
|
7501 |
|
7502 | /**
|
7503 | * Findup from filename or filenames from current filepath or root.
|
7504 | *
|
7505 | * @return fullpath of file or null when not found.
|
7506 | */
|
7507 | export function findUp(filename: string | string[]): Promise<string | null>
|
7508 |
|
7509 | /**
|
7510 | * Get possible watchman binary path.
|
7511 | */
|
7512 | export function getWatchmanPath(): string | null
|
7513 |
|
7514 | /**
|
7515 | * Get configuration by section and optional resource uri.
|
7516 | */
|
7517 | export function getConfiguration(section?: string, scope?: ConfigurationScope): WorkspaceConfiguration
|
7518 |
|
7519 | /**
|
7520 | * Resolve internal json schema, uri should starts with `vscode://`
|
7521 | */
|
7522 | export function resolveJSONSchema(uri: string): any
|
7523 | /**
|
7524 | * Get created document by uri or bufnr.
|
7525 | */
|
7526 | export function getDocument(uri: number | string): Document
|
7527 |
|
7528 | /**
|
7529 | * Apply WorkspaceEdit.
|
7530 | */
|
7531 | export function applyEdit(edit: WorkspaceEdit): Promise<boolean>
|
7532 |
|
7533 | /**
|
7534 | * Convert location to quickfix item.
|
7535 | */
|
7536 | export function getQuickfixItem(loc: Location | LocationLink, text?: string, type?: string, module?: string): Promise<QuickfixItem>
|
7537 |
|
7538 | /**
|
7539 | * Convert locations to quickfix list.
|
7540 | */
|
7541 | export function getQuickfixList(locations: Location[]): Promise<ReadonlyArray<QuickfixItem>>
|
7542 |
|
7543 | /**
|
7544 | * Populate locations to UI.
|
7545 | */
|
7546 | export function showLocations(locations: Location[]): Promise<void>
|
7547 |
|
7548 | /**
|
7549 | * Get content of line by uri and line.
|
7550 | */
|
7551 | export function getLine(uri: string, line: number): Promise<string>
|
7552 |
|
7553 | /**
|
7554 | * Get WorkspaceFolder of uri
|
7555 | */
|
7556 | export function getWorkspaceFolder(uri: string): WorkspaceFolder | undefined
|
7557 |
|
7558 | /**
|
7559 | * Get content from buffer or file by uri.
|
7560 | */
|
7561 | export function readFile(uri: string): Promise<string>
|
7562 |
|
7563 | /**
|
7564 | * Get current document and position.
|
7565 | */
|
7566 | export function getCurrentState(): Promise<EditerState>
|
7567 |
|
7568 | /**
|
7569 | * Get format options of uri or current buffer.
|
7570 | */
|
7571 | export function getFormatOptions(uri?: string): Promise<FormattingOptions>
|
7572 |
|
7573 | /**
|
7574 | * Jump to location.
|
7575 | */
|
7576 | export function jumpTo(uri: string, position?: Position | null, openCommand?: string): Promise<void>
|
7577 |
|
7578 | /**
|
7579 | * Create a file in vim and disk
|
7580 | */
|
7581 | export function createFile(filepath: string, opts?: CreateFileOptions): Promise<void>
|
7582 |
|
7583 | /**
|
7584 | * Load uri as document, buffer would be invisible if not loaded.
|
7585 | */
|
7586 | export function loadFile(uri: string): Promise<Document>
|
7587 |
|
7588 | /**
|
7589 | * Load the files that not loaded
|
7590 | */
|
7591 | export function loadFiles(uris: string[]): Promise<void>
|
7592 |
|
7593 | /**
|
7594 | * Rename file in vim and disk
|
7595 | */
|
7596 | export function renameFile(oldPath: string, newPath: string, opts?: RenameFileOptions): Promise<void>
|
7597 |
|
7598 | /**
|
7599 | * Delete file from vim and disk.
|
7600 | */
|
7601 | export function deleteFile(filepath: string, opts?: DeleteFileOptions): Promise<void>
|
7602 |
|
7603 | /**
|
7604 | * Open resource by uri
|
7605 | */
|
7606 | export function openResource(uri: string): Promise<void>
|
7607 |
|
7608 | /**
|
7609 | * Resolve full path of module from yarn or npm global directory.
|
7610 | */
|
7611 | export function resolveModule(name: string): Promise<string>
|
7612 |
|
7613 | /**
|
7614 | * Run nodejs command
|
7615 | */
|
7616 | export function runCommand(cmd: string, cwd?: string, timeout?: number): Promise<string>
|
7617 |
|
7618 | /**
|
7619 | * Expand filepath with `~` and/or environment placeholders
|
7620 | */
|
7621 | export function expand(filepath: string): string
|
7622 |
|
7623 | /**
|
7624 | * Call a function by use notifications, useful for functions like |input| that could block vim.
|
7625 | */
|
7626 | export function callAsync<T>(method: string, args: any[]): Promise<T>
|
7627 |
|
7628 | /**
|
7629 | * registerTextDocumentContentProvider
|
7630 | */
|
7631 | export function registerTextDocumentContentProvider(scheme: string, provider: TextDocumentContentProvider): Disposable
|
7632 |
|
7633 | /**
|
7634 | * Register unique keymap uses `<Plug>(coc-{key})` as lhs
|
7635 | * Throw error when {key} already exists.
|
7636 | *
|
7637 | * @param {MapMode[]} modes - array of 'n' | 'i' | 'v' | 'x' | 's' | 'o'
|
7638 | * @param {string} key - unique name
|
7639 | * @param {Function} fn - callback function
|
7640 | * @param {Partial} opts
|
7641 | * @returns {Disposable}
|
7642 | */
|
7643 | export function registerKeymap(modes: MapMode[], key: string, fn: () => ProviderResult<any>, opts?: Partial<KeymapOption>): Disposable
|
7644 |
|
7645 | /**
|
7646 | * Register expr key-mapping.
|
7647 | */
|
7648 | export function registerExprKeymap(mode: 'i' | 'n' | 'v' | 's' | 'x', key: string, fn: () => ProviderResult<string>, buffer?: boolean): Disposable
|
7649 |
|
7650 | /**
|
7651 | * Register local key-mapping.
|
7652 | */
|
7653 | export function registerLocalKeymap(mode: 'n' | 'v' | 's' | 'x', key: string, fn: () => ProviderResult<any>, notify?: boolean): Disposable
|
7654 |
|
7655 | /**
|
7656 | * Register for buffer sync objects, created item should be disposable
|
7657 | * and provide optional `onChange` which called when document change.
|
7658 | *
|
7659 | * The document is always attached and not command line buffer.
|
7660 | *
|
7661 | * @param create Called for each attached document and on document create.
|
7662 | * @returns Disposable
|
7663 | */
|
7664 | export function registerBufferSync<T extends BufferSyncItem>(create: (doc: Document) => T | undefined): BufferSync<T>
|
7665 |
|
7666 | /**
|
7667 | * Create a FuzzyMatch instance using wasm module.
|
7668 | * The FuzzyMatch does the same match algorithm as vim's `:h matchfuzzypos()`
|
7669 | */
|
7670 | export function createFuzzyMatch(): FuzzyMatch
|
7671 |
|
7672 | /**
|
7673 | * Compute word ranges of opened document in specified range.
|
7674 | *
|
7675 | * @param {string | number} uri Uri of resource
|
7676 | * @param {Range} range Range of resource
|
7677 | * @param {CancellationToken} token
|
7678 | * @returns {Promise<{ [word: string]: Range[] } | null>}
|
7679 | */
|
7680 | export function computeWordRanges(uri: string | number, range: Range, token?: CancellationToken): Promise<{ [word: string]: Range[] } | null>
|
7681 | /**
|
7682 | * Create a FileSystemWatcher instance, when watchman doesn't exist, the
|
7683 | * returned FileSystemWatcher can still be used, but not work at all.
|
7684 | */
|
7685 | export function createFileSystemWatcher(globPattern: GlobPattern, ignoreCreate?: boolean, ignoreChange?: boolean, ignoreDelete?: boolean): FileSystemWatcher
|
7686 | /**
|
7687 | * Find files across all {@link workspace.workspaceFolders workspace folders} in the workspace.
|
7688 | *
|
7689 | * @example
|
7690 | * findFiles('**/*.js', '**/node_modules/**', 10)
|
7691 | *
|
7692 | * @param include A {@link GlobPattern glob pattern} that defines the files to search for. The glob pattern
|
7693 | * will be matched against the file paths of resulting matches relative to their workspace.
|
7694 | * Use a {@link RelativePattern relative pattern} to restrict the search results to a {@link WorkspaceFolder workspace folder}.
|
7695 | * @param exclude A {@link GlobPattern glob pattern} that defines files and folders to exclude. The glob pattern
|
7696 | * will be matched against the file paths of resulting matches relative to their workspace. When `undefined` or`null`,
|
7697 | * no excludes will apply.
|
7698 | * @param maxResults An upper-bound for the result.
|
7699 | * @param token A token that can be used to signal cancellation to the underlying search engine.
|
7700 | * @return A thenable that resolves to an array of resource identifiers. Will return no results if no
|
7701 | * {@link workspace.workspaceFolders workspace folders} are opened.
|
7702 | */
|
7703 | export function findFiles(include: GlobPattern, exclude?: GlobPattern | null, maxResults?: number, token?: CancellationToken): Thenable<Uri[]>
|
7704 |
|
7705 | /**
|
7706 | * Create persistence Mru instance.
|
7707 | */
|
7708 | export function createMru(name: string): Mru
|
7709 |
|
7710 | /**
|
7711 | * Create Task instance that runs in (neo)vim, no shell.
|
7712 | *
|
7713 | * @param id Unique id string, like `TSC`
|
7714 | */
|
7715 | export function createTask(id: string): Task
|
7716 |
|
7717 | /**
|
7718 | * Create DB instance at extension root.
|
7719 | */
|
7720 | export function createDatabase(name: string): JsonDB
|
7721 | }
|
7722 | // }}
|
7723 |
|
7724 | // window module {{
|
7725 | /**
|
7726 | * Represents how a terminal exited.
|
7727 | */
|
7728 | export interface TerminalExitStatus {
|
7729 | /**
|
7730 | * The exit code that a terminal exited with, it can have the following values:
|
7731 | * - Zero: the terminal process or custom execution succeeded.
|
7732 | * - Non-zero: the terminal process or custom execution failed.
|
7733 | * - `undefined`: the user forcibly closed the terminal or a custom execution exited
|
7734 | * without providing an exit code.
|
7735 | */
|
7736 | readonly code: number | undefined
|
7737 | }
|
7738 |
|
7739 | export interface TerminalOptions {
|
7740 | /**
|
7741 | * A human-readable string which will be used to represent the terminal in the UI.
|
7742 | */
|
7743 | name?: string
|
7744 |
|
7745 | /**
|
7746 | * A path to a custom shell executable to be used in the terminal.
|
7747 | */
|
7748 | shellPath?: string
|
7749 |
|
7750 | /**
|
7751 | * Args for the custom shell executable, this does not work on Windows (see #8429)
|
7752 | */
|
7753 | shellArgs?: string[]
|
7754 |
|
7755 | /**
|
7756 | * A path or URI for the current working directory to be used for the terminal.
|
7757 | */
|
7758 | cwd?: string
|
7759 |
|
7760 | /**
|
7761 | * Object with environment variables that will be added to the VS Code process.
|
7762 | */
|
7763 | env?: { [key: string]: string | null }
|
7764 |
|
7765 | /**
|
7766 | * Whether the terminal process environment should be exactly as provided in
|
7767 | * `TerminalOptions.env`. When this is false (default), the environment will be based on the
|
7768 | * window's environment and also apply configured platform settings like
|
7769 | * `terminal.integrated.windows.env` on top. When this is true, the complete environment
|
7770 | * must be provided as nothing will be inherited from the process or any configuration.
|
7771 | * Neovim only.
|
7772 | */
|
7773 | strictEnv?: boolean
|
7774 | }
|
7775 |
|
7776 | /**
|
7777 | * An individual terminal instance within the integrated terminal.
|
7778 | */
|
7779 | export interface Terminal {
|
7780 |
|
7781 | /**
|
7782 | * The bufnr of terminal buffer.
|
7783 | */
|
7784 | readonly bufnr: number
|
7785 |
|
7786 | /**
|
7787 | * The name of the terminal.
|
7788 | */
|
7789 | readonly name: string
|
7790 |
|
7791 | /**
|
7792 | * The process ID of the shell process.
|
7793 | */
|
7794 | readonly processId: Promise<number>
|
7795 |
|
7796 | /**
|
7797 | * The exit status of the terminal, this will be undefined while the terminal is active.
|
7798 | *
|
7799 | * **Example:** Show a notification with the exit code when the terminal exits with a
|
7800 | * non-zero exit code.
|
7801 | * ```typescript
|
7802 | * window.onDidCloseTerminal(t => {
|
7803 | * if (t.exitStatus && t.exitStatus.code) {
|
7804 | * vscode.window.showInformationMessage(`Exit code: ${t.exitStatus.code}`);
|
7805 | * }
|
7806 | * });
|
7807 | * ```
|
7808 | */
|
7809 | readonly exitStatus: TerminalExitStatus | undefined
|
7810 |
|
7811 | /**
|
7812 | * Send text to the terminal. The text is written to the stdin of the underlying pty process
|
7813 | * (shell) of the terminal.
|
7814 | *
|
7815 | * @param text The text to send.
|
7816 | * @param addNewLine Whether to add a new line to the text being sent, this is normally
|
7817 | * required to run a command in the terminal. The character(s) added are \n or \r\n
|
7818 | * depending on the platform. This defaults to `true`.
|
7819 | */
|
7820 | sendText(text: string, addNewLine?: boolean): void
|
7821 |
|
7822 | /**
|
7823 | * Show the terminal panel and reveal this terminal in the UI, return false when failed.
|
7824 | *
|
7825 | * @param preserveFocus When `true` the terminal will not take focus.
|
7826 | */
|
7827 | show(preserveFocus?: boolean): Promise<boolean>
|
7828 |
|
7829 | /**
|
7830 | * Hide the terminal panel if this terminal is currently showing.
|
7831 | */
|
7832 | hide(): void
|
7833 |
|
7834 | /**
|
7835 | * Dispose and free associated resources.
|
7836 | */
|
7837 | dispose(): void
|
7838 | }
|
7839 |
|
7840 | /**
|
7841 | * Option for create status item.
|
7842 | */
|
7843 | export interface StatusItemOption {
|
7844 | progress?: boolean
|
7845 | }
|
7846 |
|
7847 | /**
|
7848 | * Status item that included in `g:coc_status`
|
7849 | */
|
7850 | export interface StatusBarItem {
|
7851 | /**
|
7852 | * The priority of this item. Higher value means the item should
|
7853 | * be shown more to the left.
|
7854 | */
|
7855 | readonly priority: number
|
7856 |
|
7857 | isProgress: boolean
|
7858 |
|
7859 | /**
|
7860 | * The text to show for the entry. You can embed icons in the text by leveraging the syntax:
|
7861 | *
|
7862 | * `My text $(icon-name) contains icons like $(icon-name) this one.`
|
7863 | *
|
7864 | * Where the icon-name is taken from the [octicon](https://octicons.github.com) icon set, e.g.
|
7865 | * `light-bulb`, `thumbsup`, `zap` etc.
|
7866 | */
|
7867 | text: string
|
7868 |
|
7869 | /**
|
7870 | * Shows the entry in the status bar.
|
7871 | */
|
7872 | show(): void
|
7873 |
|
7874 | /**
|
7875 | * Hide the entry in the status bar.
|
7876 | */
|
7877 | hide(): void
|
7878 |
|
7879 | /**
|
7880 | * Dispose and free associated resources. Call
|
7881 | * [hide](#StatusBarItem.hide).
|
7882 | */
|
7883 | dispose(): void
|
7884 | }
|
7885 |
|
7886 | /**
|
7887 | * Value-object describing where and how progress should show.
|
7888 | */
|
7889 | export interface ProgressOptions {
|
7890 |
|
7891 | /**
|
7892 | * A human-readable string which will be used to describe the
|
7893 | * operation.
|
7894 | */
|
7895 | title?: string
|
7896 |
|
7897 | /**
|
7898 | * Controls if a cancel button should show to allow the user to
|
7899 | * cancel the long running operation.
|
7900 | */
|
7901 | cancellable?: boolean
|
7902 | }
|
7903 |
|
7904 | /**
|
7905 | * Defines a generalized way of reporting progress updates.
|
7906 | */
|
7907 | export interface Progress<T> {
|
7908 |
|
7909 | /**
|
7910 | * Report a progress update.
|
7911 | *
|
7912 | * @param value A progress item, like a message and/or an
|
7913 | * report on how much work finished
|
7914 | */
|
7915 | report(value: T): void
|
7916 | }
|
7917 |
|
7918 | /**
|
7919 | * Represents an action that is shown with an information, warning, or
|
7920 | * error message.
|
7921 | *
|
7922 | * @see [showInformationMessage](#window.showInformationMessage)
|
7923 | * @see [showWarningMessage](#window.showWarningMessage)
|
7924 | * @see [showErrorMessage](#window.showErrorMessage)
|
7925 | */
|
7926 | export interface MessageItem {
|
7927 |
|
7928 | /**
|
7929 | * A short title like 'Retry', 'Open Log' etc.
|
7930 | */
|
7931 | title: string
|
7932 |
|
7933 | /**
|
7934 | * A hint for modal dialogs that the item should be triggered
|
7935 | * when the user cancels the dialog (e.g. by pressing the ESC
|
7936 | * key).
|
7937 | *
|
7938 | * Note: this option is ignored for non-modal messages.
|
7939 | * Note: not used by coc.nvim for now.
|
7940 | */
|
7941 | isCloseAffordance?: boolean
|
7942 | }
|
7943 |
|
7944 | export interface DialogButton {
|
7945 | /**
|
7946 | * Use by callback, should >= 0
|
7947 | */
|
7948 | index: number
|
7949 | text: string
|
7950 | /**
|
7951 | * Not shown when true
|
7952 | */
|
7953 | disabled?: boolean
|
7954 | }
|
7955 |
|
7956 | export interface DialogConfig {
|
7957 | /**
|
7958 | * Content shown in window.
|
7959 | */
|
7960 | content: string
|
7961 | /**
|
7962 | * Optional title text.
|
7963 | */
|
7964 | title?: string
|
7965 | /**
|
7966 | * show close button, default to true when not specified.
|
7967 | */
|
7968 | close?: boolean
|
7969 | /**
|
7970 | * highlight group for dialog window, default to `"dialog.floatHighlight"` or 'CocFlating'
|
7971 | */
|
7972 | highlight?: string
|
7973 | /**
|
7974 | * highlight items of content.
|
7975 | */
|
7976 | highlights?: ReadonlyArray<HighlightItem>
|
7977 | /**
|
7978 | * highlight groups for border, default to `"dialog.borderhighlight"` or 'CocFlating'
|
7979 | */
|
7980 | borderhighlight?: string
|
7981 | /**
|
7982 | * Buttons as bottom of dialog.
|
7983 | */
|
7984 | buttons?: DialogButton[]
|
7985 | /**
|
7986 | * index is -1 for window close without button click
|
7987 | */
|
7988 | callback?: (index: number) => void
|
7989 | }
|
7990 |
|
7991 | export type NotificationKind = 'error' | 'info' | 'warning' | 'progress'
|
7992 |
|
7993 | export interface NotificationConfig {
|
7994 | kind?: NotificationKind
|
7995 |
|
7996 | content?: string
|
7997 | /**
|
7998 | * Optional title text.
|
7999 | */
|
8000 | title?: string
|
8001 | /**
|
8002 | * Buttons as bottom of dialog.
|
8003 | */
|
8004 | buttons?: DialogButton[]
|
8005 | /**
|
8006 | * index is -1 for window close without button click
|
8007 | */
|
8008 | callback?: (index: number) => void
|
8009 | }
|
8010 |
|
8011 | /**
|
8012 | * Options to configure the behavior of the quick pick UI.
|
8013 | */
|
8014 | export interface QuickPickOptions {
|
8015 |
|
8016 | /**
|
8017 | * An optional string that represents the title of the quick pick.
|
8018 | */
|
8019 | title?: string
|
8020 |
|
8021 | /**
|
8022 | * An optional flag to include the description when filtering the picks.
|
8023 | */
|
8024 | matchOnDescription?: boolean
|
8025 |
|
8026 | /**
|
8027 | * An optional flag to make the picker accept multiple selections, if true the result is an array of picks.
|
8028 | */
|
8029 | canPickMany?: boolean
|
8030 | }
|
8031 |
|
8032 | /**
|
8033 | * Represents an item that can be selected from
|
8034 | * a list of items.
|
8035 | */
|
8036 | export interface QuickPickItem {
|
8037 | /**
|
8038 | * A human-readable string which is rendered prominent
|
8039 | */
|
8040 | label: string
|
8041 | /**
|
8042 | * A human-readable string which is rendered less prominent in the same line
|
8043 | */
|
8044 | description?: string
|
8045 | /**
|
8046 | * Optional flag indicating if this item is picked initially.
|
8047 | */
|
8048 | picked?: boolean
|
8049 | }
|
8050 |
|
8051 | export interface QuickPickConfig<T extends QuickPickItem> {
|
8052 | /**
|
8053 | * An optional title.
|
8054 | */
|
8055 | title?: string
|
8056 | /**
|
8057 | * Items to pick from.
|
8058 | */
|
8059 | items: readonly T[]
|
8060 | /**
|
8061 | * Initial value of the filter text.
|
8062 | */
|
8063 | value?: string
|
8064 | /**
|
8065 | * If multiple items can be selected at the same time. Defaults to false.
|
8066 | */
|
8067 | canSelectMany?: boolean
|
8068 | /**
|
8069 | * Max height of list window.
|
8070 | */
|
8071 | maxHeight?: number
|
8072 | }
|
8073 |
|
8074 | export interface QuickPick<T extends QuickPickItem> {
|
8075 | /**
|
8076 | * An optional title.
|
8077 | */
|
8078 | title: string | undefined
|
8079 | /**
|
8080 | * If the UI should show a progress indicator. Defaults to false.
|
8081 | *
|
8082 | * Change this to true, e.g., while loading more data or validating
|
8083 | * user input.
|
8084 | */
|
8085 | loading: boolean
|
8086 | /**
|
8087 | * Items to pick from. This can be read and updated by the extension.
|
8088 | */
|
8089 | items: readonly T[]
|
8090 | /**
|
8091 | * Active items. This can be read and updated by the extension.
|
8092 | */
|
8093 | activeItems: readonly T[]
|
8094 | /**
|
8095 | * If the filter text should also be matched against the description of the items. Defaults to false.
|
8096 | */
|
8097 | matchOnDescription: boolean
|
8098 | /**
|
8099 | * Current input value
|
8100 | */
|
8101 | readonly value: string
|
8102 | /**
|
8103 | * An event signaling when QuickPick closed, fired with selected items or null when canceled.
|
8104 | */
|
8105 | readonly onDidFinish: Event<T[] | null>
|
8106 | /**
|
8107 | * An event signaling when the value of the filter text has changed.
|
8108 | */
|
8109 | readonly onDidChangeValue: Event<string>
|
8110 | /**
|
8111 | * An event signaling when the selected items have changed.
|
8112 | */
|
8113 | readonly onDidChangeSelection: Event<readonly T[]>
|
8114 | }
|
8115 |
|
8116 | export interface ScreenPosition {
|
8117 | row: number
|
8118 | col: number
|
8119 | }
|
8120 |
|
8121 | export type MsgTypes = 'error' | 'warning' | 'more'
|
8122 |
|
8123 | export interface OpenTerminalOption {
|
8124 | /**
|
8125 | * Cwd of terminal, default to result of |getcwd()|
|
8126 | */
|
8127 | cwd?: string
|
8128 | /**
|
8129 | * Close terminal on job finish, default to true.
|
8130 | */
|
8131 | autoclose?: boolean
|
8132 | /**
|
8133 | * Keep focus current window, default to false.
|
8134 | */
|
8135 | keepfocus?: boolean
|
8136 | /**
|
8137 | * Position of terminal window, default to 'right'.
|
8138 | */
|
8139 | position?: 'bottom' | 'right'
|
8140 | }
|
8141 |
|
8142 | /**
|
8143 | * An output channel is a container for readonly textual information.
|
8144 | *
|
8145 | * To get an instance of an `OutputChannel` use
|
8146 | * [createOutputChannel](#window.createOutputChannel).
|
8147 | */
|
8148 | export interface OutputChannel {
|
8149 |
|
8150 | /**
|
8151 | * The human-readable name of this output channel.
|
8152 | */
|
8153 | readonly name: string
|
8154 |
|
8155 | readonly content: string
|
8156 | /**
|
8157 | * Append the given value to the channel.
|
8158 | *
|
8159 | * @param value A string, falsy values will not be printed.
|
8160 | */
|
8161 | append(value: string): void
|
8162 |
|
8163 | /**
|
8164 | * Append the given value and a line feed character
|
8165 | * to the channel.
|
8166 | *
|
8167 | * @param value A string, falsy values will be printed.
|
8168 | */
|
8169 | appendLine(value: string): void
|
8170 |
|
8171 | /**
|
8172 | * Removes output from the channel. Latest `keep` lines will be remained.
|
8173 | */
|
8174 | clear(keep?: number): void
|
8175 |
|
8176 | /**
|
8177 | * Reveal this channel in the UI.
|
8178 | *
|
8179 | * @param preserveFocus When `true` the channel will not take focus.
|
8180 | */
|
8181 | show(preserveFocus?: boolean): void
|
8182 |
|
8183 | /**
|
8184 | * Hide this channel from the UI.
|
8185 | */
|
8186 | hide(): void
|
8187 |
|
8188 | /**
|
8189 | * Dispose and free associated resources.
|
8190 | */
|
8191 | dispose(): void
|
8192 | }
|
8193 |
|
8194 | export interface TerminalResult {
|
8195 | bufnr: number
|
8196 | success: boolean
|
8197 | content?: string
|
8198 | }
|
8199 |
|
8200 | export interface Dialog {
|
8201 | /**
|
8202 | * Buffer number of dialog.
|
8203 | */
|
8204 | bufnr: number
|
8205 | /**
|
8206 | * Window id of dialog.
|
8207 | */
|
8208 | winid: Promise<number | null>
|
8209 | dispose: () => void
|
8210 | }
|
8211 |
|
8212 | export type HighlightItemDef = [string, number, number, number, number?, number?, number?]
|
8213 |
|
8214 | export interface HighlightDiff {
|
8215 | remove: number[]
|
8216 | removeMarkers: number[]
|
8217 | add: HighlightItemDef[]
|
8218 | }
|
8219 |
|
8220 | export interface MenuItem {
|
8221 | text: string
|
8222 | disabled?: boolean | { reason: string }
|
8223 | }
|
8224 |
|
8225 | export interface MenuOption {
|
8226 | /**
|
8227 | * Title in menu window.
|
8228 | */
|
8229 | title?: string,
|
8230 | /**
|
8231 | * Content in menu window as normal text.
|
8232 | */
|
8233 | content?: string
|
8234 | /**
|
8235 | * Create and highlight shortcut characters.
|
8236 | */
|
8237 | shortcuts?: boolean
|
8238 | /**
|
8239 | * Position of menu, default to 'cursor'
|
8240 | */
|
8241 | position?: 'center' | 'cursor'
|
8242 | }
|
8243 |
|
8244 | export interface InputOptions {
|
8245 | /**
|
8246 | * Position to show input, default to 'cursor'
|
8247 | */
|
8248 | position?: 'cursor' | 'center'
|
8249 | /**
|
8250 | * Margin top editor when position is 'center'
|
8251 | */
|
8252 | marginTop?: number
|
8253 | /**
|
8254 | * Border highlight of float window/popup, configuration `dialog.borderhighlight` used as default.
|
8255 | */
|
8256 | borderhighlight?: string
|
8257 | /**
|
8258 | * Create key-mappings for quickpick list.
|
8259 | */
|
8260 | list?: boolean
|
8261 | }
|
8262 |
|
8263 | export interface InputPreference extends InputOptions {
|
8264 | /**
|
8265 | * Top, right, bottom, left border existence, default to [1,1,1,1]
|
8266 | */
|
8267 | border?: [0 | 1, 0 | 1, 0 | 1, 0 | 1]
|
8268 | /**
|
8269 | * Rounded border, default to true, configuration `dialog.rounded` used as default.
|
8270 | */
|
8271 | rounded?: boolean
|
8272 | /**
|
8273 | * Minimal window width, `g:coc_prompt_win_width` or 32 used as default.
|
8274 | */
|
8275 | minWidth?: number
|
8276 | /**
|
8277 | * Maximum window width, configuration `dialog.maxWidth` used as default.
|
8278 | */
|
8279 | maxWidth?: number
|
8280 | }
|
8281 |
|
8282 | export interface InputDimension {
|
8283 | readonly width: number
|
8284 | readonly height: number
|
8285 | /**
|
8286 | * 0 based screen row
|
8287 | */
|
8288 | readonly row: number
|
8289 | /**
|
8290 | * O based screen col
|
8291 | */
|
8292 | readonly col: number
|
8293 | }
|
8294 |
|
8295 | export interface InputBox {
|
8296 | /**
|
8297 | * Change or get title of input box.
|
8298 | */
|
8299 | title: string
|
8300 | /**
|
8301 | * Change or get loading state of input box.
|
8302 | */
|
8303 | loading: boolean
|
8304 | /**
|
8305 | * Change or get borderhighlight of input box.
|
8306 | */
|
8307 | borderhighlight: string
|
8308 | /**
|
8309 | * Dimension of float window/popup
|
8310 | */
|
8311 | readonly dimension: InputDimension
|
8312 | /**
|
8313 | * Buffer number of float window/popup
|
8314 | */
|
8315 | readonly bufnr: number
|
8316 | /**
|
8317 | * An event signaling when the value has changed.
|
8318 | */
|
8319 | readonly onDidChange: Event<string>
|
8320 | /**
|
8321 | * An event signaling input finished, emit input value or null when canceled.
|
8322 | */
|
8323 | readonly onDidFinish: Event<string | null>
|
8324 | }
|
8325 |
|
8326 | /**
|
8327 | * FloatWinConfig.
|
8328 | */
|
8329 | export interface FloatWinConfig {
|
8330 | border?: boolean | [number, number, number, number]
|
8331 | rounded?: boolean
|
8332 | highlight?: string
|
8333 | title?: string
|
8334 | borderhighlight?: string
|
8335 | close?: boolean
|
8336 | maxHeight?: number
|
8337 | maxWidth?: number
|
8338 | winblend?: number
|
8339 | focusable?: boolean
|
8340 | shadow?: boolean
|
8341 | preferTop?: boolean
|
8342 | autoHide?: boolean
|
8343 | offsetX?: number
|
8344 | cursorline?: boolean
|
8345 | modes?: string[]
|
8346 | excludeImages?: boolean
|
8347 | }
|
8348 |
|
8349 | export interface FloatFactory {
|
8350 | /**
|
8351 | * Show documentations in float window/popup.
|
8352 | * Window and buffer are reused when possible.
|
8353 | *
|
8354 | * @param docs List of documentations.
|
8355 | * @param options Configuration for floating window/popup.
|
8356 | */
|
8357 | show: (docs: Documentation[], options?: FloatWinConfig) => Promise<void>
|
8358 | /**
|
8359 | * Close the float window created by this float factory.
|
8360 | */
|
8361 | close: () => void
|
8362 | /**
|
8363 | * Check if float window is shown.
|
8364 | */
|
8365 | activated: () => Promise<boolean>
|
8366 | /**
|
8367 | * Unbind events
|
8368 | */
|
8369 | dispose: () => void
|
8370 | }
|
8371 |
|
8372 | export namespace window {
|
8373 | /**
|
8374 | * The currently active editor or `undefined`. The active editor is the one
|
8375 | * that currently has focus or, when none has focus, the one that has changed
|
8376 | * input most recently.
|
8377 | */
|
8378 | export const activeTextEditor: TextEditor | undefined
|
8379 |
|
8380 | /**
|
8381 | * The currently visible editors or an empty array.
|
8382 | */
|
8383 | export const visibleTextEditors: readonly TextEditor[]
|
8384 |
|
8385 | /**
|
8386 | * An {@link Event} which fires when the {@link window.activeTextEditor active editor}
|
8387 | * has changed. *Note* that the event also fires when the active editor changes
|
8388 | * to `undefined`.
|
8389 | */
|
8390 | export const onDidChangeActiveTextEditor: Event<TextEditor | undefined>
|
8391 |
|
8392 | /**
|
8393 | * An {@link Event} which fires when the array of {@link window.visibleTextEditors visible editors}
|
8394 | * has changed.
|
8395 | */
|
8396 | export const onDidChangeVisibleTextEditors: Event<readonly TextEditor[]>
|
8397 |
|
8398 | /**
|
8399 | * The currently opened terminals or an empty array.
|
8400 | * onDidChangeTerminalState doesn't exist since we can't detect window resize on vim.
|
8401 | */
|
8402 | export const terminals: readonly Terminal[]
|
8403 |
|
8404 | /**
|
8405 | * Event fired after terminal created, only fired with Terminal that
|
8406 | * created by `window.createTerminal`
|
8407 | */
|
8408 | export const onDidOpenTerminal: Event<Terminal>
|
8409 |
|
8410 | /**
|
8411 | * Event fired on terminal close, only fired with Terminal that created by
|
8412 | * `window.createTerminal`
|
8413 | */
|
8414 | export const onDidCloseTerminal: Event<Terminal>
|
8415 |
|
8416 | /**
|
8417 | * Creates a {@link Terminal} with a backing shell process.
|
8418 | * The terminal is created by (neo)vim.
|
8419 | *
|
8420 | * @param options A TerminalOptions object describing the characteristics of the new terminal.
|
8421 | * @return A new Terminal.
|
8422 | * @throws When running in an environment where a new process cannot be started.
|
8423 | */
|
8424 | export function createTerminal(opts: TerminalOptions): Promise<Terminal>
|
8425 |
|
8426 | /**
|
8427 | * Create float window factory for create float window/popup around current
|
8428 | * cursor.
|
8429 | * Configuration "floatFactory.floatConfig" is used as default float config.
|
8430 | * Configuration "coc.preferences.excludeImageLinksInMarkdownDocument" is also used.
|
8431 | *
|
8432 | * Float windows are automatic reused and hidden on specific events including:
|
8433 | * - BufEnter
|
8434 | * - InsertEnter
|
8435 | * - InsertLeave
|
8436 | * - MenuPopupChanged
|
8437 | * - CursorMoved
|
8438 | * - CursorMovedI
|
8439 | *
|
8440 | * @param conf Configuration of float window.
|
8441 | * @return FloatFactory
|
8442 | */
|
8443 | export function createFloatFactory(conf: FloatWinConfig): FloatFactory
|
8444 |
|
8445 | /**
|
8446 | * Reveal message with message type.
|
8447 | *
|
8448 | * @deprecated Use `window.showErrorMessage`, `window.showWarningMessage` and `window.showInformationMessage` instead.
|
8449 | * @param msg Message text to show.
|
8450 | * @param messageType Type of message, could be `error` `warning` and `more`, default to `more`
|
8451 | */
|
8452 | export function showMessage(msg: string, messageType?: MsgTypes): void
|
8453 |
|
8454 | /**
|
8455 | * Run command in vim terminal for result
|
8456 | *
|
8457 | * @param cmd Command to run.
|
8458 | * @param cwd Cwd of terminal, default to result of |getcwd()|.
|
8459 | */
|
8460 | export function runTerminalCommand(cmd: string, cwd?: string, keepfocus?: boolean): Promise<TerminalResult>
|
8461 |
|
8462 | /**
|
8463 | * Open terminal window.
|
8464 | *
|
8465 | * @param cmd Command to run.
|
8466 | * @param opts Terminal option.
|
8467 | * @returns buffer number of terminal.
|
8468 | */
|
8469 | export function openTerminal(cmd: string, opts?: OpenTerminalOption): Promise<number>
|
8470 |
|
8471 | /**
|
8472 | * Show quickpick for single item, use `window.menuPick` for menu at current current position.
|
8473 | * Use `window.showPickerDialog()` for multiple selection.
|
8474 | *
|
8475 | * @param items Label list.
|
8476 | * @param placeholder Prompt text, default to 'choose by number'.
|
8477 | * @returns Index of selected item, or -1 when canceled.
|
8478 | */
|
8479 | export function showQuickpick(items: string[], placeholder?: string): Promise<number>
|
8480 |
|
8481 | /**
|
8482 | * Shows a selection list allowing multiple selections.
|
8483 | * Throw error when 'workspace.env.dialog' is not true.
|
8484 | *
|
8485 | * @param items An array of strings, or a promise that resolves to an array of strings.
|
8486 | * @param options Configures the behavior of the selection list.
|
8487 | * @param token A token that can be used to signal cancellation.
|
8488 | * @return A promise that resolves to the selected items or `undefined`.
|
8489 | */
|
8490 | export function showQuickPick(items: readonly string[] | Thenable<readonly string[]>, options: QuickPickOptions & { canPickMany: true }, token?: CancellationToken): Thenable<string[] | undefined>
|
8491 |
|
8492 | /**
|
8493 | * Shows a selection list.
|
8494 | * Throw error when 'workspace.env.dialog' is not true.
|
8495 | *
|
8496 | * @param items An array of strings, or a promise that resolves to an array of strings.
|
8497 | * @param options Configures the behavior of the selection list.
|
8498 | * @param token A token that can be used to signal cancellation.
|
8499 | * @return A promise that resolves to the selection or `undefined`.
|
8500 | */
|
8501 | export function showQuickPick(items: readonly string[] | Thenable<readonly string[]>, options?: QuickPickOptions, token?: CancellationToken): Thenable<string | undefined>
|
8502 |
|
8503 | /**
|
8504 | * Shows a selection list allowing multiple selections.
|
8505 | * Throw error when 'workspace.env.dialog' is not true.
|
8506 | *
|
8507 | * @param items An array of items, or a promise that resolves to an array of items.
|
8508 | * @param options Configures the behavior of the selection list.
|
8509 | * @param token A token that can be used to signal cancellation.
|
8510 | * @return A promise that resolves to the selected items or `undefined`.
|
8511 | */
|
8512 | export function showQuickPick<T extends QuickPickItem>(items: readonly T[] | Thenable<readonly T[]>, options: QuickPickOptions & { canPickMany: true }, token?: CancellationToken): Thenable<T[] | undefined>
|
8513 |
|
8514 | /**
|
8515 | * Shows a selection list.
|
8516 | * Throw error when `workspace.env.dialog` not true.
|
8517 | *
|
8518 | * @param items An array of items, or a promise that resolves to an array of items.
|
8519 | * @param options Configures the behavior of the selection list.
|
8520 | * @param token A token that can be used to signal cancellation.
|
8521 | * @return A promise that resolves to the selected item or `undefined`.
|
8522 | */
|
8523 | export function showQuickPick<T extends QuickPickItem>(items: readonly T[] | Thenable<readonly T[]>, options?: QuickPickOptions, token?: CancellationToken): Thenable<T | undefined>
|
8524 |
|
8525 | /**
|
8526 | * Show menu picker at current cursor position, |inputlist()| is used as fallback.
|
8527 | * Throw error when `workspace.env.dialog` not true.
|
8528 | *
|
8529 | * @param items Array of texts or menu items.
|
8530 | * @param title Optional title of float/popup window.
|
8531 | * @param token A token that can be used to signal cancellation.
|
8532 | * @returns Selected index (0 based), -1 when canceled.
|
8533 | */
|
8534 | export function showMenuPicker(items: string[] | MenuItem[], option?: MenuOption | string, token?: CancellationToken): Promise<number>
|
8535 |
|
8536 | /**
|
8537 | * Prompt user for confirm, a float/popup window would be used when possible,
|
8538 | * use vim's |confirm()| function as callback.
|
8539 | *
|
8540 | * @param title The prompt text.
|
8541 | * @returns Result of confirm.
|
8542 | */
|
8543 | export function showPrompt(title: string): Promise<boolean>
|
8544 |
|
8545 | /**
|
8546 | * Show dialog window at the center of screen.
|
8547 | * Note that the dialog would always be closed after button click.
|
8548 | * Throw error when `workspace.env.dialog` not true.
|
8549 | *
|
8550 | * @param config Dialog configuration.
|
8551 | * @returns Dialog or null when dialog can't work.
|
8552 | */
|
8553 | export function showDialog(config: DialogConfig): Promise<Dialog | null>
|
8554 |
|
8555 | /**
|
8556 | * Request input from user, `input()` is used when `window.env.dialog` not true.
|
8557 | *
|
8558 | * @param title Title text of prompt window.
|
8559 | * @param defaultValue Default value of input, empty text by default.
|
8560 | * @param {InputOptions} option for input window, other preferences are read from user configuration.
|
8561 | */
|
8562 | export function requestInput(title: string, defaultValue?: string, option?: InputOptions): Promise<string>
|
8563 |
|
8564 | /**
|
8565 | * Creates and show a {@link InputBox} to let the user enter some text input.
|
8566 | * Throw error when `workspace.env.dialog` not true.
|
8567 | *
|
8568 | * @return A new {@link InputBox}.
|
8569 | */
|
8570 | export function createInputBox(title: string, defaultValue: string | undefined, option: InputPreference): Promise<InputBox>
|
8571 |
|
8572 | /**
|
8573 | * Creates and show a {@link QuickPick} to let the user pick an item or items from a
|
8574 | * list of items of type T.
|
8575 | * Throw error when `workspace.env.dialog` not true.
|
8576 | *
|
8577 | * Note that in many cases the more convenient {@link window.showQuickPick}
|
8578 | * is easier to use. {@link window.createQuickPick} should be used
|
8579 | * when {@link window.showQuickPick} does not offer the required flexibility.
|
8580 | *
|
8581 | * @return A new {@link QuickPick}.
|
8582 | */
|
8583 | export function createQuickPick<T extends QuickPickItem>(config: QuickPickConfig<T>): Promise<QuickPick<T>>
|
8584 |
|
8585 | /**
|
8586 | * Create statusbar item that would be included in `g:coc_status`.
|
8587 | *
|
8588 | * @param priority Higher priority item would be shown right.
|
8589 | * @param option
|
8590 | * @return A new status bar item.
|
8591 | */
|
8592 | export function createStatusBarItem(priority?: number, option?: StatusItemOption): StatusBarItem
|
8593 |
|
8594 | /**
|
8595 | * Open local config file
|
8596 | */
|
8597 | export function openLocalConfig(): Promise<void>
|
8598 |
|
8599 | /**
|
8600 | * Create a new output channel
|
8601 | *
|
8602 | * @param name Unique name of output channel.
|
8603 | * @returns A new output channel.
|
8604 | */
|
8605 | export function createOutputChannel(name: string): OutputChannel
|
8606 |
|
8607 | /**
|
8608 | * Create a {@link TreeView} instance, call `show()` method to render.
|
8609 | *
|
8610 | * @param viewId Id of the view, used as title of TreeView when title doesn't exist.
|
8611 | * @param options Options for creating the {@link TreeView}
|
8612 | * @returns a {@link TreeView}.
|
8613 | */
|
8614 | export function createTreeView<T>(viewId: string, options: TreeViewOptions<T>): TreeView<T>
|
8615 |
|
8616 | /**
|
8617 | * Reveal buffer of output channel.
|
8618 | *
|
8619 | * @param name Name of output channel.
|
8620 | * @param preserveFocus Preserve window focus when true.
|
8621 | */
|
8622 | export function showOutputChannel(name: string, preserveFocus: boolean): void
|
8623 |
|
8624 | /**
|
8625 | * Echo lines at the bottom of vim.
|
8626 | *
|
8627 | * @param lines Line list.
|
8628 | * @param truncate Truncate the lines to avoid 'press enter to continue' when true
|
8629 | */
|
8630 | export function echoLines(lines: string[], truncate?: boolean): Promise<void>
|
8631 |
|
8632 | /**
|
8633 | * Get current cursor position (line, character both 0 based).
|
8634 | *
|
8635 | * @returns Cursor position.
|
8636 | */
|
8637 | export function getCursorPosition(): Promise<Position>
|
8638 |
|
8639 | /**
|
8640 | * Move cursor to position (line, character both 0 based).
|
8641 | *
|
8642 | * @param position LSP position.
|
8643 | */
|
8644 | export function moveTo(position: Position): Promise<void>
|
8645 |
|
8646 | /**
|
8647 | * Get current cursor character offset in document,
|
8648 | * length of line break would always be 1.
|
8649 | *
|
8650 | * @returns Character offset.
|
8651 | */
|
8652 | export function getOffset(): Promise<number>
|
8653 |
|
8654 | /**
|
8655 | * Get screen position of current cursor(relative to editor),
|
8656 | * both `row` and `col` are 0 based.
|
8657 | *
|
8658 | * @returns Cursor screen position.
|
8659 | */
|
8660 | export function getCursorScreenPosition(): Promise<ScreenPosition>
|
8661 |
|
8662 | /**
|
8663 | * Show multiple picker at center of screen.
|
8664 | * Use `workspace.env.dialog` to check if dialog could work.
|
8665 | *
|
8666 | * @param items A set of items that will be rendered as actions in the message.
|
8667 | * @param title Title of picker dialog.
|
8668 | * @param token A token that can be used to signal cancellation.
|
8669 | * @return A promise that resolves to the selected items or `undefined`.
|
8670 | */
|
8671 | export function showPickerDialog(items: string[], title: string, token?: CancellationToken): Promise<string[] | undefined>
|
8672 |
|
8673 | /**
|
8674 | * Show multiple picker at center of screen.
|
8675 | * Use `workspace.env.dialog` to check if dialog could work.
|
8676 | *
|
8677 | * @param items A set of items that will be rendered as actions in the message.
|
8678 | * @param title Title of picker dialog.
|
8679 | * @param token A token that can be used to signal cancellation.
|
8680 | * @return A promise that resolves to the selected items or `undefined`.
|
8681 | */
|
8682 | export function showPickerDialog<T extends QuickPickItem>(items: T[], title: string, token?: CancellationToken): Promise<T[] | undefined>
|
8683 |
|
8684 | /**
|
8685 | * Show an information message to users. Optionally provide an array of items which will be presented as
|
8686 | * clickable buttons.
|
8687 | *
|
8688 | * @param message The message to show.
|
8689 | * @param items A set of items that will be rendered as actions in the message.
|
8690 | * @return Promise that resolves to the selected item or `undefined` when being dismissed.
|
8691 | */
|
8692 | export function showInformationMessage(message: string, ...items: string[]): Promise<string | undefined>
|
8693 | /**
|
8694 | * Show an information message to users. Optionally provide an array of items which will be presented as
|
8695 | * clickable buttons.
|
8696 | *
|
8697 | * @param message The message to show.
|
8698 | * @param items A set of items that will be rendered as actions in the message.
|
8699 | * @return Promise that resolves to the selected item or `undefined` when being dismissed.
|
8700 | */
|
8701 | export function showInformationMessage<T extends MessageItem>(message: string, ...items: T[]): Promise<T | undefined>
|
8702 |
|
8703 | /**
|
8704 | * Show an warning message to users. Optionally provide an array of items which will be presented as
|
8705 | * clickable buttons.
|
8706 | *
|
8707 | * @param message The message to show.
|
8708 | * @param items A set of items that will be rendered as actions in the message.
|
8709 | * @return Promise that resolves to the selected item or `undefined` when being dismissed.
|
8710 | */
|
8711 | export function showWarningMessage(message: string, ...items: string[]): Promise<string | undefined>
|
8712 | /**
|
8713 | * Show an warning message to users. Optionally provide an array of items which will be presented as
|
8714 | * clickable buttons.
|
8715 | *
|
8716 | * @param message The message to show.
|
8717 | * @param items A set of items that will be rendered as actions in the message.
|
8718 | * @return Promise that resolves to the selected item or `undefined` when being dismissed.
|
8719 | */
|
8720 | export function showWarningMessage<T extends MessageItem>(message: string, ...items: T[]): Promise<T | undefined>
|
8721 |
|
8722 | /**
|
8723 | * Show an error message to users. Optionally provide an array of items which will be presented as
|
8724 | * clickable buttons.
|
8725 | *
|
8726 | * @param message The message to show.
|
8727 | * @param items A set of items that will be rendered as actions in the message.
|
8728 | * @return Promise that resolves to the selected item or `undefined` when being dismissed.
|
8729 | */
|
8730 | export function showErrorMessage(message: string, ...items: string[]): Promise<string | undefined>
|
8731 | /**
|
8732 | * Show an error message to users. Optionally provide an array of items which will be presented as
|
8733 | * clickable buttons.
|
8734 | *
|
8735 | * @param message The message to show.
|
8736 | * @param items A set of items that will be rendered as actions in the message.
|
8737 | * @return Promise that resolves to the selected item or `undefined` when being dismissed.
|
8738 | */
|
8739 | export function showErrorMessage<T extends MessageItem>(message: string, ...items: T[]): Promise<T | undefined>
|
8740 |
|
8741 | /**
|
8742 | * Show notification window at bottom right of screen.
|
8743 | */
|
8744 | export function showNotification(config: NotificationConfig): Promise<void>
|
8745 |
|
8746 | /**
|
8747 | * Show progress in the editor. Progress is shown while running the given callback
|
8748 | * and while the promise it returned isn't resolved nor rejected.
|
8749 | *
|
8750 | * @param task A callback returning a promise. Progress state can be reported with
|
8751 | * the provided [progress](#Progress)-object.
|
8752 | *
|
8753 | * To report discrete progress, use `increment` to indicate how much work has been completed. Each call with
|
8754 | * a `increment` value will be summed up and reflected as overall progress until 100% is reached (a value of
|
8755 | * e.g. `10` accounts for `10%` of work done).
|
8756 | *
|
8757 | * To monitor if the operation has been cancelled by the user, use the provided [`CancellationToken`](#CancellationToken).
|
8758 | *
|
8759 | * @return The thenable the task-callback returned.
|
8760 | */
|
8761 | export function withProgress<R>(options: ProgressOptions, task: (progress: Progress<{
|
8762 | message?: string
|
8763 | increment?: number
|
8764 | }>, token: CancellationToken) => Thenable<R>): Promise<R>
|
8765 |
|
8766 | /**
|
8767 | * Get selected range for current document
|
8768 | */
|
8769 | export function getSelectedRange(visualmode: string): Promise<Range | null>
|
8770 |
|
8771 | /**
|
8772 | * Visual select range of current document
|
8773 | */
|
8774 | export function selectRange(range: Range): Promise<void>
|
8775 |
|
8776 | /**
|
8777 | * Get diff between new highlight items and current highlights requested from vim
|
8778 | *
|
8779 | * @param {number} bufnr - Buffer number
|
8780 | * @param {string} ns - Highlight namespace
|
8781 | * @param {HighlightItem[]} items - Highlight items
|
8782 | * @param {[number, number] | undefined} - region 0 based start line and end line (end exclusive)
|
8783 | * @param {CancellationToken} token - CancellationToken
|
8784 | * @returns {Promise<HighlightDiff>}
|
8785 | */
|
8786 | export function diffHighlights(bufnr: number, ns: string, items: ExtendedHighlightItem[], region?: [number, number] | undefined, token?: CancellationToken): Promise<HighlightDiff | null>
|
8787 |
|
8788 | /**
|
8789 | * Apply highlight diffs, normally used with `window.diffHighlights`
|
8790 | *
|
8791 | * Timer is used to add highlights when there're too many highlight items to add,
|
8792 | * the highlight process won't be finished on that case.
|
8793 | *
|
8794 | * @param {number} bufnr - Buffer name
|
8795 | * @param {string} ns - Namespace
|
8796 | * @param {number} priority
|
8797 | * @param {HighlightDiff} diff
|
8798 | * @param {boolean} notify - Use notification, default false.
|
8799 | * @returns {Promise<void>}
|
8800 | */
|
8801 | export function applyDiffHighlights(bufnr: number, ns: string, priority: number, diff: HighlightDiff, notify?: boolean): Promise<void>
|
8802 | }
|
8803 | // }}
|
8804 |
|
8805 | // extensions module {{
|
8806 | export interface Logger {
|
8807 | readonly category: string
|
8808 | readonly level: string
|
8809 | log(...args: any[]): void
|
8810 | trace(message: any, ...args: any[]): void
|
8811 | debug(message: any, ...args: any[]): void
|
8812 | info(message: any, ...args: any[]): void
|
8813 | warn(message: any, ...args: any[]): void
|
8814 | error(message: any, ...args: any[]): void
|
8815 | fatal(message: any, ...args: any[]): void
|
8816 | mark(message: any, ...args: any[]): void
|
8817 | }
|
8818 |
|
8819 | /**
|
8820 | * A memento represents a storage utility. It can store and retrieve
|
8821 | * values.
|
8822 | */
|
8823 | export interface Memento {
|
8824 |
|
8825 | /**
|
8826 | * Return a value.
|
8827 | *
|
8828 | * @param key A string.
|
8829 | * @return The stored value or `undefined`.
|
8830 | */
|
8831 | get<T>(key: string): T | undefined
|
8832 |
|
8833 | /**
|
8834 | * Return a value.
|
8835 | *
|
8836 | * @param key A string.
|
8837 | * @param defaultValue A value that should be returned when there is no
|
8838 | * value (`undefined`) with the given key.
|
8839 | * @return The stored value or the defaultValue.
|
8840 | */
|
8841 | get<T>(key: string, defaultValue: T): T
|
8842 |
|
8843 | /**
|
8844 | * Store a value. The value must be JSON-stringifyable.
|
8845 | *
|
8846 | * @param key A string.
|
8847 | * @param value A value. MUST not contain cyclic references.
|
8848 | */
|
8849 | update(key: string, value: any): Promise<void>
|
8850 | }
|
8851 |
|
8852 | export type ExtensionState = 'disabled' | 'loaded' | 'activated' | 'unknown'
|
8853 |
|
8854 | export enum ExtensionType {
|
8855 | Global,
|
8856 | Local,
|
8857 | SingleFile,
|
8858 | Internal
|
8859 | }
|
8860 |
|
8861 | export interface ExtensionJson {
|
8862 | name: string
|
8863 | main?: string
|
8864 | engines: {
|
8865 | [key: string]: string
|
8866 | }
|
8867 | version?: string
|
8868 | [key: string]: any
|
8869 | }
|
8870 |
|
8871 | export interface ExtensionInfo {
|
8872 | id: string
|
8873 | version: string
|
8874 | description: string
|
8875 | root: string
|
8876 | exotic: boolean
|
8877 | uri?: string
|
8878 | state: ExtensionState
|
8879 | isLocal: boolean
|
8880 | packageJSON: Readonly<ExtensionJson>
|
8881 | }
|
8882 |
|
8883 | /**
|
8884 | * Represents an extension.
|
8885 | *
|
8886 | * To get an instance of an `Extension` use [getExtension](#extensions.getExtension).
|
8887 | */
|
8888 | export interface Extension<T> {
|
8889 |
|
8890 | /**
|
8891 | * The canonical extension identifier in the form of: `publisher.name`.
|
8892 | */
|
8893 | readonly id: string
|
8894 |
|
8895 | /**
|
8896 | * The absolute file path of the directory containing this extension.
|
8897 | */
|
8898 | readonly extensionPath: string
|
8899 |
|
8900 | /**
|
8901 | * `true` if the extension has been activated.
|
8902 | */
|
8903 | readonly isActive: boolean
|
8904 |
|
8905 | /**
|
8906 | * The parsed contents of the extension's package.json.
|
8907 | */
|
8908 | readonly packageJSON: any
|
8909 |
|
8910 | /**
|
8911 | * The public API exported by this extension. It is an invalid action
|
8912 | * to access this field before this extension has been activated.
|
8913 | */
|
8914 | readonly exports: T
|
8915 |
|
8916 | /**
|
8917 | * Activates this extension and returns its public API.
|
8918 | *
|
8919 | * @return A promise that will resolve when this extension has been activated.
|
8920 | */
|
8921 | activate(): Promise<T>
|
8922 | }
|
8923 |
|
8924 | /**
|
8925 | * An extension context is a collection of utilities private to an
|
8926 | * extension.
|
8927 | *
|
8928 | * An instance of an `ExtensionContext` is provided as the first
|
8929 | * parameter to the `activate`-call of an extension.
|
8930 | */
|
8931 | export interface ExtensionContext {
|
8932 |
|
8933 | /**
|
8934 | * An array to which disposables can be added. When this
|
8935 | * extension is deactivated the disposables will be disposed.
|
8936 | */
|
8937 | subscriptions: Disposable[]
|
8938 |
|
8939 | /**
|
8940 | * The absolute file path of the directory containing the extension.
|
8941 | */
|
8942 | extensionPath: string
|
8943 |
|
8944 | /**
|
8945 | * Get the absolute path of a resource contained in the extension.
|
8946 | *
|
8947 | * @param relativePath A relative path to a resource contained in the extension.
|
8948 | * @return The absolute path of the resource.
|
8949 | */
|
8950 | asAbsolutePath(relativePath: string): string
|
8951 |
|
8952 | /**
|
8953 | * The absolute directory path for extension to download persist data.
|
8954 | * The directory might not exist.
|
8955 | */
|
8956 | storagePath: string
|
8957 |
|
8958 | /**
|
8959 | * A memento object that stores state in the context
|
8960 | * of the currently opened [workspace](#workspace.workspaceFolders).
|
8961 | */
|
8962 | workspaceState: Memento
|
8963 |
|
8964 | /**
|
8965 | * A memento object that stores state independent
|
8966 | * of the current opened [workspace](#workspace.workspaceFolders).
|
8967 | */
|
8968 | globalState: Memento
|
8969 |
|
8970 | logger: Logger
|
8971 | }
|
8972 |
|
8973 | export type ExtensionApi = {
|
8974 | [index: string]: any
|
8975 | } | void | null | undefined
|
8976 |
|
8977 | export interface PropertyScheme {
|
8978 | type: string
|
8979 | default: any
|
8980 | description: string
|
8981 | enum?: string[]
|
8982 | items?: any
|
8983 | [key: string]: any
|
8984 | }
|
8985 |
|
8986 | export namespace extensions {
|
8987 | /**
|
8988 | * Fired on extension loaded, extension not activated yet.
|
8989 | */
|
8990 | export const onDidLoadExtension: Event<Extension<ExtensionApi>>
|
8991 |
|
8992 | /**
|
8993 | * Fired on extension activated.
|
8994 | */
|
8995 | export const onDidActiveExtension: Event<Extension<ExtensionApi>>
|
8996 |
|
8997 | /**
|
8998 | * Fired with extension id on extension unload.
|
8999 | */
|
9000 | export const onDidUnloadExtension: Event<string>
|
9001 |
|
9002 | /**
|
9003 | * Get all loaded extensions, without disabled extensions, extension may not activated.
|
9004 | */
|
9005 | export const all: ReadonlyArray<Extension<ExtensionApi>>
|
9006 |
|
9007 | /**
|
9008 | * Get state of specific extension.
|
9009 | */
|
9010 | export function getExtensionState(id: string): ExtensionState
|
9011 |
|
9012 | /**
|
9013 | * Get state of all extensions, including disabled extensions.
|
9014 | */
|
9015 | export function getExtensionStates(): Promise<ExtensionInfo[]>
|
9016 |
|
9017 | /**
|
9018 | * Check if extension is activated.
|
9019 | */
|
9020 | export function isActivated(id: string): boolean
|
9021 | }
|
9022 | // }}
|
9023 |
|
9024 | // listManager module {{
|
9025 | export interface LocationWithLine {
|
9026 | uri: string
|
9027 | /**
|
9028 | * Match text of line.
|
9029 | */
|
9030 | line: string
|
9031 | /**
|
9032 | * Highlight text in line.
|
9033 | */
|
9034 | text?: string
|
9035 | }
|
9036 |
|
9037 | export interface AnsiHighlight {
|
9038 | /**
|
9039 | * Byte indexes, 0 based.
|
9040 | */
|
9041 | span: [number, number]
|
9042 | hlGroup: string
|
9043 | }
|
9044 |
|
9045 | export interface ListItem {
|
9046 | label: string
|
9047 | preselect?: boolean
|
9048 | filterText?: string
|
9049 | /**
|
9050 | * A string that should be used when comparing this item
|
9051 | * with other items, only used for fuzzy filter.
|
9052 | */
|
9053 | sortText?: string
|
9054 | location?: Location | LocationWithLine | string
|
9055 | data?: any
|
9056 | ansiHighlights?: AnsiHighlight[]
|
9057 | resolved?: boolean
|
9058 | }
|
9059 |
|
9060 | export type ListMode = 'normal' | 'insert'
|
9061 |
|
9062 | export type ListMatcher = 'strict' | 'fuzzy' | 'regex'
|
9063 |
|
9064 | export interface ListOptions {
|
9065 | position: string
|
9066 | reverse: boolean
|
9067 | input: string
|
9068 | ignorecase: boolean
|
9069 | interactive: boolean
|
9070 | sort: boolean
|
9071 | mode: ListMode
|
9072 | matcher: ListMatcher
|
9073 | autoPreview: boolean
|
9074 | numberSelect: boolean
|
9075 | noQuit: boolean
|
9076 | first: boolean
|
9077 | }
|
9078 |
|
9079 | export interface ListContext {
|
9080 | /**
|
9081 | * Input on list activated.
|
9082 | */
|
9083 | input: string
|
9084 | /**
|
9085 | * Current work directory on activated.
|
9086 | */
|
9087 | cwd: string
|
9088 | /**
|
9089 | * Options of list.
|
9090 | */
|
9091 | options: ListOptions
|
9092 | /**
|
9093 | * Arguments passed to list.
|
9094 | */
|
9095 | args: string[]
|
9096 | /**
|
9097 | * Original window on list invoke.
|
9098 | */
|
9099 | window: Window
|
9100 | /**
|
9101 | * Original buffer on list invoke.
|
9102 | */
|
9103 | buffer: Buffer
|
9104 | listWindow: Window | null
|
9105 | }
|
9106 |
|
9107 | export interface ListAction {
|
9108 | /**
|
9109 | * Action name
|
9110 | */
|
9111 | name: string
|
9112 | /**
|
9113 | * Should persist list window on invoke.
|
9114 | */
|
9115 | persist?: boolean
|
9116 | /**
|
9117 | * Should reload list after invoke.
|
9118 | */
|
9119 | reload?: boolean
|
9120 | /**
|
9121 | * Inovke all selected items in parallel.
|
9122 | */
|
9123 | parallel?: boolean
|
9124 | /**
|
9125 | * Support handle multiple items at once.
|
9126 | */
|
9127 | multiple?: boolean
|
9128 | /**
|
9129 | * Tab positioned list should be persisted (no window switch) on action invoke.
|
9130 | */
|
9131 | tabPersist?: boolean
|
9132 | /**
|
9133 | * Item is array of selected items when multiple is true.
|
9134 | */
|
9135 | execute: (item: ListItem | ListItem[], context: ListContext) => ProviderResult<void>
|
9136 | }
|
9137 |
|
9138 | export interface MultipleListAction extends Omit<ListAction, 'execute'> {
|
9139 | multiple: true
|
9140 | execute: (item: ListItem[], context: ListContext) => ProviderResult<void>
|
9141 | }
|
9142 |
|
9143 | export interface ListTask {
|
9144 | on(event: 'data', callback: (item: ListItem) => void): void
|
9145 | on(event: 'end', callback: () => void): void
|
9146 | on(event: 'error', callback: (msg: string | Error) => void): void
|
9147 | dispose(): void
|
9148 | }
|
9149 |
|
9150 | export interface ListArgument {
|
9151 | key?: string
|
9152 | hasValue?: boolean
|
9153 | name: string
|
9154 | description: string
|
9155 | }
|
9156 |
|
9157 | export interface IList {
|
9158 | /**
|
9159 | * Unique name of list.
|
9160 | */
|
9161 | name: string
|
9162 | /**
|
9163 | * Default action name.
|
9164 | */
|
9165 | defaultAction: string
|
9166 | /**
|
9167 | * Action list.
|
9168 | */
|
9169 | actions: ListAction[]
|
9170 | /**
|
9171 | * Load list items.
|
9172 | */
|
9173 | loadItems(context: ListContext, token: CancellationToken): Promise<ListItem[] | ListTask | null | undefined>
|
9174 | /**
|
9175 | * Should be true when interactive is supported.
|
9176 | */
|
9177 | interactive?: boolean
|
9178 | /**
|
9179 | * Description of list.
|
9180 | */
|
9181 | description?: string
|
9182 | /**
|
9183 | * Detail description, shown in help.
|
9184 | */
|
9185 | detail?: string
|
9186 | /**
|
9187 | * Options supported by list.
|
9188 | */
|
9189 | options?: ListArgument[]
|
9190 | /**
|
9191 | * Resolve list item.
|
9192 | */
|
9193 | resolveItem?(item: ListItem): Promise<ListItem | null>
|
9194 | /**
|
9195 | * Highlight buffer by vim's syntax commands.
|
9196 | */
|
9197 | doHighlight?(): void
|
9198 | /**
|
9199 | * Called on list unregistered.
|
9200 | */
|
9201 | dispose?(): void
|
9202 | }
|
9203 |
|
9204 | export interface PreviewOptions {
|
9205 | bufname?: string
|
9206 | lines: string[]
|
9207 | filetype?: string
|
9208 | lnum?: number
|
9209 | range?: Range
|
9210 | /**
|
9211 | * @deprecated not used
|
9212 | */
|
9213 | sketch?: boolean
|
9214 | }
|
9215 |
|
9216 | export namespace listManager {
|
9217 | /**
|
9218 | * Registered list names set.
|
9219 | */
|
9220 | export const names: ReadonlyArray<string>
|
9221 | /**
|
9222 | * Register list, list session can be created by `CocList [name]` after registered.
|
9223 | */
|
9224 | export function registerList(list: IList): Disposable
|
9225 | }
|
9226 | // }}
|
9227 |
|
9228 | // snippetManager module {{
|
9229 | export interface SnippetSession {
|
9230 | isActive: boolean
|
9231 | }
|
9232 |
|
9233 | export interface UltiSnippetOption {
|
9234 | regex?: string
|
9235 | context?: string
|
9236 | }
|
9237 |
|
9238 | /**
|
9239 | * A snippet string is a template which allows to insert text
|
9240 | * and to control the editor cursor when insertion happens.
|
9241 | *
|
9242 | * A snippet can define tab stops and placeholders with `$1`, `$2`
|
9243 | * and `${3:foo}`. `$0` defines the final tab stop, it defaults to
|
9244 | * the end of the snippet. Variables are defined with `$name` and
|
9245 | * `${name:default value}`. The full snippet syntax is documented
|
9246 | * [here](https://code.visualstudio.com/docs/editor/userdefinedsnippets#_creating-your-own-snippets).
|
9247 | */
|
9248 | export class SnippetString {
|
9249 | /**
|
9250 | * The snippet string.
|
9251 | */
|
9252 | value: string
|
9253 |
|
9254 | constructor(
|
9255 | /**
|
9256 | * The default snippet string.
|
9257 | */
|
9258 | value?: string
|
9259 | )
|
9260 |
|
9261 | /**
|
9262 | * Builder-function that appends the given string to
|
9263 | * the {@link SnippetString.value `value`} of this snippet string.
|
9264 | *
|
9265 | * @param string A value to append 'as given'. The string will be escaped.
|
9266 | * @return This snippet string.
|
9267 | */
|
9268 | appendText(string: string): SnippetString
|
9269 |
|
9270 | /**
|
9271 | * Builder-function that appends a tabstop (`$1`, `$2` etc) to
|
9272 | * the {@link SnippetString.value `value`} of this snippet string.
|
9273 | *
|
9274 | * @param number The number of this tabstop, defaults to an auto-increment
|
9275 | * value starting at 1.
|
9276 | * @return This snippet string.
|
9277 | */
|
9278 | appendTabstop(number?: number): SnippetString
|
9279 |
|
9280 | /**
|
9281 | * Builder-function that appends a placeholder (`${1:value}`) to
|
9282 | * the {@link SnippetString.value `value`} of this snippet string.
|
9283 | *
|
9284 | * @param value The value of this placeholder - either a string or a function
|
9285 | * with which a nested snippet can be created.
|
9286 | * @param number The number of this tabstop, defaults to an auto-increment
|
9287 | * value starting at 1.
|
9288 | * @return This snippet string.
|
9289 | */
|
9290 | appendPlaceholder(value: string | ((snippet: SnippetString) => any), number?: number): SnippetString
|
9291 |
|
9292 | /**
|
9293 | * Builder-function that appends a choice (`${1|a,b,c|}`) to
|
9294 | * the {@link SnippetString.value `value`} of this snippet string.
|
9295 | *
|
9296 | * @param values The values for choices - the array of strings
|
9297 | * @param number The number of this tabstop, defaults to an auto-increment
|
9298 | * value starting at 1.
|
9299 | * @return This snippet string.
|
9300 | */
|
9301 | appendChoice(values: string[], number?: number): SnippetString
|
9302 |
|
9303 | /**
|
9304 | * Builder-function that appends a variable (`${VAR}`) to
|
9305 | * the {@link SnippetString.value `value`} of this snippet string.
|
9306 | *
|
9307 | * @param name The name of the variable - excluding the `$`.
|
9308 | * @param defaultValue The default value which is used when the variable name cannot
|
9309 | * be resolved - either a string or a function with which a nested snippet can be created.
|
9310 | * @return This snippet string.
|
9311 | */
|
9312 | appendVariable(name: string, defaultValue: string | ((snippet: SnippetString) => any)): SnippetString
|
9313 | }
|
9314 | /**
|
9315 | * Manage snippet sessions.
|
9316 | */
|
9317 | export namespace snippetManager {
|
9318 | /**
|
9319 | * Get snippet session by bufnr.
|
9320 | */
|
9321 | export function getSession(bufnr: number): SnippetSession | undefined
|
9322 | /**
|
9323 | * Resolve snippet string to text.
|
9324 | */
|
9325 | export function resolveSnippet(body: string, ultisnip?: UltiSnippetOption): Promise<string>
|
9326 | /**
|
9327 | * Insert snippet at current buffer.
|
9328 | *
|
9329 | * @param {string} snippet Textmate snippet string.
|
9330 | * @param {boolean} select Not select first placeholder when false, default `true`.
|
9331 | * @param {Range} range Repalce range, insert to current cursor position when undefined.
|
9332 | * @returns {Promise<boolean>} true when insert success.
|
9333 | */
|
9334 | export function insertSnippet(snippet: string | SnippetString, select?: boolean, range?: Range, ultisnip?: boolean): Promise<boolean>
|
9335 |
|
9336 | /**
|
9337 | * Jump to next placeholder, only works when snippet session activated.
|
9338 | */
|
9339 | export function nextPlaceholder(): Promise<void>
|
9340 | /**
|
9341 | * Jump to previous placeholder, only works when snippet session activated.
|
9342 | */
|
9343 | export function previousPlaceholder(): Promise<void>
|
9344 | /**
|
9345 | * Cancel snippet session of current buffer, does nothing when no session activated.
|
9346 | */
|
9347 | export function cancel(): void
|
9348 | /**
|
9349 | * Check if snippet activated for bufnr.
|
9350 | */
|
9351 | export function isActivated(bufnr: number): boolean
|
9352 | }
|
9353 | // }}
|
9354 |
|
9355 | // diagnosticManager module {{
|
9356 | export interface DiagnosticItem {
|
9357 | file: string
|
9358 | lnum: number
|
9359 | col: number
|
9360 | source: string
|
9361 | code: string | number
|
9362 | message: string
|
9363 | severity: string
|
9364 | level: number
|
9365 | location: Location
|
9366 | }
|
9367 |
|
9368 | export enum DiagnosticKind {
|
9369 | Syntax,
|
9370 | Semantic,
|
9371 | Suggestion,
|
9372 | }
|
9373 |
|
9374 | /**
|
9375 | * A diagnostics collection is a container that manages a set of
|
9376 | * [diagnostics](#Diagnostic). Diagnostics are always scopes to a
|
9377 | * diagnostics collection and a resource.
|
9378 | *
|
9379 | * To get an instance of a `DiagnosticCollection` use
|
9380 | * [createDiagnosticCollection](#languages.createDiagnosticCollection).
|
9381 | */
|
9382 | export interface DiagnosticCollection {
|
9383 |
|
9384 | /**
|
9385 | * The name of this diagnostic collection, for instance `typescript`. Every diagnostic
|
9386 | * from this collection will be associated with this name. Also, the task framework uses this
|
9387 | * name when defining [problem matchers](https://code.visualstudio.com/docs/editor/tasks#_defining-a-problem-matcher).
|
9388 | */
|
9389 | readonly name: string
|
9390 |
|
9391 | /**
|
9392 | * Assign diagnostics for given resource. Will replace
|
9393 | * existing diagnostics for that resource.
|
9394 | *
|
9395 | * @param uri A resource identifier.
|
9396 | * @param diagnostics Array of diagnostics or `undefined`
|
9397 | */
|
9398 | set(uri: string, diagnostics: Diagnostic[] | null): void
|
9399 | /**
|
9400 | * Replace all entries in this collection.
|
9401 | *
|
9402 | * Diagnostics of multiple tuples of the same uri will be merged, e.g
|
9403 | * `[[file1, [d1]], [file1, [d2]]]` is equivalent to `[[file1, [d1, d2]]]`.
|
9404 | * If a diagnostics item is `undefined` as in `[file1, undefined]`
|
9405 | * all previous but not subsequent diagnostics are removed.
|
9406 | *
|
9407 | * @param entries An array of tuples, like `[[file1, [d1, d2]], [file2, [d3, d4, d5]]]`, or `undefined`.
|
9408 | */
|
9409 | set(entries: [string, Diagnostic[] | null][] | string, diagnostics?: Diagnostic[]): void
|
9410 |
|
9411 | /**
|
9412 | * Remove all diagnostics from this collection that belong
|
9413 | * to the provided `uri`. The same as `#set(uri, undefined)`.
|
9414 | *
|
9415 | * @param uri A resource identifier.
|
9416 | */
|
9417 | delete(uri: string): void
|
9418 |
|
9419 | /**
|
9420 | * Remove all diagnostics from this collection. The same
|
9421 | * as calling `#set(undefined)`
|
9422 | */
|
9423 | clear(): void
|
9424 |
|
9425 | /**
|
9426 | * Iterate over each entry in this collection.
|
9427 | *
|
9428 | * @param callback Function to execute for each entry.
|
9429 | * @param thisArg The `this` context used when invoking the handler function.
|
9430 | */
|
9431 | forEach(callback: (uri: string, diagnostics: Diagnostic[], collection: DiagnosticCollection) => any, thisArg?: any): void
|
9432 |
|
9433 | /**
|
9434 | * Get the diagnostics for a given resource. *Note* that you cannot
|
9435 | * modify the diagnostics-array returned from this call.
|
9436 | *
|
9437 | * @param uri A resource identifier.
|
9438 | * @returns An immutable array of [diagnostics](#Diagnostic) or `undefined`.
|
9439 | */
|
9440 | get(uri: string): Diagnostic[] | undefined
|
9441 |
|
9442 | /**
|
9443 | * Check if this collection contains diagnostics for a
|
9444 | * given resource.
|
9445 | *
|
9446 | * @param uri A resource identifier.
|
9447 | * @returns `true` if this collection has diagnostic for the given resource.
|
9448 | */
|
9449 | has(uri: string): boolean
|
9450 |
|
9451 | /**
|
9452 | * Dispose and free associated resources. Calls
|
9453 | * [clear](#DiagnosticCollection.clear).
|
9454 | */
|
9455 | dispose(): void
|
9456 | }
|
9457 |
|
9458 | export interface DiagnosticEventParams {
|
9459 | bufnr: number
|
9460 | uri: string
|
9461 | diagnostics: ReadonlyArray<Diagnostic>
|
9462 | }
|
9463 |
|
9464 | export namespace diagnosticManager {
|
9465 |
|
9466 | export const onDidRefresh: Event<DiagnosticEventParams>
|
9467 | /**
|
9468 | * Create collection by name
|
9469 | */
|
9470 | export function create(name: string): DiagnosticCollection
|
9471 |
|
9472 | /**
|
9473 | * Get readonly diagnostics for uri
|
9474 | */
|
9475 | export function getDiagnostics(uri: string): { [collection: string]: Diagnostic[] }
|
9476 |
|
9477 | /**
|
9478 | * Get readonly diagnostics by document and range.
|
9479 | */
|
9480 | export function getDiagnosticsInRange(doc: TextDocumentIdentifier, range: Range): ReadonlyArray<Diagnostic>
|
9481 | /**
|
9482 | * Get all sorted diagnostics
|
9483 | */
|
9484 | export function getDiagnosticList(): Promise<ReadonlyArray<DiagnosticItem>>
|
9485 |
|
9486 | /**
|
9487 | * All diagnostics at current cursor position.
|
9488 | */
|
9489 | export function getCurrentDiagnostics(): Promise<ReadonlyArray<Diagnostic>>
|
9490 |
|
9491 | /**
|
9492 | * Get diagnostic collection.
|
9493 | */
|
9494 | export function getCollectionByName(name: string): DiagnosticCollection
|
9495 | }
|
9496 | // }}
|
9497 |
|
9498 | // language client {{
|
9499 | /**
|
9500 | * An action to be performed when the connection is producing errors.
|
9501 | */
|
9502 | export enum ErrorAction {
|
9503 | /**
|
9504 | * Continue running the server.
|
9505 | */
|
9506 | Continue = 1,
|
9507 | /**
|
9508 | * Shutdown the server.
|
9509 | */
|
9510 | Shutdown = 2
|
9511 | }
|
9512 | /**
|
9513 | * An action to be performed when the connection to a server got closed.
|
9514 | */
|
9515 | export enum CloseAction {
|
9516 | /**
|
9517 | * Don't restart the server. The connection stays closed.
|
9518 | */
|
9519 | DoNotRestart = 1,
|
9520 | /**
|
9521 | * Restart the server.
|
9522 | */
|
9523 | Restart = 2
|
9524 | }
|
9525 | /**
|
9526 | * A pluggable error handler that is invoked when the connection is either
|
9527 | * producing errors or got closed.
|
9528 | */
|
9529 | export interface ErrorHandler {
|
9530 | /**
|
9531 | * An error has occurred while writing or reading from the connection.
|
9532 | *
|
9533 | * @param error - the error received
|
9534 | * @param message - the message to be delivered to the server if know.
|
9535 | * @param count - a count indicating how often an error is received. Will
|
9536 | * be reset if a message got successfully send or received.
|
9537 | */
|
9538 | error(error: Error, message: { jsonrpc: string }, count: number): ErrorAction
|
9539 | /**
|
9540 | * The connection to the server got closed.
|
9541 | */
|
9542 | closed(): CloseAction
|
9543 | }
|
9544 | export interface InitializationFailedHandler {
|
9545 | (error: Error | any): boolean
|
9546 | }
|
9547 |
|
9548 | export interface SynchronizeOptions {
|
9549 | /**
|
9550 | * @deprecated Use the new pull model (`workspace/configuration` request)
|
9551 | */
|
9552 | configurationSection?: string | string[]
|
9553 | fileEvents?: FileSystemWatcher | FileSystemWatcher[]
|
9554 | }
|
9555 |
|
9556 | export enum RevealOutputChannelOn {
|
9557 | Info = 1,
|
9558 | Warn = 2,
|
9559 | Error = 3,
|
9560 | Never = 4
|
9561 | }
|
9562 | export interface ConfigurationItem {
|
9563 | /**
|
9564 | * The scope to get the configuration section for.
|
9565 | */
|
9566 | scopeUri?: string
|
9567 | /**
|
9568 | * The configuration section asked for.
|
9569 | */
|
9570 | section?: string
|
9571 | }
|
9572 | export interface ResponseError<D> {
|
9573 | code: number
|
9574 | data: D | undefined
|
9575 | }
|
9576 |
|
9577 | export type HandlerResult<R, E> = R | ResponseError<E> | Thenable<R> | Thenable<ResponseError<E>> | Thenable<R | ResponseError<E>>
|
9578 |
|
9579 | export interface RequestHandler<P, R, E> {
|
9580 | (params: P, token: CancellationToken): HandlerResult<R, E>
|
9581 | }
|
9582 |
|
9583 | export interface RequestHandler0<R, E> {
|
9584 | (token: CancellationToken): HandlerResult<R, E>
|
9585 | }
|
9586 | /**
|
9587 | * The parameters of a configuration request.
|
9588 | */
|
9589 | export interface ConfigurationParams {
|
9590 | items: ConfigurationItem[]
|
9591 | }
|
9592 |
|
9593 | export interface ConfigurationWorkspaceMiddleware {
|
9594 | configuration?: (params: ConfigurationParams, token: CancellationToken, next: RequestHandler<ConfigurationParams, any[], void>) => HandlerResult<any[], void>
|
9595 | }
|
9596 |
|
9597 | export interface WorkspaceFolderWorkspaceMiddleware {
|
9598 | workspaceFolders?: (token: CancellationToken, next: RequestHandler0<WorkspaceFolder[] | null, void>) => HandlerResult<WorkspaceFolder[] | null, void>
|
9599 | didChangeWorkspaceFolders?: NextSignature<WorkspaceFoldersChangeEvent, Promise<void>>
|
9600 | }
|
9601 |
|
9602 | export interface ProvideTypeDefinitionSignature {
|
9603 | (
|
9604 | this: void,
|
9605 | document: LinesTextDocument,
|
9606 | position: Position,
|
9607 | token: CancellationToken
|
9608 | ): ProviderResult<Definition | DefinitionLink[]>
|
9609 | }
|
9610 |
|
9611 | export interface TypeDefinitionMiddleware {
|
9612 | provideTypeDefinition?: (
|
9613 | this: void,
|
9614 | document: LinesTextDocument,
|
9615 | position: Position,
|
9616 | token: CancellationToken,
|
9617 | next: ProvideTypeDefinitionSignature
|
9618 | ) => ProviderResult<Definition | DefinitionLink[]>
|
9619 | }
|
9620 |
|
9621 | export interface ProvideImplementationSignature {
|
9622 | (this: void, document: LinesTextDocument, position: Position, token: CancellationToken): ProviderResult<Definition | DefinitionLink[]>
|
9623 | }
|
9624 |
|
9625 | export interface ImplementationMiddleware {
|
9626 | provideImplementation?: (this: void, document: LinesTextDocument, position: Position, token: CancellationToken, next: ProvideImplementationSignature) => ProviderResult<Definition | DefinitionLink[]>
|
9627 | }
|
9628 | export type ProvideDocumentColorsSignature = (document: LinesTextDocument, token: CancellationToken) => ProviderResult<ColorInformation[]>
|
9629 |
|
9630 | export type ProvideColorPresentationSignature = (
|
9631 | color: Color,
|
9632 | context: { document: LinesTextDocument; range: Range },
|
9633 | token: CancellationToken
|
9634 | ) => ProviderResult<ColorPresentation[]>
|
9635 |
|
9636 | export interface ColorProviderMiddleware {
|
9637 | provideDocumentColors?: (
|
9638 | this: void,
|
9639 | document: LinesTextDocument,
|
9640 | token: CancellationToken,
|
9641 | next: ProvideDocumentColorsSignature
|
9642 | ) => ProviderResult<ColorInformation[]>
|
9643 | provideColorPresentations?: (
|
9644 | this: void,
|
9645 | color: Color,
|
9646 | context: { document: LinesTextDocument; range: Range },
|
9647 | token: CancellationToken,
|
9648 | next: ProvideColorPresentationSignature
|
9649 | ) => ProviderResult<ColorPresentation[]>
|
9650 | }
|
9651 |
|
9652 | export interface ProvideDeclarationSignature {
|
9653 | (this: void, document: LinesTextDocument, position: Position, token: CancellationToken): ProviderResult<Declaration | DeclarationLink[]>
|
9654 | }
|
9655 |
|
9656 | export interface DeclarationMiddleware {
|
9657 | provideDeclaration?: (this: void, document: LinesTextDocument, position: Position, token: CancellationToken, next: ProvideDeclarationSignature) => ProviderResult<Declaration | DeclarationLink[]>
|
9658 | }
|
9659 |
|
9660 | export type ProvideFoldingRangeSignature = (
|
9661 | this: void,
|
9662 | document: LinesTextDocument,
|
9663 | context: FoldingContext,
|
9664 | token: CancellationToken
|
9665 | ) => ProviderResult<FoldingRange[]>
|
9666 |
|
9667 | export interface FoldingRangeProviderMiddleware {
|
9668 | provideFoldingRanges?: (
|
9669 | this: void,
|
9670 | document: LinesTextDocument,
|
9671 | context: FoldingContext,
|
9672 | token: CancellationToken,
|
9673 | next: ProvideFoldingRangeSignature
|
9674 | ) => ProviderResult<FoldingRange[]>
|
9675 | }
|
9676 |
|
9677 | export interface PrepareCallHierarchySignature {
|
9678 | (this: void, document: LinesTextDocument, position: Position, token: CancellationToken): ProviderResult<CallHierarchyItem | CallHierarchyItem[]>
|
9679 | }
|
9680 |
|
9681 | export interface CallHierarchyIncomingCallsSignature {
|
9682 | (this: void, item: CallHierarchyItem, token: CancellationToken): ProviderResult<CallHierarchyIncomingCall[]>
|
9683 | }
|
9684 |
|
9685 | export interface CallHierarchyOutgoingCallsSignature {
|
9686 | (this: void, item: CallHierarchyItem, token: CancellationToken): ProviderResult<CallHierarchyOutgoingCall[]>
|
9687 | }
|
9688 | export interface CallHierarchyMiddleware {
|
9689 | prepareCallHierarchy?: (
|
9690 | this: void,
|
9691 | document: LinesTextDocument,
|
9692 | positions: Position,
|
9693 | token: CancellationToken,
|
9694 | next: PrepareCallHierarchySignature
|
9695 | ) => ProviderResult<CallHierarchyItem | CallHierarchyItem[]>
|
9696 | provideCallHierarchyIncomingCalls?: (
|
9697 | this: void,
|
9698 | item: CallHierarchyItem,
|
9699 | token: CancellationToken,
|
9700 | next: CallHierarchyIncomingCallsSignature
|
9701 | ) => ProviderResult<CallHierarchyIncomingCall[]>
|
9702 | provideCallHierarchyOutgoingCalls?: (
|
9703 | this: void,
|
9704 | item: CallHierarchyItem,
|
9705 | token: CancellationToken,
|
9706 | next: CallHierarchyOutgoingCallsSignature
|
9707 | ) => ProviderResult<CallHierarchyOutgoingCall[]>
|
9708 | }
|
9709 |
|
9710 | export interface DocumentSemanticsTokensSignature {
|
9711 | (this: void, document: LinesTextDocument, token: CancellationToken): ProviderResult<SemanticTokens>
|
9712 | }
|
9713 |
|
9714 | export interface DocumentSemanticsTokensEditsSignature {
|
9715 | (this: void, document: LinesTextDocument, previousResultId: string, token: CancellationToken): ProviderResult<SemanticTokens | SemanticTokensDelta>
|
9716 | }
|
9717 |
|
9718 | export interface DocumentRangeSemanticTokensSignature {
|
9719 | (this: void, document: LinesTextDocument, range: Range, token: CancellationToken): ProviderResult<SemanticTokens>
|
9720 | }
|
9721 |
|
9722 | export interface SemanticTokensMiddleware {
|
9723 | provideDocumentSemanticTokens?: (
|
9724 | this: void,
|
9725 | document: LinesTextDocument,
|
9726 | token: CancellationToken,
|
9727 | next: DocumentSemanticsTokensSignature
|
9728 | ) => ProviderResult<SemanticTokens>
|
9729 | provideDocumentSemanticTokensEdits?: (
|
9730 | this: void,
|
9731 | document: LinesTextDocument,
|
9732 | previousResultId: string,
|
9733 | token: CancellationToken,
|
9734 | next: DocumentSemanticsTokensEditsSignature
|
9735 | ) => ProviderResult<SemanticTokens | SemanticTokensDelta>
|
9736 | provideDocumentRangeSemanticTokens?: (
|
9737 | this: void,
|
9738 | document: LinesTextDocument,
|
9739 | range: Range,
|
9740 | token: CancellationToken,
|
9741 | next: DocumentRangeSemanticTokensSignature
|
9742 | ) => ProviderResult<SemanticTokens>
|
9743 | }
|
9744 |
|
9745 | export interface FileOperationsMiddleware {
|
9746 | didCreateFiles?: NextSignature<FileCreateEvent, Promise<void>>
|
9747 | willCreateFiles?: NextSignature<FileWillCreateEvent, Thenable<WorkspaceEdit | null | undefined>>
|
9748 | didRenameFiles?: NextSignature<FileRenameEvent, Promise<void>>
|
9749 | willRenameFiles?: NextSignature<FileWillRenameEvent, Thenable<WorkspaceEdit | null | undefined>>
|
9750 | didDeleteFiles?: NextSignature<FileDeleteEvent, Promise<void>>
|
9751 | willDeleteFiles?: NextSignature<FileWillDeleteEvent, Thenable<WorkspaceEdit | null | undefined>>
|
9752 | }
|
9753 |
|
9754 | export interface ProvideLinkedEditingRangeSignature {
|
9755 | (this: void, document: LinesTextDocument, position: Position, token: CancellationToken): ProviderResult<LinkedEditingRanges>
|
9756 | }
|
9757 |
|
9758 | export interface LinkedEditingRangeMiddleware {
|
9759 | provideLinkedEditingRange?: (
|
9760 | this: void,
|
9761 | document: LinesTextDocument,
|
9762 | position: Position,
|
9763 | token: CancellationToken,
|
9764 | next: ProvideLinkedEditingRangeSignature
|
9765 | ) => ProviderResult<LinkedEditingRanges>
|
9766 | }
|
9767 |
|
9768 | export interface ProvideSelectionRangeSignature {
|
9769 | (this: void, document: LinesTextDocument, positions: Position[], token: CancellationToken): ProviderResult<SelectionRange[]>
|
9770 | }
|
9771 |
|
9772 | export interface SelectionRangeProviderMiddleware {
|
9773 | provideSelectionRanges?: (this: void, document: LinesTextDocument, positions: Position[], token: CancellationToken, next: ProvideSelectionRangeSignature) => ProviderResult<SelectionRange[]>
|
9774 | }
|
9775 |
|
9776 | export type ProvideDiagnosticSignature = (this: void, document: TextDocument, previousResultId: string | undefined, token: CancellationToken) => ProviderResult<DocumentDiagnosticReport>
|
9777 |
|
9778 | export type ProvideWorkspaceDiagnosticSignature = (this: void, resultIds: PreviousResultId[], token: CancellationToken, resultReporter: ResultReporter) => ProviderResult<WorkspaceDiagnosticReport>
|
9779 |
|
9780 | export interface DiagnosticProviderMiddleware {
|
9781 | provideDiagnostics?: (this: void, document: TextDocument, previousResultId: string | undefined, token: CancellationToken, next: ProvideDiagnosticSignature) => ProviderResult<DocumentDiagnosticReport>
|
9782 | provideWorkspaceDiagnostics?: (this: void, resultIds: PreviousResultId[], token: CancellationToken, resultReporter: ResultReporter, next: ProvideWorkspaceDiagnosticSignature) => ProviderResult<WorkspaceDiagnosticReport>
|
9783 | }
|
9784 |
|
9785 | export interface HandleWorkDoneProgressSignature {
|
9786 | (this: void, token: ProgressToken, params: WorkDoneProgressBegin | WorkDoneProgressReport | WorkDoneProgressEnd): void
|
9787 | }
|
9788 |
|
9789 | export interface HandleDiagnosticsSignature {
|
9790 | (this: void, uri: string, diagnostics: Diagnostic[]): void
|
9791 | }
|
9792 |
|
9793 | export interface ProvideCompletionItemsSignature {
|
9794 | (this: void, document: LinesTextDocument, position: Position, context: CompletionContext, token: CancellationToken): ProviderResult<CompletionItem[] | CompletionList | null>
|
9795 | }
|
9796 |
|
9797 | export interface ResolveCompletionItemSignature {
|
9798 | (this: void, item: CompletionItem, token: CancellationToken): ProviderResult<CompletionItem>
|
9799 | }
|
9800 |
|
9801 | export interface ProvideHoverSignature {
|
9802 | (this: void, document: LinesTextDocument, position: Position, token: CancellationToken): ProviderResult<Hover>
|
9803 | }
|
9804 |
|
9805 | export interface ProvideSignatureHelpSignature {
|
9806 | (this: void, document: LinesTextDocument, position: Position, context: SignatureHelpContext, token: CancellationToken): ProviderResult<SignatureHelp>
|
9807 | }
|
9808 |
|
9809 | export interface ProvideDefinitionSignature {
|
9810 | (this: void, document: LinesTextDocument, position: Position, token: CancellationToken): ProviderResult<Definition | DefinitionLink[]>
|
9811 | }
|
9812 |
|
9813 | export interface ProvideReferencesSignature {
|
9814 | (this: void, document: LinesTextDocument, position: Position, options: {
|
9815 | includeDeclaration: boolean
|
9816 | }, token: CancellationToken): ProviderResult<Location[]>
|
9817 | }
|
9818 |
|
9819 | export interface ProvideDocumentHighlightsSignature {
|
9820 | (this: void, document: LinesTextDocument, position: Position, token: CancellationToken): ProviderResult<DocumentHighlight[]>
|
9821 | }
|
9822 |
|
9823 | export interface ProvideDocumentSymbolsSignature {
|
9824 | (this: void, document: LinesTextDocument, token: CancellationToken): ProviderResult<SymbolInformation[] | DocumentSymbol[]>
|
9825 | }
|
9826 |
|
9827 | export interface ProvideWorkspaceSymbolsSignature {
|
9828 | (this: void, query: string, token: CancellationToken): ProviderResult<SymbolInformation[]>
|
9829 | }
|
9830 |
|
9831 | export interface ProvideCodeActionsSignature {
|
9832 | (this: void, document: LinesTextDocument, range: Range, context: CodeActionContext, token: CancellationToken): ProviderResult<(Command | CodeAction)[]>
|
9833 | }
|
9834 |
|
9835 | export interface ResolveCodeActionSignature {
|
9836 | (this: void, item: CodeAction, token: CancellationToken): ProviderResult<CodeAction>
|
9837 | }
|
9838 |
|
9839 | export interface ProvideCodeLensesSignature {
|
9840 | (this: void, document: LinesTextDocument, token: CancellationToken): ProviderResult<CodeLens[]>
|
9841 | }
|
9842 |
|
9843 | export interface ResolveCodeLensSignature {
|
9844 | (this: void, codeLens: CodeLens, token: CancellationToken): ProviderResult<CodeLens>
|
9845 | }
|
9846 |
|
9847 | export interface ProvideDocumentFormattingEditsSignature {
|
9848 | (this: void, document: LinesTextDocument, options: FormattingOptions, token: CancellationToken): ProviderResult<TextEdit[]>
|
9849 | }
|
9850 |
|
9851 | export interface ProvideDocumentRangeFormattingEditsSignature {
|
9852 | (this: void, document: LinesTextDocument, range: Range, options: FormattingOptions, token: CancellationToken): ProviderResult<TextEdit[]>
|
9853 | }
|
9854 |
|
9855 | export interface ProvideOnTypeFormattingEditsSignature {
|
9856 | (this: void, document: LinesTextDocument, position: Position, ch: string, options: FormattingOptions, token: CancellationToken): ProviderResult<TextEdit[]>
|
9857 | }
|
9858 |
|
9859 | export interface PrepareRenameSignature {
|
9860 | (this: void, document: LinesTextDocument, position: Position, token: CancellationToken): ProviderResult<Range | {
|
9861 | range: Range
|
9862 | placeholder: string
|
9863 | }>
|
9864 | }
|
9865 |
|
9866 | export interface ProvideRenameEditsSignature {
|
9867 | (this: void, document: LinesTextDocument, position: Position, newName: string, token: CancellationToken): ProviderResult<WorkspaceEdit>
|
9868 | }
|
9869 |
|
9870 | export interface ProvideDocumentLinksSignature {
|
9871 | (this: void, document: LinesTextDocument, token: CancellationToken): ProviderResult<DocumentLink[]>
|
9872 | }
|
9873 |
|
9874 | export interface ResolveDocumentLinkSignature {
|
9875 | (this: void, link: DocumentLink, token: CancellationToken): ProviderResult<DocumentLink>
|
9876 | }
|
9877 |
|
9878 | export interface ExecuteCommandSignature {
|
9879 | (this: void, command: string, args: any[]): ProviderResult<any>
|
9880 | }
|
9881 |
|
9882 | export interface NextSignature<P, R> {
|
9883 | (this: void, data: P, next: (data: P) => R): R
|
9884 | }
|
9885 |
|
9886 | export interface DidChangeConfigurationSignature {
|
9887 | (this: void, sections: string[] | undefined): void
|
9888 | }
|
9889 |
|
9890 | export interface DidChangeWatchedFileSignature {
|
9891 | (this: void, event: FileEvent): void
|
9892 | }
|
9893 |
|
9894 | export interface _WorkspaceMiddleware {
|
9895 | didChangeConfiguration?: (this: void, sections: string[] | undefined, next: DidChangeConfigurationSignature) => Promise<void>
|
9896 | didChangeWatchedFile?: (this: void, event: FileEvent, next: DidChangeWatchedFileSignature) => void
|
9897 | }
|
9898 |
|
9899 | export type WorkspaceMiddleware = _WorkspaceMiddleware & ConfigurationWorkspaceMiddleware & WorkspaceFolderWorkspaceMiddleware & FileOperationsMiddleware
|
9900 |
|
9901 | /**
|
9902 | * Params to show a document.
|
9903 | *
|
9904 | * @since 3.16.0
|
9905 | */
|
9906 | export interface ShowDocumentParams {
|
9907 | /**
|
9908 | * The document uri to show.
|
9909 | */
|
9910 | uri: string
|
9911 | /**
|
9912 | * Indicates to show the resource in an external program.
|
9913 | * To show for example `https://code.visualstudio.com/`
|
9914 | * in the default WEB browser set `external` to `true`.
|
9915 | */
|
9916 | external?: boolean
|
9917 | /**
|
9918 | * An optional property to indicate whether the editor
|
9919 | * showing the document should take focus or not.
|
9920 | * Clients might ignore this property if an external
|
9921 | * program in started.
|
9922 | */
|
9923 | takeFocus?: boolean
|
9924 | /**
|
9925 | * An optional selection range if the document is a text
|
9926 | * document. Clients might ignore the property if an
|
9927 | * external program is started or the file is not a text
|
9928 | * file.
|
9929 | */
|
9930 | selection?: Range
|
9931 | }
|
9932 | /**
|
9933 | * The result of an show document request.
|
9934 | *
|
9935 | * @since 3.16.0
|
9936 | */
|
9937 | export interface ShowDocumentResult {
|
9938 | /**
|
9939 | * A boolean indicating if the show was successful.
|
9940 | */
|
9941 | success: boolean
|
9942 | }
|
9943 |
|
9944 | export interface _WindowMiddleware {
|
9945 | showDocument?: (
|
9946 | this: void,
|
9947 | params: ShowDocumentParams,
|
9948 | next: RequestHandler<ShowDocumentParams, ShowDocumentResult, void>
|
9949 | ) => Promise<ShowDocumentResult>
|
9950 | }
|
9951 | export type WindowMiddleware = _WindowMiddleware
|
9952 |
|
9953 | /**
|
9954 | * The Middleware lets extensions intercept the request and notifications send and received
|
9955 | * from the server
|
9956 | */
|
9957 | interface _Middleware {
|
9958 | didOpen?: NextSignature<LinesTextDocument, Promise<void>>
|
9959 | didChange?: NextSignature<DidChangeTextDocumentParams, Promise<void>>
|
9960 | willSave?: NextSignature<TextDocumentWillSaveEvent, Promise<void>>
|
9961 | willSaveWaitUntil?: NextSignature<TextDocumentWillSaveEvent, Thenable<TextEdit[]>>
|
9962 | didSave?: NextSignature<LinesTextDocument, Promise<void>>
|
9963 | didClose?: NextSignature<LinesTextDocument, Promise<void>>
|
9964 | handleDiagnostics?: (this: void, uri: string, diagnostics: Diagnostic[], next: HandleDiagnosticsSignature) => void
|
9965 | provideCompletionItem?: (this: void, document: LinesTextDocument, position: Position, context: CompletionContext, token: CancellationToken, next: ProvideCompletionItemsSignature) => ProviderResult<CompletionItem[] | CompletionList | null>
|
9966 | resolveCompletionItem?: (this: void, item: CompletionItem, token: CancellationToken, next: ResolveCompletionItemSignature) => ProviderResult<CompletionItem>
|
9967 | provideHover?: (this: void, document: LinesTextDocument, position: Position, token: CancellationToken, next: ProvideHoverSignature) => ProviderResult<Hover>
|
9968 | provideSignatureHelp?: (this: void, document: LinesTextDocument, position: Position, context: SignatureHelpContext, token: CancellationToken, next: ProvideSignatureHelpSignature) => ProviderResult<SignatureHelp>
|
9969 | provideDefinition?: (this: void, document: LinesTextDocument, position: Position, token: CancellationToken, next: ProvideDefinitionSignature) => ProviderResult<Definition | DefinitionLink[]>
|
9970 | provideReferences?: (this: void, document: LinesTextDocument, position: Position, options: {
|
9971 | includeDeclaration: boolean
|
9972 | }, token: CancellationToken, next: ProvideReferencesSignature) => ProviderResult<Location[]>
|
9973 | provideDocumentHighlights?: (this: void, document: LinesTextDocument, position: Position, token: CancellationToken, next: ProvideDocumentHighlightsSignature) => ProviderResult<DocumentHighlight[]>
|
9974 | provideDocumentSymbols?: (this: void, document: LinesTextDocument, token: CancellationToken, next: ProvideDocumentSymbolsSignature) => ProviderResult<SymbolInformation[] | DocumentSymbol[]>
|
9975 | provideWorkspaceSymbols?: (this: void, query: string, token: CancellationToken, next: ProvideWorkspaceSymbolsSignature) => ProviderResult<SymbolInformation[]>
|
9976 | provideCodeActions?: (this: void, document: LinesTextDocument, range: Range, context: CodeActionContext, token: CancellationToken, next: ProvideCodeActionsSignature) => ProviderResult<(Command | CodeAction)[]>
|
9977 | handleWorkDoneProgress?: (this: void, token: ProgressToken, params: WorkDoneProgressBegin | WorkDoneProgressReport | WorkDoneProgressEnd, next: HandleWorkDoneProgressSignature) => void
|
9978 | resolveCodeAction?: (this: void, item: CodeAction, token: CancellationToken, next: ResolveCodeActionSignature) => ProviderResult<CodeAction>
|
9979 | provideCodeLenses?: (this: void, document: LinesTextDocument, token: CancellationToken, next: ProvideCodeLensesSignature) => ProviderResult<CodeLens[]>
|
9980 | resolveCodeLens?: (this: void, codeLens: CodeLens, token: CancellationToken, next: ResolveCodeLensSignature) => ProviderResult<CodeLens>
|
9981 | provideDocumentFormattingEdits?: (this: void, document: LinesTextDocument, options: FormattingOptions, token: CancellationToken, next: ProvideDocumentFormattingEditsSignature) => ProviderResult<TextEdit[]>
|
9982 | provideDocumentRangeFormattingEdits?: (this: void, document: LinesTextDocument, range: Range, options: FormattingOptions, token: CancellationToken, next: ProvideDocumentRangeFormattingEditsSignature) => ProviderResult<TextEdit[]>
|
9983 | provideOnTypeFormattingEdits?: (this: void, document: LinesTextDocument, position: Position, ch: string, options: FormattingOptions, token: CancellationToken, next: ProvideOnTypeFormattingEditsSignature) => ProviderResult<TextEdit[]>
|
9984 | prepareRename?: (this: void, document: LinesTextDocument, position: Position, token: CancellationToken, next: PrepareRenameSignature) => ProviderResult<Range | {
|
9985 | range: Range
|
9986 | placeholder: string
|
9987 | }>
|
9988 | provideRenameEdits?: (this: void, document: LinesTextDocument, position: Position, newName: string, token: CancellationToken, next: ProvideRenameEditsSignature) => ProviderResult<WorkspaceEdit>
|
9989 | provideDocumentLinks?: (this: void, document: LinesTextDocument, token: CancellationToken, next: ProvideDocumentLinksSignature) => ProviderResult<DocumentLink[]>
|
9990 | resolveDocumentLink?: (this: void, link: DocumentLink, token: CancellationToken, next: ResolveDocumentLinkSignature) => ProviderResult<DocumentLink>
|
9991 | executeCommand?: (this: void, command: string, args: any[], next: ExecuteCommandSignature) => ProviderResult<any>
|
9992 | workspace?: WorkspaceMiddleware
|
9993 | window?: WindowMiddleware
|
9994 | }
|
9995 | export type Middleware = _Middleware & TypeDefinitionMiddleware & ImplementationMiddleware & ColorProviderMiddleware & DeclarationMiddleware & FoldingRangeProviderMiddleware & CallHierarchyMiddleware & SemanticTokensMiddleware & LinkedEditingRangeMiddleware & SelectionRangeProviderMiddleware & DiagnosticProviderMiddleware
|
9996 |
|
9997 | export interface ConnectionOptions {
|
9998 | cancellationStrategy: unknown
|
9999 | maxRestartCount?: number
|
10000 | }
|
10001 |
|
10002 | export interface DiagnosticPullOptions {
|
10003 | /**
|
10004 | * Whether to pull for diagnostics on document change.
|
10005 | * Default to "pullDiagnostic.onChange" configuration.
|
10006 | */
|
10007 | onChange?: boolean
|
10008 |
|
10009 | /**
|
10010 | * Whether to pull for diagnostics on document save.
|
10011 | * Default to "pullDiagnostic.onSave" configuration.
|
10012 | */
|
10013 | onSave?: boolean
|
10014 |
|
10015 | /**
|
10016 | * Whether to pull for workspace diagnostics when possible.
|
10017 | * Default to "pullDiagnostic.workspace" configuration.
|
10018 | */
|
10019 | workspace?: boolean
|
10020 | /**
|
10021 | * Minimatch patterns to match full filepath that should be ignored for pullDiagnostic.
|
10022 | * Default to "pullDiagnostic.ignored" configuration.
|
10023 | */
|
10024 | ignored?: string[]
|
10025 |
|
10026 | /**
|
10027 | * An optional filter method that is consulted when triggering a
|
10028 | * diagnostic pull during document change or document save.
|
10029 | *
|
10030 | * @param document the document that changes or got save
|
10031 | * @param mode the mode
|
10032 | */
|
10033 | filter?(document: TextDocument, mode: 'onType' | 'onSave'): boolean
|
10034 | }
|
10035 |
|
10036 | export interface LanguageClientOptions {
|
10037 | ignoredRootPaths?: string[]
|
10038 | disableSnippetCompletion?: boolean
|
10039 | disableDynamicRegister?: boolean
|
10040 | disabledFeatures?: string[]
|
10041 | formatterPriority?: number
|
10042 | documentSelector?: DocumentSelector | string[]
|
10043 | synchronize?: SynchronizeOptions
|
10044 | diagnosticCollectionName?: string
|
10045 | outputChannelName?: string
|
10046 | outputChannel?: OutputChannel
|
10047 | revealOutputChannelOn?: RevealOutputChannelOn
|
10048 | /**
|
10049 | * The encoding use to read stdout and stderr. Defaults
|
10050 | * to 'utf8' if omitted.
|
10051 | */
|
10052 | stdioEncoding?: string
|
10053 | initializationOptions?: any | (() => any)
|
10054 | initializationFailedHandler?: InitializationFailedHandler
|
10055 | progressOnInitialization?: boolean
|
10056 | errorHandler?: ErrorHandler
|
10057 | middleware?: Middleware
|
10058 | workspaceFolder?: WorkspaceFolder
|
10059 | connectionOptions?: ConnectionOptions
|
10060 | diagnosticPullOptions?: DiagnosticPullOptions
|
10061 | markdown?: {
|
10062 | isTrusted?: boolean
|
10063 | /**
|
10064 | * Not used
|
10065 | */
|
10066 | supportHtml?: boolean
|
10067 | }
|
10068 | }
|
10069 | export enum State {
|
10070 | Stopped = 1,
|
10071 | Running = 2,
|
10072 | Starting = 3
|
10073 | }
|
10074 | export interface StateChangeEvent {
|
10075 | oldState: State
|
10076 | newState: State
|
10077 | }
|
10078 | export enum ClientState {
|
10079 | Initial = 0,
|
10080 | Starting = 1,
|
10081 | StartFailed = 2,
|
10082 | Running = 3,
|
10083 | Stopping = 4,
|
10084 | Stopped = 5
|
10085 | }
|
10086 | export interface RegistrationData<T> {
|
10087 | id: string
|
10088 | registerOptions: T
|
10089 | }
|
10090 |
|
10091 | export type FeatureState = {
|
10092 | kind: 'document'
|
10093 |
|
10094 | /**
|
10095 | * The features's id. This is usually the method names used during
|
10096 | * registration.
|
10097 | */
|
10098 | id: string
|
10099 |
|
10100 | /**
|
10101 | * Has active registrations.
|
10102 | */
|
10103 | registrations: boolean
|
10104 |
|
10105 | /**
|
10106 | * A registration matches an open document.
|
10107 | */
|
10108 | matches: boolean
|
10109 |
|
10110 | } | {
|
10111 | kind: 'workspace'
|
10112 |
|
10113 | /**
|
10114 | * The features's id. This is usually the method names used during
|
10115 | * registration.
|
10116 | */
|
10117 | id: string
|
10118 |
|
10119 | /**
|
10120 | * Has active registrations.
|
10121 | */
|
10122 | registrations: boolean
|
10123 | } | {
|
10124 | kind: 'window'
|
10125 |
|
10126 | /**
|
10127 | * The features's id. This is usually the method names used during
|
10128 | * registration.
|
10129 | */
|
10130 | id: string
|
10131 |
|
10132 | /**
|
10133 | * Has active registrations.
|
10134 | */
|
10135 | registrations: boolean
|
10136 | } | {
|
10137 | kind: 'static'
|
10138 | }
|
10139 | /**
|
10140 | * A static feature. A static feature can't be dynamically activate via the
|
10141 | * server. It is wired during the initialize sequence.
|
10142 | */
|
10143 | export interface StaticFeature {
|
10144 | /**
|
10145 | * Called to fill the initialize params.
|
10146 | *
|
10147 | * @params the initialize params.
|
10148 | */
|
10149 | fillInitializeParams?: (params: object) => void
|
10150 | /**
|
10151 | * Called to fill in the client capabilities this feature implements.
|
10152 | *
|
10153 | * @param capabilities The client capabilities to fill.
|
10154 | */
|
10155 | fillClientCapabilities(capabilities: object): void
|
10156 | /**
|
10157 | * A preflight where the server capabilities are shown to all features
|
10158 | * before a feature is actually initialized. This allows feature to
|
10159 | * capture some state if they are a pre-requisite for other features.
|
10160 | *
|
10161 | * @param capabilities the server capabilities
|
10162 | * @param documentSelector the document selector pass to the client's constructor.
|
10163 | * May be `undefined` if the client was created without a selector.
|
10164 | */
|
10165 | preInitialize?: (capabilities: object, documentSelector: DocumentSelector | undefined) => void
|
10166 | /**
|
10167 | * Initialize the feature. This method is called on a feature instance
|
10168 | * when the client has successfully received the initialize request from
|
10169 | * the server and before the client sends the initialized notification
|
10170 | * to the server.
|
10171 | *
|
10172 | * @param capabilities the server capabilities
|
10173 | * @param documentSelector the document selector pass to the client's constructor.
|
10174 | * May be `undefined` if the client was created without a selector.
|
10175 | */
|
10176 | initialize(capabilities: object, documentSelector: DocumentSelector | undefined): void
|
10177 | /**
|
10178 | * Returns the state the feature is in.
|
10179 | */
|
10180 | getState?(): FeatureState
|
10181 | /**
|
10182 | * Called when the client is stopped to dispose this feature. Usually a feature
|
10183 | * unregisters listeners registered hooked up with the VS Code extension host.
|
10184 | */
|
10185 | dispose(): void
|
10186 | }
|
10187 |
|
10188 | /**
|
10189 | * A dynamic feature can be activated via the server.
|
10190 | */
|
10191 | export interface DynamicFeature<RO> {
|
10192 | /**
|
10193 | * Called to fill the initialize params.
|
10194 | *
|
10195 | * @params the initialize params.
|
10196 | */
|
10197 | fillInitializeParams?: (params: InitializeParams) => void
|
10198 | /**
|
10199 | * Called to fill in the client capabilities this feature implements.
|
10200 | *
|
10201 | * @param capabilities The client capabilities to fill.
|
10202 | */
|
10203 | fillClientCapabilities(capabilities: any): void
|
10204 | /**
|
10205 | * Initialize the feature. This method is called on a feature instance
|
10206 | * when the client has successfully received the initialize request from
|
10207 | * the server and before the client sends the initialized notification
|
10208 | * to the server.
|
10209 | *
|
10210 | * @param capabilities the server capabilities.
|
10211 | * @param documentSelector the document selector pass to the client's constructor.
|
10212 | * May be `undefined` if the client was created without a selector.
|
10213 | */
|
10214 | initialize(capabilities: object, documentSelector: DocumentSelector | undefined): void
|
10215 |
|
10216 | /**
|
10217 | * A preflight where the server capabilities are shown to all features
|
10218 | * before a feature is actually initialized. This allows feature to
|
10219 | * capture some state if they are a pre-requisite for other features.
|
10220 | *
|
10221 | * @param capabilities the server capabilities
|
10222 | * @param documentSelector the document selector pass to the client's constructor.
|
10223 | * May be `undefined` if the client was created without a selector.
|
10224 | */
|
10225 | preInitialize?: (capabilities: object, documentSelector: DocumentSelector | undefined) => void
|
10226 | /**
|
10227 | * The signature (e.g. method) for which this features support dynamic activation / registration.
|
10228 | */
|
10229 | registrationType: RegistrationType<RO>
|
10230 | /**
|
10231 | * Is called when the server send a register request for the given message.
|
10232 | *
|
10233 | * @param data additional registration data as defined in the protocol.
|
10234 | */
|
10235 | register(data: RegistrationData<RO>): void
|
10236 | /**
|
10237 | * Is called when the server wants to unregister a feature.
|
10238 | *
|
10239 | * @param id the id used when registering the feature.
|
10240 | */
|
10241 | unregister(id: string): void
|
10242 | /**
|
10243 | * Returns the state the feature is in.
|
10244 | */
|
10245 | getState?(): FeatureState
|
10246 | /**
|
10247 | * Called when the client is stopped to dispose this feature. Usually a feature
|
10248 | * unregisters listeners registered hooked up with the VS Code extension host.
|
10249 | */
|
10250 | dispose(): void
|
10251 | }
|
10252 |
|
10253 | class ParameterStructures {
|
10254 | private readonly kind
|
10255 | /**
|
10256 | * The parameter structure is automatically inferred on the number of parameters
|
10257 | * and the parameter type in case of a single param.
|
10258 | */
|
10259 | static readonly auto: ParameterStructures
|
10260 | /**
|
10261 | * Forces `byPosition` parameter structure. This is useful if you have a single
|
10262 | * parameter which has a literal type.
|
10263 | */
|
10264 | static readonly byPosition: ParameterStructures
|
10265 | /**
|
10266 | * Forces `byName` parameter structure. This is only useful when having a single
|
10267 | * parameter. The library will report errors if used with a different number of
|
10268 | * parameters.
|
10269 | */
|
10270 | static readonly byName: ParameterStructures
|
10271 | private constructor()
|
10272 | static is(value: any): value is ParameterStructures
|
10273 | toString(): string
|
10274 | }
|
10275 | /**
|
10276 | * An interface to type messages.
|
10277 | */
|
10278 | export interface MessageSignature {
|
10279 | readonly method: string
|
10280 | readonly numberOfParams: number
|
10281 | readonly parameterStructures: ParameterStructures
|
10282 | }
|
10283 |
|
10284 | /**
|
10285 | *
|
10286 | * An abstract implementation of a MessageType.
|
10287 | */
|
10288 | abstract class AbstractMessageSignature implements MessageSignature {
|
10289 | readonly method: string
|
10290 | readonly numberOfParams: number
|
10291 | constructor(method: string, numberOfParams: number)
|
10292 | get parameterStructures(): ParameterStructures
|
10293 | }
|
10294 |
|
10295 | /**
|
10296 | * Classes to type request response pairs
|
10297 | */
|
10298 | export class RequestType0<R, E> extends AbstractMessageSignature {
|
10299 | /**
|
10300 | * Clients must not use this property. It is here to ensure correct typing.
|
10301 | */
|
10302 | readonly _: [R, E, _EM] | undefined
|
10303 | constructor(method: string)
|
10304 | }
|
10305 |
|
10306 | export class RequestType<P, R, E> extends AbstractMessageSignature {
|
10307 | private _parameterStructures
|
10308 | /**
|
10309 | * Clients must not use this property. It is here to ensure correct typing.
|
10310 | */
|
10311 | readonly _: [P, R, E, _EM] | undefined
|
10312 | constructor(method: string, _parameterStructures?: ParameterStructures)
|
10313 | get parameterStructures(): ParameterStructures
|
10314 | }
|
10315 |
|
10316 | export class NotificationType<P> extends AbstractMessageSignature {
|
10317 | /**
|
10318 | * Clients must not use this property. It is here to ensure correct typing.
|
10319 | */
|
10320 | readonly _: [P, _EM] | undefined
|
10321 | constructor(method: string)
|
10322 | }
|
10323 |
|
10324 | export class NotificationType0 extends AbstractMessageSignature {
|
10325 | /**
|
10326 | * Clients must not use this property. It is here to ensure correct typing.
|
10327 | */
|
10328 | readonly _: [_EM] | undefined
|
10329 | constructor(method: string)
|
10330 | }
|
10331 |
|
10332 | export interface InitializeParams {
|
10333 | /**
|
10334 | * The process Id of the parent process that started
|
10335 | * the server.
|
10336 | */
|
10337 | processId: number | null
|
10338 | /**
|
10339 | * Information about the client
|
10340 | *
|
10341 | * @since 3.15.0
|
10342 | */
|
10343 | clientInfo?: {
|
10344 | /**
|
10345 | * The name of the client as defined by the client.
|
10346 | */
|
10347 | name: string
|
10348 | /**
|
10349 | * The client's version as defined by the client.
|
10350 | */
|
10351 | version?: string
|
10352 | }
|
10353 | /**
|
10354 | * The rootPath of the workspace. Is null
|
10355 | * if no folder is open.
|
10356 | *
|
10357 | * @deprecated in favour of rootUri.
|
10358 | */
|
10359 | rootPath?: string | null
|
10360 | /**
|
10361 | * The rootUri of the workspace. Is null if no
|
10362 | * folder is open. If both `rootPath` and `rootUri` are set
|
10363 | * `rootUri` wins.
|
10364 | *
|
10365 | * @deprecated in favour of workspaceFolders.
|
10366 | */
|
10367 | rootUri: string | null
|
10368 | /**
|
10369 | * The capabilities provided by the client (editor or tool)
|
10370 | */
|
10371 | capabilities: any
|
10372 | /**
|
10373 | * User provided initialization options.
|
10374 | */
|
10375 | initializationOptions?: any
|
10376 | /**
|
10377 | * The initial trace setting. If omitted trace is disabled ('off').
|
10378 | */
|
10379 | trace?: 'off' | 'messages' | 'verbose'
|
10380 | /**
|
10381 | * An optional token that a server can use to report work done progress.
|
10382 | */
|
10383 | workDoneToken?: ProgressToken
|
10384 | }
|
10385 |
|
10386 | class RegistrationType<RO> {
|
10387 | /**
|
10388 | * Clients must not use this property. It is here to ensure correct typing.
|
10389 | */
|
10390 | readonly ____: [RO, _EM] | undefined
|
10391 | readonly method: string
|
10392 | constructor(method: string)
|
10393 | }
|
10394 | /**
|
10395 | * The result returned from an initialize request.
|
10396 | */
|
10397 | export interface InitializeResult {
|
10398 | /**
|
10399 | * The capabilities the language server provides.
|
10400 | */
|
10401 | capabilities: any
|
10402 | /**
|
10403 | * Information about the server.
|
10404 | *
|
10405 | * @since 3.15.0
|
10406 | */
|
10407 | serverInfo?: {
|
10408 | /**
|
10409 | * The name of the server as defined by the server.
|
10410 | */
|
10411 | name: string
|
10412 | /**
|
10413 | * The servers's version as defined by the server.
|
10414 | */
|
10415 | version?: string
|
10416 | }
|
10417 | /**
|
10418 | * Custom initialization results.
|
10419 | */
|
10420 | [custom: string]: any
|
10421 | }
|
10422 |
|
10423 | export interface NotificationFeature<T extends Function> {
|
10424 | /**
|
10425 | * Triggers the corresponding RPC method.
|
10426 | */
|
10427 | getProvider(document: TextDocument): {
|
10428 | send: T
|
10429 | }
|
10430 | }
|
10431 |
|
10432 | export interface ExecutableOptions {
|
10433 | cwd?: string
|
10434 | env?: any
|
10435 | detached?: boolean
|
10436 | shell?: boolean
|
10437 | }
|
10438 |
|
10439 | export interface Executable {
|
10440 | command: string
|
10441 | args?: string[]
|
10442 | options?: ExecutableOptions
|
10443 | }
|
10444 |
|
10445 | export interface ForkOptions {
|
10446 | cwd?: string
|
10447 | env?: any
|
10448 | execPath?: string
|
10449 | encoding?: string
|
10450 | execArgv?: string[]
|
10451 | }
|
10452 |
|
10453 | export interface StreamInfo {
|
10454 | writer: NodeJS.WritableStream
|
10455 | reader: NodeJS.ReadableStream
|
10456 | detached?: boolean
|
10457 | }
|
10458 |
|
10459 | export enum TransportKind {
|
10460 | stdio = 0,
|
10461 | ipc = 1,
|
10462 | pipe = 2,
|
10463 | socket = 3
|
10464 | }
|
10465 |
|
10466 | export interface SocketTransport {
|
10467 | kind: TransportKind.socket
|
10468 | port: number
|
10469 | }
|
10470 |
|
10471 | export interface NodeModule {
|
10472 | module: string
|
10473 | transport?: TransportKind | SocketTransport
|
10474 | args?: string[]
|
10475 | runtime?: string
|
10476 | options?: ForkOptions
|
10477 | }
|
10478 |
|
10479 | export interface ChildProcessInfo {
|
10480 | process: cp.ChildProcess
|
10481 | detached: boolean
|
10482 | }
|
10483 |
|
10484 | export interface PartialMessageInfo {
|
10485 | readonly messageToken: number
|
10486 | readonly waitingTime: number
|
10487 | }
|
10488 |
|
10489 | export interface MessageReader {
|
10490 | readonly onError: Event<Error>
|
10491 | readonly onClose: Event<void>
|
10492 | readonly onPartialMessage: Event<PartialMessageInfo>
|
10493 | listen(callback: (data: { jsonrpc: string }) => void): void
|
10494 | dispose(): void
|
10495 | }
|
10496 |
|
10497 | export interface MessageWriter {
|
10498 | readonly onError: Event<[Error, { jsonrpc: string } | undefined, number | undefined]>
|
10499 | readonly onClose: Event<void>
|
10500 | write(msg: { jsonrpc: string }): void
|
10501 | dispose(): void
|
10502 | }
|
10503 |
|
10504 | export class NullLogger {
|
10505 | constructor()
|
10506 | error(message: string): void
|
10507 | warn(message: string): void
|
10508 | info(message: string): void
|
10509 | log(message: string): void
|
10510 | }
|
10511 |
|
10512 | export interface MessageTransports {
|
10513 | reader: MessageReader
|
10514 | writer: MessageWriter
|
10515 | detached?: boolean
|
10516 | }
|
10517 |
|
10518 | export namespace MessageTransports {
|
10519 | /**
|
10520 | * Checks whether the given value conforms to the [MessageTransports](#MessageTransports) interface.
|
10521 | */
|
10522 | function is(value: any): value is MessageTransports
|
10523 | }
|
10524 |
|
10525 | export type ServerOptions = Executable | NodeModule | {
|
10526 | run: Executable
|
10527 | debug: Executable
|
10528 | } | {
|
10529 | run: NodeModule
|
10530 | debug: NodeModule
|
10531 | } | (() => Promise<cp.ChildProcess | StreamInfo | MessageTransports | ChildProcessInfo>)
|
10532 |
|
10533 | export interface _EM {
|
10534 | _$endMarker$_: number
|
10535 | }
|
10536 |
|
10537 | export class ProgressType<PR> {
|
10538 | /**
|
10539 | * Clients must not use these properties. They are here to ensure correct typing.
|
10540 | * in TypeScript
|
10541 | */
|
10542 | readonly __?: [PR, _EM]
|
10543 | readonly _pr?: PR
|
10544 | constructor()
|
10545 | }
|
10546 |
|
10547 | export enum Trace {
|
10548 | Off = 0,
|
10549 | Messages = 1,
|
10550 | Verbose = 2
|
10551 | }
|
10552 |
|
10553 | export class ProtocolRequestType0<R, PR, E, RO> extends RequestType0<R, E> implements ProgressType<PR>, RegistrationType<RO> {
|
10554 | /**
|
10555 | * Clients must not use these properties. They are here to ensure correct typing.
|
10556 | * in TypeScript
|
10557 | */
|
10558 | readonly ___: [PR, RO, _EM] | undefined
|
10559 | readonly ____: [RO, _EM] | undefined
|
10560 | readonly _pr: PR | undefined
|
10561 | constructor(method: string)
|
10562 | }
|
10563 |
|
10564 | export class ProtocolRequestType<P, R, PR, E, RO> extends RequestType<P, R, E> implements ProgressType<PR>, RegistrationType<RO> {
|
10565 | /**
|
10566 | * Clients must not use this property. It is here to ensure correct typing.
|
10567 | */
|
10568 | readonly ___: [PR, RO, _EM] | undefined
|
10569 | readonly ____: [RO, _EM] | undefined
|
10570 | readonly _pr: PR | undefined
|
10571 | constructor(method: string)
|
10572 | }
|
10573 |
|
10574 | export class ProtocolNotificationType0<RO> extends NotificationType0 implements RegistrationType<RO> {
|
10575 | /**
|
10576 | * Clients must not use this property. It is here to ensure correct typing.
|
10577 | */
|
10578 | readonly ___: [RO, _EM] | undefined
|
10579 | readonly ____: [RO, _EM] | undefined
|
10580 | constructor(method: string)
|
10581 | }
|
10582 | export class ProtocolNotificationType<P, RO> extends NotificationType<P> implements RegistrationType<RO> {
|
10583 | /**
|
10584 | * Clients must not use this property. It is here to ensure correct typing.
|
10585 | */
|
10586 | readonly ___: [RO, _EM] | undefined
|
10587 | readonly ____: [RO, _EM] | undefined
|
10588 | constructor(method: string)
|
10589 | }
|
10590 |
|
10591 | export interface NotificationHandler0 {
|
10592 | (): void
|
10593 | }
|
10594 |
|
10595 | export interface NotificationHandler<P> {
|
10596 | (params: P): void
|
10597 | }
|
10598 |
|
10599 | /**
|
10600 | * A language server for manage a language server.
|
10601 | * It's recommended to use `services.registerLanguageClient` to register language client to serviers,
|
10602 | * you can have language client listed in `CocList services` and services could start the language client
|
10603 | * by `documentselector` of `clientOptions`.
|
10604 | */
|
10605 | export class LanguageClient {
|
10606 | readonly id: string
|
10607 | readonly name: string
|
10608 | constructor(id: string, name: string, serverOptions: ServerOptions, clientOptions: LanguageClientOptions, forceDebug?: boolean)
|
10609 | /**
|
10610 | * Create language client by name and options, don't forget to register language client
|
10611 | * to services by `services.registerLanguageClient`
|
10612 | */
|
10613 | constructor(name: string, serverOptions: ServerOptions, clientOptions: LanguageClientOptions, forceDebug?: boolean)
|
10614 |
|
10615 | sendRequest<R, PR, E, RO>(type: ProtocolRequestType0<R, PR, E, RO>, token?: CancellationToken): Promise<R>
|
10616 | sendRequest<P, R, PR, E, RO>(type: ProtocolRequestType<P, R, PR, E, RO>, params: P, token?: CancellationToken): Promise<R>
|
10617 | /**
|
10618 | * R => result
|
10619 | * E => Error result
|
10620 | */
|
10621 | sendRequest<R, E>(type: RequestType0<R, E>, token?: CancellationToken): Promise<R>
|
10622 | /**
|
10623 | * P => params
|
10624 | * R => result
|
10625 | * E => Error result
|
10626 | */
|
10627 | sendRequest<P, R, E>(type: RequestType<P, R, E>, params: P, token?: CancellationToken): Promise<R>
|
10628 | sendRequest<R>(method: string, token?: CancellationToken): Promise<R>
|
10629 | sendRequest<R>(method: string, param: any, token?: CancellationToken): Promise<R>
|
10630 |
|
10631 | onRequest<R, PR, E, RO>(type: ProtocolRequestType0<R, PR, E, RO>, handler: RequestHandler0<R, E>): Disposable
|
10632 | onRequest<P, R, PR, E, RO>(type: ProtocolRequestType<P, R, PR, E, RO>, handler: RequestHandler<P, R, E>): Disposable
|
10633 | onRequest<R, E>(type: RequestType0<R, E>, handler: RequestHandler0<R, E>): Disposable
|
10634 | onRequest<P, R, E>(type: RequestType<P, R, E>, handler: RequestHandler<P, R, E>): Disposable
|
10635 | onRequest<R, E>(method: string, handler: (...params: any[]) => HandlerResult<R, E>): Disposable
|
10636 |
|
10637 | sendNotification<RO>(type: ProtocolNotificationType0<RO>): Promise<void>
|
10638 | sendNotification<P, RO>(type: ProtocolNotificationType<P, RO>, params?: P): Promise<void>
|
10639 | sendNotification(type: NotificationType0): Promise<void>
|
10640 | sendNotification<P>(type: NotificationType<P>, params?: P): Promise<void>
|
10641 | sendNotification(method: string): Promise<void>
|
10642 | sendNotification(method: string, params: any): Promise<void>
|
10643 |
|
10644 | onNotification<RO>(type: ProtocolNotificationType0<RO>, handler: NotificationHandler0): Disposable
|
10645 | onNotification<P, RO>(type: ProtocolNotificationType<P, RO>, handler: NotificationHandler<P>): Disposable
|
10646 | onNotification(type: NotificationType0, handler: () => void): Disposable
|
10647 | onNotification<P>(type: NotificationType<P>, handler: (params: P) => void): Disposable
|
10648 | onNotification(method: string, handler: (...params: any[]) => void): Disposable
|
10649 |
|
10650 | onProgress<P>(type: ProgressType<any>, token: string | number, handler: (params: P) => void): Disposable
|
10651 | sendProgress<P>(type: ProgressType<P>, token: string | number, value: P): Promise<void>
|
10652 |
|
10653 | /**
|
10654 | * Append info to outputChannel
|
10655 | */
|
10656 | info(message: string, data?: any): void
|
10657 | /**
|
10658 | * Append warning to outputChannel
|
10659 | */
|
10660 | warn(message: string, data?: any): void
|
10661 | /**
|
10662 | * append error to outputChannel
|
10663 | */
|
10664 | error(message: string, data?: any): void
|
10665 | getPublicState(): State
|
10666 |
|
10667 | readonly initializeResult: InitializeResult | undefined
|
10668 | readonly clientOptions: LanguageClientOptions
|
10669 | readonly outputChannel: OutputChannel
|
10670 | /**
|
10671 | * Fired on language server state change.
|
10672 | */
|
10673 | readonly onDidChangeState: Event<StateChangeEvent>
|
10674 | readonly diagnostics: DiagnosticCollection | undefined
|
10675 | /**
|
10676 | * Current running state.
|
10677 | */
|
10678 | readonly serviceState: ServiceStat
|
10679 | readonly started: boolean
|
10680 | /**
|
10681 | * Check if server could start.
|
10682 | */
|
10683 | needsStart(): boolean
|
10684 | /**
|
10685 | * Check if server could stop.
|
10686 | */
|
10687 | needsStop(): boolean
|
10688 | onReady(): Promise<void>
|
10689 | set trace(value: Trace)
|
10690 |
|
10691 | /**
|
10692 | * Stop language server.
|
10693 | */
|
10694 | stop(): Promise<void>
|
10695 |
|
10696 | /**
|
10697 | * Start language server, not needed when registered to services by `services.registerLanguageClient`
|
10698 | */
|
10699 | start(): Promise<void>
|
10700 | /**
|
10701 | * Restart language client.
|
10702 | */
|
10703 | restart(): void
|
10704 |
|
10705 | /**
|
10706 | * Register custom feature.
|
10707 | */
|
10708 | registerFeature(feature: StaticFeature | DynamicFeature<any>): void
|
10709 |
|
10710 | /**
|
10711 | * Log failed request to outputChannel.
|
10712 | */
|
10713 | handleFailedRequest<T, P extends { kind: string }>(type: P, token: CancellationToken | undefined, error: any, defaultValue: T)
|
10714 | }
|
10715 |
|
10716 | /**
|
10717 | * Monitor for setting change, restart language server when specified setting changed.
|
10718 | */
|
10719 | export class SettingMonitor {
|
10720 | constructor(client: LanguageClient, setting: string)
|
10721 | start(): Disposable
|
10722 | }
|
10723 | // }}
|
10724 | }
|
10725 | // vim: set sw=2 ts=2 sts=2 et foldmarker={{,}} foldmethod=marker foldlevel=0 nofen:
|
10726 |
|
\ | No newline at end of file |