) => any): Disposable
2156 | }
2157 |
2158 | /// https://docs.nova.app/api-reference/process-message/
2159 |
2160 | /** A `ProcessMessage` object is represents a messages sent from a subprocess to the extension via JSON-RPC. `ProcessMessage` objects are only used with a [Process](https://docs.nova.app/api-reference/process) object which has been set up to use JSON-RPC communication. */
2161 | interface ProcessMessage {
2162 | /** The method name of the message, as a string. If the message is a response, this will be `null`. */
2163 | readonly method: string | null
2164 |
2165 | /** An object containing the parameters of the message. All values are JSON-encodable. */
2166 | readonly parameters?: P
2167 |
2168 | /** If the message is a response whose request succeeded, this will contain the result object of the response, otherwise this will be `null`. */
2169 | readonly result: R
2170 |
2171 | /** If the message is a response whose request failed, this will contain the error code object of the response, otherwise this will be `null`. */
2172 | readonly errorCode: number | null
2173 |
2174 | /** If the message is a response whose request failed, this will contain the error reason object of the response, otherwise this will be `null`. */
2175 | readonly errorReason: string | null
2176 |
2177 | /** If the message is a response whose request failed, this will contain the error data object of the response (if any), otherwise this will be `null`. */
2178 | readonly errorData: E | null
2179 | }
2180 |
2181 | /// https://docs.nova.app/api-reference/range/
2182 |
2183 | /**
2184 | * A `Range` represents a contiguous, linear region of an element, specified by a start and end index. Most often it is used to indicate sections of a text stream.
2185 | *
2186 | * The `Range` class is not subclassable.
2187 | */
2188 | declare class Range {
2189 | /**
2190 | * Creates a new `Range` with a provided `start` and end `index`.
2191 | * @throws Raises an `Error` if the end index precedes the start index.
2192 | */
2193 | constructor(start: number, end: number)
2194 |
2195 | /** The start index of the range, as a `Number`. */
2196 | readonly start: number
2197 |
2198 | /** The end index of the range, as a `Number`. */
2199 | readonly end: number
2200 |
2201 | /** The length of the range, as a `Number`. This is equivalent to subtracting `start` from `end`. */
2202 | readonly length: number
2203 |
2204 | /** A `Boolean` indicating whether the range is empty (its start and end indices are the same). */
2205 | readonly empty: boolean
2206 |
2207 | /** Returns `true` if the receiver is equal to another provided range, `false` otherwise. */
2208 | isEqual(range: Range): boolean
2209 |
2210 | /** Returns a `Number` indicating how a provided range compares to the receiver in sort order. The return value will be `-1` if the receiver’s start index precedes the other’s, or if the same, if its length is shorter. The return value will be `1` if the opposite is true. The return value will be `0` if the ranges are equal. */
2211 | compare(range: Range): number
2212 |
2213 | /** Returns `true` if the receiver fully contains another provided range, `false` otherwise. */
2214 | containsRange(range: Range): boolean
2215 |
2216 | /** Returns `true` if the receiver contains a provided index, `false` otherwise. */
2217 | containsIndex(index: number): boolean
2218 |
2219 | /** Returns a new `Range` representing a union of the receiver and a provided range. */
2220 | union(range: Range): Range
2221 |
2222 | /** Returns a new `Range` representing an intersection of the receiver and a provided range. If the two ranges to not intersect, the returned range will have zero start and end indices. */
2223 | intersection(range: Range): Range
2224 |
2225 | /** Returns `true` if the receiver intersects a provided range (shares at least one index), `false` otherwise. */
2226 | intersectsRange(range: Range): boolean
2227 | }
2228 |
2229 | /// https://docs.nova.app/api-reference/scanner/
2230 |
2231 | /**
2232 | * A `Scanner` object is a simple string parser that allows for easy scanning for substrings and characters in a character set, and well as numeric values in several representations.
2233 | *
2234 | * To set a scanner object to ignore a set of characters as it scans the string, use the `skipChars` property. Characters in the skip set are skipped over before the target is scanned. The default set of characters to skip is the whitespace and newline character set.
2235 | *
2236 | * The `Scanner` class is not subclassable.
2237 | * @example
2238 | * let string = "Foobar abc 12.0";
2239 | *
2240 | * let scanner = new Scanner(string);
2241 | *
2242 | * scanner.scanString("Foo"); // => "Foo"
2243 | * scanner.scanString("Foo"); // => null
2244 | * scanner.scanString("bar"); // => "bar"
2245 | *
2246 | * scanner.scanChars(Charset.alphanumeric); // => "abc";
2247 | *
2248 | * scanner.scanFloat(); // => 12.0
2249 | * scanner.scanFloat(); // => null
2250 | *
2251 | * scanner.atEnd; // => true
2252 | */
2253 | declare class Scanner {
2254 | /** Creates a new `Scanner` object with a provided string to scan. */
2255 | constructor(string: string)
2256 |
2257 | /** The string the scanner is parsing. */
2258 | readonly string: string
2259 |
2260 | /** The current character position of the scanner in its string as an integer. */
2261 | location: number
2262 |
2263 | /** Whether the scanner’s location is at the end of its string. */
2264 | readonly atEnd: boolean
2265 |
2266 | /** The set of characters that should be skipped during parsing, as a [Charset](https://docs.nova.app/api-reference/charset). Characters in the skip set are skipped over before the target is scanned. The default set of characters to skip is the whitespace and newline character set. */
2267 | skipChars: Charset
2268 |
2269 | /** Whether the scanner parses using case-sensitive rules. By default this is `false`. */
2270 | caseSensitive: boolean
2271 |
2272 | /** Scans the provided string, returning the string if found and `null` if it was not found. */
2273 | scanString(string: string): string | null
2274 |
2275 | /** Scans the string until a given string is encountered, accumulating characters in a string that is returned. If no characters are scanned (such as if the string to be scanned up to is already at the scan location or the scanner is empty), this method returns `null`. */
2276 | scanUpToString(string: string): string | null
2277 |
2278 | /** Scans for characters in the provided [Charset](https://docs.nova.app/api-reference/charset), accumulating them into a string that is returned. If no characters are scanned, this method returns `null`. */
2279 | scanChars(charset: Charset): string | null
2280 |
2281 | /** Scans the string until a character in the provided [Charset](https://docs.nova.app/api-reference/charset) is encountered, accumulating characters in a string that is returned. If no characters are scanned (such as if a characters to be scanned up to is already at the scan location or the scanner is empty), this method returns `null`. */
2282 | scanUpToChars(charset: Charset): string | null
2283 |
2284 | /** Scans for an integer value in decimal representation, returning it if found, and returning `null` if no value is found. */
2285 | scanInt(): number | null
2286 |
2287 | /** Scans for a floating-point value in decimal representation, returning it if found, and returning `null` if no value is found. */
2288 | scanFloat(): number | null
2289 |
2290 | /** Scans for an integer value in hexadecimal representation, returning it if found, and returning `null` if no value is found. */
2291 | scanHexInt(): number | null
2292 |
2293 | /** Scans for a floating-point value in hexadecimal representation, returning it if found, and returning `null` if no value is found. */
2294 | scanHexFloat(): number | null
2295 | }
2296 |
2297 | /// https://docs.nova.app/api-reference/scope-selector/
2298 |
2299 | /**
2300 | * A `ScopeSelector` object represents a single text selector used for the names of scopes in syntax grammars. These objects can be used to determine whether a specific region of text matches a specific subset of selector classes, such as for use in completions.
2301 | * @since 3.0
2302 | */
2303 | declare class ScopeSelector {
2304 | /**
2305 | * Creates a new scope selector from the provided string. The string must follow the standard format used for [syntax grammar scopes](https://docs.nova.app/syntax-reference/scopes): a set of alphanumeric identifiers that are separated by period (`.`) characters. The universal selector `*` is also allowed. Any other characters (including whitespace) will be ignored and stripped from the string.
2306 | *
2307 | * The special class `*` is reserved to represent the universal selector, which will match any other selector compared to it. If this class is included as a component of any selector it will be assumed to also represent the universal selector.
2308 | */
2309 | constructor(string: string)
2310 |
2311 | /** An array of strings representing the set of period-separated classes that were specified in the string which created the selector. The classes are not guaranteed to be in any particular order, and may not represent the order that was originally specified. */
2312 | readonly classes: ReadonlyArray
2313 |
2314 | /** The string which created the selector. */
2315 | readonly string: string
2316 |
2317 | /**
2318 | * Returns a boolean value as to whether the selector or string provided matches the receiver.
2319 | * @throws The argument must be either another `ScopeSelector` instance or a string that can be resolved as such. Passing any other value will raise an `Error`.
2320 | */
2321 | matches(selectorOrString: ScopeSelector | string): boolean
2322 | }
2323 |
2324 | /// https://docs.nova.app/api-reference/symbol/
2325 |
2326 | type SymbolType =
2327 | // Types
2328 | | "type"
2329 | | "class"
2330 | | "category"
2331 | | "interface"
2332 | | "enum"
2333 | | "union"
2334 | | "struct"
2335 |
2336 | // Callables
2337 | | "function"
2338 | | "method"
2339 | | "closure"
2340 | | "constructor"
2341 | | "destructor"
2342 | | "getter"
2343 | | "setter"
2344 | | "static-method"
2345 |
2346 | // Values
2347 | | "constant"
2348 | | "variable"
2349 | | "property"
2350 | | "argument"
2351 | | "color"
2352 | | "enum-member"
2353 | | "static-property"
2354 |
2355 | // Expressions
2356 | | "expression"
2357 | | "statement"
2358 | | "block"
2359 | | "heading"
2360 | | "comment"
2361 | | "package"
2362 | | "file"
2363 | | "reference"
2364 | | "keyword"
2365 | | "bookmark"
2366 |
2367 | // Stylesets
2368 | | "style-ruleset"
2369 | | "style-directive"
2370 | | "style-id"
2371 | | "style-class"
2372 | | "style-pseudoclass"
2373 | | "style-pseudoelement"
2374 |
2375 | // Tags
2376 | | "tag"
2377 | | "tag-head"
2378 | | "tag-title"
2379 | | "tag-meta"
2380 | | "tag-link"
2381 | | "tag-body"
2382 | | "tag-script"
2383 | | "tag-style"
2384 | | "tag-heading"
2385 | | "tag-section"
2386 | | "tag-container"
2387 | | "tag-ul"
2388 | | "tag-ol"
2389 | | "tag-li"
2390 | | "tag-anchor"
2391 | | "tag-image"
2392 | | "tag-media"
2393 | | "tag-form"
2394 | | "tag-form-field"
2395 | | "tag-framework"
2396 |
2397 | /**
2398 | * A `Symbol` represents a symbolic construct within an editor’s text, such as a function, type, or interface. Extensions can request symbols from a [TextEditor](https://docs.nova.app/api-reference/text-editor) instance at specific positions in the text.
2399 | *
2400 | * The `Symbol` class is not subclassable.
2401 | */
2402 | interface Symbol {
2403 | /** The type of the symbol, as a string. */
2404 | readonly type: SymbolType
2405 |
2406 | /** The range of the symbol within the text, as a [Range](https://docs.nova.app/api-reference/range) object. */
2407 | readonly range: Range
2408 |
2409 | /** The name of the symbol as used in quick open and autocomplete. */
2410 | readonly name: string
2411 |
2412 | /** The range of the symbol’s name within the text, as a [Range](https://docs.nova.app/api-reference/range) object. This does not necessarily match exactly with the `name` property, such as if transformations were made on the name during symbolication. */
2413 | readonly nameRange: Range
2414 |
2415 | /** The name of the symbol as presented in the Symbols list. This may include additional contextual information not included in the text. */
2416 | readonly displayName: string
2417 |
2418 | /** The comment text associated with the symbol, if any. */
2419 | readonly comment: string | null
2420 |
2421 | /** The parent symbol containing the receiver, if any. For example, a method symbol’s parent might be a containing class. */
2422 | readonly parent: Symbol | null
2423 | }
2424 |
2425 | /// https://docs.nova.app/api-reference/task/
2426 |
2427 | declare type TaskName = string & { __type: 'TaskName' }
2428 |
2429 | /**
2430 | * A `Task` object is used to represent a dynamically-defined task that the user can choose and invoke in the IDE’s task running interface. It allows customization of one or more standard actions in the tasks interface represented in the toolbar and menus.
2431 | *
2432 | * The `Task` class is not subclassable.
2433 | * @since 2.0
2434 | */
2435 | declare class Task {
2436 | /** An action name used to denote an action bound to “Build”. */
2437 | static readonly Build: TaskName
2438 |
2439 | /** An action name used to denote an action bound to “Clean”. */
2440 | static readonly Clean: TaskName
2441 |
2442 | /** An action name used to denote an action bound to “Run”. */
2443 | static readonly Run: TaskName
2444 |
2445 | /**
2446 | * Creates a new task object with the provided user-readable name, as a string.
2447 | * @example
2448 | * let task = new Task("Say Example");
2449 | *
2450 | * task.setAction(Task.Build, new TaskProcessAction('/usr/bin/say', {
2451 | * args: ["I'm Building!"],
2452 | * env: {}
2453 | * }));
2454 | *
2455 | * task.setAction(Task.Run, new TaskProcessAction('/usr/bin/say', {
2456 | * args: ["I'm Running!"],
2457 | * env: {}
2458 | * }));
2459 | *
2460 | * task.setAction(Task.Clean, new TaskProcessAction('/usr/bin/say', {
2461 | * args: ["I'm Cleaning!"],
2462 | * env: {}
2463 | * }));
2464 | */
2465 | constructor(name: string)
2466 |
2467 | /** The user-readable name of the task as a string. */
2468 | name: string
2469 |
2470 | /** The name of an image to show for the item (see [Images](https://docs.nova.app/extensions/images) for more information). */
2471 | image: string
2472 |
2473 | /**
2474 | * If set to `true`, then invoking the “Run” action of the task will first invoke the “Build” task. By default, this is `false`.
2475 | * @since 5.0
2476 | */
2477 | buildBeforeRunning: boolean
2478 |
2479 | /** Returns the action that is defined for the provided name, or `undefined` if no action is set. */
2480 | getAction(name: string): TaskProcessAction | undefined
2481 | /** Returns the action that is defined for the provided name, or `undefined` if no action is set. */
2482 | getAction(name: string): TaskResolvableAction | undefined
2483 |
2484 | /** Sets an action for a provided name. If `action` is `null` or `undefined` the action will be removed from the task. */
2485 | setAction(name: string, action?: TaskProcessAction | null): void
2486 | /** Sets an action for a provided name. If `action` is `null` or `undefined` the action will be removed from the task. */
2487 | setAction(name: string, action?: TaskResolvableAction | null): void
2488 | }
2489 |
2490 | /// https://docs.nova.app/api-reference/task-action-resolve-context/
2491 |
2492 | /**
2493 | * A `TaskActionResolveContext` object contains contextual information about a [TaskResolvableAction](https://docs.nova.app/api-reference/task-resolvable-action) instance being resolved in response to the user invoking it. An object of this type will be provided to a task provider’s `resolveTaskAction()` method.
2494 | *
2495 | * The `TaskActionResolveContext` class is not subclassable.
2496 | * @since 4.0
2497 | */
2498 | interface TaskActionResolveContext {
2499 | /** The action type name of the action being invoked, such as `Task.Build`, `Task.Run`, or `Task.Clean`. This value can be compared to see what type of action to resolve. */
2500 | readonly action: TaskName
2501 |
2502 | /**
2503 | * If the action being resolved is from a Task Template (defined in an extension’s manifest `taskTemplates` key), the property will be a [Configuration](https://docs.nova.app/api-reference/configuration) object that contains configuration values as set in the Project Settings for the task.
2504 | *
2505 | * If the action being resolved is not from a task template (such as one provided by a task assistant) this property will be `undefined`.
2506 | *
2507 | * The configuration object provided for this property is transient. It will not continue to be referenced by the runtime after this resolution of the action is complete. As such, attempting to set values or observe changes on it won’t be particularly useful.
2508 | * @since 5.0
2509 | */
2510 | readonly config?: Configuration
2511 |
2512 | /**
2513 | * The arbitrary data argument that was provided for the resolvable action which is being resolved.
2514 | *
2515 | * This object can be of any type that is *transferrable*, or encodable in the same way as arguments to the [CommandsRegistry](https://docs.nova.app/api-reference/commands-registry). If not set when the action was defined, this property will be `undefined`.
2516 | */
2517 | readonly data?: T
2518 | }
2519 |
2520 | /// https://docs.nova.app/api-reference/task-command-action/
2521 |
2522 | /**
2523 | * A `TaskCommandAction` object represents an action that can be used as part of a [Task](https://docs.nova.app/api-reference/task) that invokes an extension command registered with the [CommandsRegistry](https://docs.nova.app/api-reference/commands-registry), much in the same way as if the user had chosen a menu item bound to it.
2524 | *
2525 | * The `TaskCommandAction` class is not subclassable.
2526 | * @since 3.0
2527 | */
2528 | declare class TaskCommandAction {
2529 | /** Creates a `TaskCommandAction` object that will invoke the extension command named `command`. */
2530 | constructor(command: string, options?: {
2531 | /** Arguments to pass to the command. */
2532 | args?: string[]
2533 | })
2534 |
2535 | /**
2536 | * The arguments passed to the command.
2537 | *
2538 | * See documentation for the [CommandsRegistry](https://docs.nova.app/api-reference/commands-registry) for more information about how commands are invoked and how their arguments are handled.
2539 | */
2540 | readonly args: ReadonlyArray
2541 |
2542 | /** The name used to register the command. */
2543 | readonly command: string
2544 | }
2545 |
2546 | /// https://docs.nova.app/api-reference/task-debug-adapter-action/
2547 |
2548 | /**
2549 | * A `TaskDebugAdapterAction` object represents an action that can be used as part of a [Task](https://docs.nova.app/api-reference/task) which invokes a [debug adapter](https://docs.nova.app/extensions/debug-adapters) conforming to the [Debug Adapter Protocol](https://microsoft.github.io/debug-adapter-protocol/).
2550 | *
2551 | * The `TaskDebugAdapterAction` class is not subclassable.
2552 | * @since 9.0
2553 | */
2554 | declare class TaskDebugAdapterAction {
2555 | /**
2556 | * Creates a `TaskDebugAdapterAction` object that interfaces with a debug adapter.
2557 | *
2558 | * The `adapterType` is a string denoting the adapter’s identifier. This identifier should be unique across the workspace, and is generally recommended to be the identifier of the debugger or adapter itself, such as `debugpy`, `chrome-devtools`, etc. This parameter is used to link the instance with its [adapter description](https://docs.nova.app/extensions/debug-adapters/#manifest-description) in the extension manifest.
2559 | * @example
2560 | * class PythonTaskAssistant {
2561 | * resolveTaskAction(context) {
2562 | * let config = context.config;
2563 | *
2564 | * let action = new TaskDebugAdapterAction('debugpy');
2565 | *
2566 | * action.command = "/usr/bin/python3";
2567 | * action.args = ["-m", "debugpy"];
2568 | *
2569 | * action.debugArgs = {
2570 | * program: config.get("python.debug.script", "string")
2571 | * };
2572 | *
2573 | * task.setActionAction(Task.Run, action);
2574 | * }
2575 | * }
2576 | */
2577 | constructor(adapterType: string)
2578 |
2579 | /**
2580 | * Determines how the adapter is started by Nova. Valid values are:
2581 | * - `launch`: The adapter is launched directly by Nova. This is the default if a value is not specified.
2582 | * - `attach`: Nova attempts to attach to an already-running instance of the adapter. A `transport` other than `stdio` must be specified for attaching.
2583 | */
2584 | adapterStart?: "launch" | "attach"
2585 |
2586 | /**
2587 | * The arguments passed to the debug adapter process.
2588 | *
2589 | * **Note:** these are the arguments passed when launching the `adapter`, not the debuggee. Passing arguments to the debuggee requires support from the adapter via a key in the [debugArgs](https://docs.nova.app/api-reference/task-debug-adapter-action/#debugargs) property. This property is ignored if the adapter is not launched by Nova.
2590 | */
2591 | args?: string[]
2592 |
2593 | /** The command used to launch the debug adapter. This property is ignored if the adapter is not launched by Nova. */
2594 | command?: string
2595 |
2596 | /** The current working directory for the debug adapter. If not specified, the project directory will be used. This property is ignored if the adapter is not launched by Nova. */
2597 | cwd?: string
2598 |
2599 | /**
2600 | * Arguments passed to the debug adapter for use in setting up its options and starting the debuggee. This corresponds to the `arguments` argument of the [Launch](https://microsoft.github.io/debug-adapter-protocol/specification#Requests_Launch) or [Attach](https://microsoft.github.io/debug-adapter-protocol/specification#Requests_Attach) request of the Debug Adapter Protocol.
2601 | *
2602 | * This object is freeform and the contents of it is not defined by Nova’s extension API (beyond it being an object). Check the documentation for the specific adapter for more information.
2603 | */
2604 | debugArgs?: object
2605 |
2606 | /**
2607 | * The method by which the adapter should attempt to start debugging the debuggee. Valid values are:
2608 | * - `launch`: The adapter will attempt to launch the debuggee by sending a [Launch](https://microsoft.github.io/debug-adapter-protocol/specification#Requests_Launch) request.
2609 | * - `attach`: The adapter will attempt to connect to the debuggee by sending an [Attach](https://microsoft.github.io/debug-adapter-protocol/specification#Requests_Attach) request.
2610 | *
2611 | * Not all adapters support both types of debug request. Check the documentation for the specific adapter for more information.
2612 | */
2613 | debugRequest?: "launch" | "attach"
2614 |
2615 | /** The environment variables (as an Object) set for the debug adapter. This property is ignored if the adapter is not launched by Nova. */
2616 | env?: { [key: string]: string }
2617 |
2618 | /** The host on which to attempt to connect to a Socket to communicate with the adapter. This property is only referenced when the transport is set to `socket`. By default, if no value is specified, this defaults to `localhost`. */
2619 | socketHost?: string
2620 |
2621 | /** The path at which to connect to a Unix Domain Socket to communicate with the adapter. This property is only referenced when the `transport` is set to `domainSocket`. This property is required if using Unix Domain Socket communication. */
2622 | socketPath?: string
2623 |
2624 | /** The port on which to attempt to connect to a Socket to communicate with the adapter. This property is only referenced when the `transport` is set to `socket`. This property is required if using Socket communication. */
2625 | socketPort?: number
2626 |
2627 | /**
2628 | * The transport mechanism to use to communicate with the adapter. Valid values are:
2629 | * - `stdio`: Communicate using Standard I/O. Only valid when the adapter is launched by Nova.
2630 | * - `socket`: Communicate using a TCP Socket. A `socketPort` *must* be specified and a `socketHost` is optional.
2631 | * - `domainSocket`: Communicate using a Unix Domain Socket. A `socketPath` must be specified.
2632 | */
2633 | transport?: "stdio" | "socket" | "domainSocket"
2634 | }
2635 |
2636 | /// https://docs.nova.app/api-reference/task-process-action/
2637 |
2638 | /**
2639 | * A `TaskProcessAction` object represents an action that can be used as part of a Task which invokes a Unix subprocess, much in the same way as the [Process](https://docs.nova.app/api-reference/process) class.
2640 | *
2641 | * The `TaskProcessAction` class is not subclassable.
2642 | * @since 2.0
2643 | */
2644 | declare class TaskProcessAction {
2645 | /**
2646 | * Creates a `TaskProcessAction` object that will launch the executable represented by `command`.
2647 | * @example
2648 | * let action = new TaskProcessAction('/usr/bin/say', {
2649 | * args: ["I'm Running!"],
2650 | * env: {}
2651 | * });
2652 | *
2653 | * task.setActionAction(Task.Run, action);
2654 | */
2655 | constructor(command: string, options?: {
2656 | /** Additional arguments to pass. */
2657 | args?: string[]
2658 |
2659 | /** Additional environment variables to set. */
2660 | env?: { [key: string]: string }
2661 |
2662 | /** The current working directory path to set for the process. */
2663 | cwd?: string
2664 |
2665 | /** Run the subprocess within a shell. */
2666 | shell?: boolean
2667 |
2668 | /** An array of [Issue Matcher](https://docs.nova.app/extensions/issue-matchers/) names used to process output from the action. */
2669 | matchers?: string[]
2670 | })
2671 |
2672 | /** The arguments passed to the process, including any specified when the Process was constructed. */
2673 | readonly args: ReadonlyArray
2674 |
2675 | /** The command used to launch the process. */
2676 | readonly command: string
2677 |
2678 | /** The current working directory for the process. If not specified, the project directory will be used. */
2679 | readonly cwd: string
2680 |
2681 | /** The environment variables set for the process, including any specified when the Process was constructed. */
2682 | readonly env: { [key: string]: string }
2683 |
2684 | /** An array of [Issue Matcher](https://docs.nova.app/extensions/issue-matchers) names that will be used when processing output from the action. If not specified, the standard set of matchers will be used. */
2685 | readonly matchers: ReadonlyArray
2686 | }
2687 |
2688 | /// https://docs.nova.app/api-reference/task-resolvable-action/
2689 |
2690 | /**
2691 | * A `TaskResolvableAction` object represents an action that can be used as part of a [Task](https://docs.nova.app/api-reference/task) whose execution details are not known when the action is created. When the user invokes a task’s resolvable action, the action’s task provider will be queried to resolve the action into a more concrete type (such as a [TaskProcessAction](https://docs.nova.app/api-reference/task-process-action).
2692 | *
2693 | * The `TaskResolvableAction` class is not subclassable.
2694 | * @since 4.0
2695 | */
2696 | declare class TaskResolvableAction {
2697 | /** Creates a `TaskResolvableAction` object. */
2698 | constructor(options?: {
2699 | /** An arbitrary transferrable (encodable) type that will be provided when the action is resolved */
2700 | data?: T
2701 | })
2702 |
2703 | /**
2704 | * The arbitrary data argument that will be passed to the action’s task provider when it is resolved.
2705 | *
2706 | * This object can be of any type that is *transferrable*, or encodable in the same way as arguments to the [CommandsRegistry](https://docs.nova.app/api-reference/commands-registry).
2707 | *
2708 | * This value will be provided to the task assistant’s `resolveTaskAction()` method through the `context` parameter of type [TaskActionResolveContext](https://docs.nova.app/api-reference/task-action-resolve-context).
2709 | */
2710 | readonly data: T
2711 | }
2712 |
2713 | /// https://docs.nova.app/api-reference/text-document/
2714 |
2715 | /** A `TextDocument` represents an open text document in the application. Text document objects are not directly mutable, requiring a [TextEditor](https://docs.nova.app/api-reference/text-editor) object to make modifications. Text documents are not one-to-one to text editors, since multiple editors may be open for a single document. */
2716 | interface TextDocument {
2717 | /** Returns the document’s unique URI, as a `String`. The URI is guaranteed to exist for all documents, but may change if the document is moved. Unsaved documents have a URI with an `unsaved://` scheme. */
2718 | readonly uri: string
2719 |
2720 | /** Returns the document’s path, as a `String`. If the document is remote, this will be the path on the relevant server. If the document is unsaved, this may be `null` or `undefined`. */
2721 | readonly path?: string | null
2722 |
2723 | /** Returns `true` if the document is a remote document. */
2724 | readonly isRemote: boolean
2725 |
2726 | /** Returns `true` if the document has modifications that are not yet saved to disk. */
2727 | readonly isDirty: boolean
2728 |
2729 | /** Returns `true` if the document contains no text. */
2730 | readonly isEmpty: boolean
2731 |
2732 | /** Returns `true` if the document has not yet been saved to disk, and does not have a path. */
2733 | readonly isUntitled: boolean
2734 |
2735 | /** Returns `true` if the document has been closed. Closed documents are no longer interact-able. */
2736 | readonly isClosed: boolean
2737 |
2738 | /** Returns, as a `String`, the default line ending string used by the document. */
2739 | readonly eol: string
2740 |
2741 | /** Returns the length of the document in characters. */
2742 | readonly length: number
2743 |
2744 | /** Returns the identifier for the document’s language syntax. If the document is plain text, this may be `null` or `undefined`. */
2745 | readonly syntax?: string | null
2746 |
2747 | /**
2748 | * Returns a section of the document’s text indicated by a provided [Range](https://docs.nova.app/api-reference/range) as a `String`.
2749 | * @throws If the range exceeds the receiver’s bounds, an `Error` will be thrown.
2750 | */
2751 | getTextInRange(range: Range): string
2752 |
2753 | /**
2754 | * Given a [Range](https://docs.nova.app/api-reference/range), this method will return the range of all lines encompassing that range.
2755 | * @throws If the range exceeds the receiver’s bounds, an `Error` will be thrown.
2756 | */
2757 | getLineRangeForRange(range: Range): Range
2758 |
2759 | /** Adds an event listener that invokes the provided `callback` when the document’s path changes. The callback will receive as an argument the document object and the new path (or `null` if the document does not have a path). */
2760 | onDidChangePath(callback: (document: TextDocument, path: string | null) => void): Disposable
2761 |
2762 | /** Adds an event listener that invokes the provided `callback` when the document’s syntax (language) changes. The callback will receive as an argument the document object and the new syntax name (or `null` if the document does not have a syntax / is plain text). */
2763 | onDidChangeSyntax(callback: (document: TextDocument, syntax: string | null) => void): Disposable
2764 | }
2765 |
2766 | /// https://docs.nova.app/api-reference/text-edit/
2767 |
2768 | /**
2769 | * A `TextEdit` describes a single change that may be applied to a [TextEditor](https://docs.nova.app/api-reference/text-editor). An array of `TextEdit` objects represent a set of changes that may be applied together atomically. `TextEdit` objects are most often used with APIs such as [CompletionItem](https://docs.nova.app/api-reference/completion-item) to describe set of edits to apply.
2770 | * @since 2.0
2771 | */
2772 | declare class TextEdit {
2773 | /** Returns a new text edit that deletes text in the [Range](https://docs.nova.app/api-reference/range) `range`. */
2774 | static delete(range: Range): TextEdit
2775 |
2776 | /** Returns a new text edit that inserts text at position. */
2777 | static insert(position: number, newText: string): TextEdit
2778 |
2779 | /** Returns a new text edit that replaces the [Range](https://docs.nova.app/api-reference/range) `range` with `newText`. */
2780 | static replace(range: Range, newText: string): TextEdit
2781 |
2782 | /** Creates a new text edit that replaces the [Range](https://docs.nova.app/api-reference/range) `range` with `newText`. */
2783 | constructor(range: Range, newText: string)
2784 |
2785 | /** A `String` that will be inserted when the text edit is applied. */
2786 | readonly newText: string
2787 |
2788 | /** The [Range](https://docs.nova.app/api-reference/range) that will be replaced when the edit is applied. */
2789 | readonly range: Range
2790 | }
2791 |
2792 | /// https://docs.nova.app/api-reference/text-editor/
2793 |
2794 | /** A `TextEditor` represents an open text editor in the application. An editor has a reference to its backing [TextDocument](https://docs.nova.app/api-reference/text-document) object. Text editors are not one-to-one to text documents, since multiple editors may be open for a single document. */
2795 | interface TextEditor {
2796 | /** Returns `true` if the object provided is a `TextEditor` instance, otherwise returning `false`. This can be most useful for a [Commands](https://docs.nova.app/extensions/commands) handler function, which can receive either a [Workspace](https://docs.nova.app/api-reference/workspace) or `TextEditor` instance as its first argument. */
2797 | static isTextEditor(object: any): boolean
2798 |
2799 | /** The [TextDocument](https://docs.nova.app/api-reference/text-document) object backing the editor. */
2800 | readonly document: TextDocument
2801 |
2802 | /** The currently selected range, as a [Range](https://docs.nova.app/api-reference/range). If the receiver has multiple selected ranges, this will return the primary range (generally the first range). */
2803 | selectedRange: Range
2804 |
2805 | /** An array of all currently selected ranges, as [Range](https://docs.nova.app/api-reference/range) objects. The ranges are guaranteed to be in ascending order, and have no intersections. */
2806 | selectedRanges: Range[]
2807 |
2808 | /** The currently selected text, as a `String`. If the receiver has multiple selected ranges, this will return the text for the primary range (as returned by `selectedRange`). */
2809 | readonly selectedText: string
2810 |
2811 | /** Whether the editor is set to use soft tabs (spaces). */
2812 | softTabs: boolean
2813 |
2814 | /** The number of spaces used as a single tab length. */
2815 | tabLength: number
2816 |
2817 | /** A `String` representation of a single tab in the editor’s preferred indentation style and tab width. */
2818 | readonly tabText: string
2819 |
2820 | /**
2821 | * Begins an atomic edit session for the editor.
2822 | *
2823 | * The first argument must be a callable that will be invoked immediately to collect changes. The caller is responsible for doing all work in the callback it intends to represent a “single” operation on the undo stack.
2824 | *
2825 | * The callback will receive as an argument a [TextEditorEdit](https://docs.nova.app/api-reference/text-editor-edit) object that can be used to queue changes for the edit operation.
2826 | *
2827 | * This method returns a `Promise` object that resolves when the edit operation is either accepted or rejected by the editor. The editor may reject an edit operation if, for example, the extension has taken too long to queue changes such that editor responsiveness may be impacted.
2828 | * @throws It is a programming error to invoke this method from within a text change callback (such as one registered using `onDidChange()`). Attempting to do so will throw an `Error`.
2829 | */
2830 | edit(callback: (edit: TextEditorEdit) => void, options?: unknown): Promise
2831 | // TODO: Options not documented
2832 |
2833 | /**
2834 | * Shorthand for inserting text quickly at the editor’s current insertion point(s). If there is any selection, it will be replaced by the provided text. Multiple calls to `insert()` within the same function will not be coalesced into one undo operation. To coalesce changes into a single undo operation, use the `edit()` API.
2835 | *
2836 | * This method returns a `Promise` object that resolves when the insert operation is either accepted or rejected by the editor. The editor may reject an insert operation if, for example, the extension has taken too long to queue changes such that editor responsiveness may be impacted.
2837 | *
2838 | * **The format argument was added in Nova 1.2.**
2839 | * @throws It is a programming error to invoke this method from within a text change callback (such as one registered using `onDidChange()`). Attempting to do so will throw an `Error`.
2840 | */
2841 | insert(string: string, format?: InsertTextFormat): Promise
2842 |
2843 | /**
2844 | * Requests that the editor be saved. For unsaved documents, this will present a modal save panel to the user requesting that a path be chosen.
2845 | *
2846 | * This method returns a `Promise` object that resolves when the save operation is finished, or rejects if the save operation failed.
2847 | */
2848 | save(): Promise
2849 |
2850 | /**
2851 | * Returns a section of the document’s text indicated by a provided [Range](https://docs.nova.app/api-reference/range) as a `String`.
2852 | *
2853 | * This is a convenience method that is effectively the same as invoking `getTextInRange(range)` on the editor’s document.
2854 | * @throws If the range exceeds the receiver’s bounds, an `Error` will be thrown.
2855 | */
2856 | getTextInRange(range: Range): string
2857 |
2858 | /**
2859 | * Given a [Range](https://docs.nova.app/api-reference/range), this method will return the range of all lines encompassing that range.
2860 | *
2861 | * This is a convenience method that is effectively the same as invoking `getLineRangeForRange(range)` on the editor’s document.
2862 | * @throws If the range exceeds the receiver’s bounds, an `Error` will be thrown.
2863 | */
2864 | getLineRangeForRange(range: Range): Range
2865 |
2866 | /**
2867 | * Adds an event listener that invokes the provided `callback` when the editor’s text changes. The callback will receive as an argument the `TextEditor` object.
2868 | *
2869 | * **Note:** This callback is potentially invoked very often as text changes. If you would like to perform actions in response to a user pausing after typing, consider the `onDidStopChanging()` event handler instead.
2870 | *
2871 | * The optional `thisValue` argument may be used to set what `this` is bound to when the callable is invoked. If omitted, `this` will be `undefined`.
2872 | */
2873 | onDidChange(callback: (this: T, editor: TextEditor) => void, thisValue?: T): Disposable
2874 |
2875 | /**
2876 | * Adds an event listener that invokes the provided `callback` a short time after the editor stops changing. Multiple changes to text in a short time will be coalesced into one event that can be acted upon performantly. The callback will receive as an argument the `TextEditor` object.
2877 | *
2878 | * The optional `thisValue` argument may be used to set what `this` is bound to when the callable is invoked. If omitted, `this` will be `undefined`.
2879 | */
2880 | onDidStopChanging(callback: (this: T, editor: TextEditor) => void, thisValue?: T): Disposable
2881 |
2882 | /**
2883 | * Adds an event listener that invokes the provided `callback` just before the editor is saved. The callback will receive as an argument the `TextEditor` object. If the callback performs modifications to the editor within the callback (such as with `edit()`), they will be applied in such a way as to include them in the pending save operation.
2884 | *
2885 | * This method may return a `Promise` object to denote to the runtime that changes need to be performed asynchronously. The IDE will wait for the promise to resolve or reject as part of its wait time.
2886 | *
2887 | * If a callback registered using this method (or a promise returned from it) takes too long to perform operations, any edits enqueued may be deferred until after the save operation, or discarded entirely. In the case they are discarded, an error will be reported from the `Promise` object returned from `edit()`. The exact amount of time may vary, but the runtime guarantees that it will allow at least 5 seconds for all extensions to perform their operations.
2888 | *
2889 | * The optional `thisValue` argument may be used to set what `this` is bound to when the callable is invoked. If omitted, `this` will be `undefined`.
2890 | */
2891 | onWillSave(callback: (this: T, editor: TextEditor) => void | Promise, thisValue?: T): Disposable
2892 |
2893 | /**
2894 | * Adds an event listener that invokes the provided `callback` when the editor is saved. The callback will receive as an argument the `TextEditor` object.
2895 | *
2896 | * The optional `thisValue` argument may be used to set what `this` is bound to when the callable is invoked. If omitted, `this` will be `undefined`.
2897 | */
2898 | onDidSave(callback: (this: T, editor: TextEditor) => void, thisValue?: T): Disposable
2899 |
2900 | /**
2901 | * Adds an event listener that invokes the provided `callback` when the editor’s selected ranges change. The callback will receive as an argument the `TextEditor` object.
2902 | *
2903 | * The optional `thisValue` argument may be used to set what `this` is bound to when the callable is invoked. If omitted, `this` will be `undefined`.
2904 | */
2905 | onDidChangeSelection(callback: (this: T, editor: TextEditor) => void, thisValue?: T): Disposable
2906 |
2907 | /**
2908 | * Adds an event listener that invokes the provided `callback` when the editor is being closed. The callback will receive as an argument the `TextEditor` object.
2909 | *
2910 | * The optional `thisValue` argument may be used to set what `this` is bound to when the callable is invoked. If omitted, `this` will be `undefined`.
2911 | */
2912 | onDidDestroy(callback: (this: T, editor: TextEditor) => void, thisValue?: T): Disposable
2913 |
2914 | /**
2915 | * Moves the editor’s selected ranges upward a specific number of rows. If no row count parameter is provided, the selection will be moved one row.
2916 | * @since 5.0
2917 | */
2918 | moveUp(rowCount?: number): void
2919 |
2920 | /**
2921 | * Moves the editor’s selected ranges downward a specific number of rows. If no row count parameter is provided, the selection will be moved one row.
2922 | * @since 5.0
2923 | */
2924 | moveDown(rowCount?: number): void
2925 |
2926 | /**
2927 | * Moves the editor’s selected ranges leftward a specific number of columns. If no column count parameter is provided, the selection will be moved one column.
2928 | * @since 5.0
2929 | */
2930 | moveLeft(columnCount?: number): void
2931 |
2932 | /**
2933 | * Moves the editor’s selected ranges rightward a specific number of columns. If no column count parameter is provided, the selection will be moved one column.
2934 | * @since 5.0
2935 | */
2936 | moveRight(columnCount?: number): void
2937 |
2938 | /**
2939 | * Moves the editor’s selected range to the top of the document, before the first character.
2940 | * @since 5.0
2941 | */
2942 | moveToTop(): void
2943 |
2944 | /**
2945 | * Moves the editor’s selected range to the end of the document, after the last character.
2946 | * @since 5.0
2947 | */
2948 | moveToBottom(): void
2949 |
2950 | /**
2951 | * Moves the editor’s selected ranges to the beginning of each line containing them.
2952 | * @since 5.0
2953 | */
2954 | moveToBeginningOfLine(): void
2955 |
2956 | /**
2957 | * Moves the editor’s selected ranges to the end of each line containing them.
2958 | * @since 5.0
2959 | */
2960 | moveToEndOfLine(): void
2961 |
2962 | /**
2963 | * Moves the editor’s selected ranges to the beginning of the word containing or against the start of each range.
2964 | * @since 5.0
2965 | */
2966 | moveToBeginningOfWord(): void
2967 |
2968 | /**
2969 | * Moves the editor’s selected ranges to the beginning of the word containing or against the end of each range.
2970 | * @since 5.0
2971 | */
2972 | moveToEndOfWord(): void
2973 |
2974 | /** Adds the provided [Range](https://docs.nova.app/api-reference/range) to the editor’s selected ranges, automatically coalescing any overlapping ranges. If the provided range is zero-length, the range will be added as a cursor. */
2975 | addSelectionForRange(range: Range): void
2976 |
2977 | /** Extends the editor’s primary selected range to the provided character position. */
2978 | selectToPosition(position: number): void
2979 |
2980 | /** Extends the editor’s primary selected range upward a specific number of lines. If no row count parameter is provided, the selection will be extended one row. */
2981 | selectUp(rowCount?: number): void
2982 |
2983 | /** Extends the editor’s primary selected range downward a specific number of lines. If no row count parameter is provided, the selection will be extended one row. */
2984 | selectDown(rowCount?: number): void
2985 |
2986 | /** Extends the editor’s primary selected range leftward a specific number of characters. If no column count parameter is provided, the selection will be extended one column. */
2987 | selectLeft(columnCount?: number): void
2988 |
2989 | /** Extends the editor’s primary selected range rightward a specific number of characters. If no column count parameter is provided, the selection will be extended one column. */
2990 | selectRight(columnCount?: number): void
2991 |
2992 | /** Extends the editor’s primary selected range to the beginning of the text. */
2993 | selectToTop(): void
2994 |
2995 | /** Extends the editor’s primary selected range to the end of the text. */
2996 | selectToBottom(): void
2997 |
2998 | /** Selects all text in the editor. */
2999 | selectAll(): void
3000 |
3001 | /** Extends all selected ranges and cursors to encompass all lines in which they intersect. */
3002 | selectLinesContainingCursors(): void
3003 |
3004 | /** Extends all selected ranges and cursors backward to the beginning of their first (or only) line. */
3005 | selectToBeginningOfLine(): void
3006 |
3007 | /** Extends all selected ranges and cursors forward to the end of their last (or only) line. */
3008 | selectToEndOfLine(): void
3009 |
3010 | /** Extends all selected ranges and cursors to encompass all words in which they intersect. */
3011 | selectWordsContainingCursors(): void
3012 |
3013 | /** Extends all selected ranges and cursors backward to the beginning of their first (or only) word. */
3014 | selectToBeginningOfWord(): void
3015 |
3016 | /** Extends all selected ranges and cursors forward to the end of their last (or only) word. */
3017 | selectToEndOfWord(): void
3018 |
3019 | /** Scrolls the editor to ensure that the primary selected range is visible. */
3020 | scrollToCursorPosition(): void
3021 |
3022 | /** Scrolls the editor to ensure that the provided character position is visible. */
3023 | scrollToPosition(position: number): void
3024 |
3025 | /**
3026 | * Begins a shadow typing session for the editor with a set of ranges. The ranges provided will be added as selected text ranges (or cursors, if zero-length) in the editor in a similar way to adding them to the `selectedRanges` property. However, the ranges will only remain valid while typing text in the current undo coalescing state. If the selection or undo state changes by any other means (such as by moving the cursors manually or saving the document), the ranges will be removed and the shadow typing session will end.
3027 | *
3028 | * The optional `charset` argument may be provided with a [Charset](https://docs.nova.app/api-reference/charset) object. As the user types, the characters will be compared with this character set. If a character does not match, the shadow typing session will end automatically.
3029 | */
3030 | startShadowTyping(ranges: Range[], charset?: Charset): void
3031 |
3032 | /** Explicitly ends the current shadow typing session, if any. It’s generally not required to invoke this manually except in very specific circumstances that the shadow typing session’s attribute (such as its charset) cannot handle. */
3033 | endShadowTyping(): void
3034 |
3035 | /** Gets the deepest displayable symbol containing the provided text position, as a [Symbol](https://docs.nova.app/api-reference/symbol) object. If no symbol could be found, this method returns `null`. */
3036 | symbolAtPosition(position: number): Symbol | null
3037 |
3038 | /** Gets the deepest displayable symbol for the start position of each of the selected ranges of the editor, as an array of [Symbol](https://docs.nova.app/api-reference/symbol) objects. If no symbol could be found at a specific position, the array will contain a `null` entry for that range. */
3039 | symbolsForSelectedRanges()
3040 | }
3041 |
3042 | /// https://docs.nova.app/api-reference/text-editor-edit/
3043 |
3044 | /** Enumeration defining in what format the text provided should be parsed. */
3045 | declare enum InsertTextFormat {
3046 | /** The text is plain text and will not be modified (the default value). */
3047 | PlainText,
3048 |
3049 | /** The text uses the [Snippets](https://docs.nova.app/extensions/snippets/) format and will be parsed for editor placeholders. */
3050 | Snippet
3051 | }
3052 |
3053 | /**
3054 | * A `TextEditorEdit` object is used to queue changes within a call to a [TextEditor](https://docs.nova.app/api-reference/text-editor)’s `edit()` method. Multiple calls to an edit’s methods will be performed atomically to the editor as one operation on the undo stack.
3055 | *
3056 | * Changes are incurred in the order in which they are invoked on the `TextEditorEdit` object. As such, ranges provided to successive calls must ensure they take into account changes in character positions and ranges due to previous edits in the operation.
3057 | */
3058 | interface TextEditorEdit {
3059 | /** Deletes text in the the provided [Range](https://docs.nova.app/api-reference/range). */
3060 | delete(range: Range): void
3061 |
3062 | /**
3063 | * Replaces text in the the provided [Range](https://docs.nova.app/api-reference/range) with a new text string. This method differs from `insert()` in that it will not move the cursor.
3064 | *
3065 | * The third argument provided, format, is an `InsertTextFormat` enumeration value defining in what format the text provided should be parsed. **This argument was added in Nova 5.**
3066 | * Supported values are:
3067 | * - InsertTextFormat.PlainText: The text is plain text and will not be modified (the default value).
3068 | * - InsertTextFormat.Snippet: The text uses the Snippets format and will be parsed for editor placeholders.
3069 | */
3070 | replace(range: Range, text: string, format?: InsertTextFormat): void
3071 |
3072 | /**
3073 | * Inserts text at the provided character position (`Number`). This method differs from `replace()` in that it will automatically move the cursor.
3074 | *
3075 | * The third argument provided, `format`, is an `InsertTextFormat` enumeration value defining in what format the text provided should be parsed. **This argument was added in Nova 5.**
3076 | * Supported values are:
3077 | * - InsertTextFormat.PlainText: The text is plain text and will not be modified (the default value).
3078 | * - InsertTextFormat.Snippet: The text uses the Snippets format and will be parsed for editor placeholders.
3079 | */
3080 | insert(position: number, text: string, format?: InsertTextFormat): void
3081 | }
3082 |
3083 | /// https://docs.nova.app/api-reference/tree-data-provider/
3084 |
3085 | /**
3086 | * A `TreeDataProvider` interface should be implemented by objects that provide data to a [TreeView](https://docs.nova.app/api-reference/tree-view).
3087 | *
3088 | * The elements provided as data objects by a `TreeDataProvider` may be any valid JavaScript object.
3089 | * @example
3090 | * interface TreeDataProvider {
3091 | * getChildren(element);
3092 | * getParent(element);
3093 | * getTreeItem(element);
3094 | * }
3095 | */
3096 | interface TreeDataProvider {
3097 | /** Returns an array of children for an element (or a `Promise` that resolves to it). The `element` will be `null` for the root of the tree. */
3098 | getChildren(element: E | null): E[] | Promise
3099 |
3100 | /** Returns the parent of an element. This is an optional method used for the `TreeView` `reveal()` API. */
3101 | getParent(element: E): E | null
3102 |
3103 | /** Returns the [TreeItem](https://docs.nova.app/api-reference/tree-item) representation of an element. */
3104 | getTreeItem(element: E): TreeItem
3105 | }
3106 |
3107 | /// https://docs.nova.app/api-reference/tree-item/
3108 |
3109 | declare enum TreeItemCollapsibleState {
3110 | /** The item cannot be expanded (it is a leaf item). */
3111 | None,
3112 |
3113 | /** The item can be expanded, but is collapsed by default. */
3114 | Collapsed,
3115 |
3116 | /** The item can be expanded, and is expanded by default. */
3117 | Expanded
3118 | }
3119 |
3120 | /**
3121 | * A `TreeItem` object is the visual representation of an element represented within the dataset of a [TreeView](https://docs.nova.app/api-reference/tree-view). Tree items define attributes such as the element’s label, description, and icon.
3122 | *
3123 | * The `TreeItem` class is not subclassable.
3124 | * @example
3125 | * let item = new TreeItem("image.png", TreeItemCollapsibleState.None);
3126 | *
3127 | * item.descriptiveText = "PNG file";
3128 | * item.path = "path/to/image.png";
3129 | */
3130 | declare class TreeItem {
3131 | /** Creates a new `TreeItem` object. The collapsibleState argument defaults to `TreeItemCollapsibleState.None`. */
3132 | constructor(name: string, collapsibleState?: TreeItemCollapsibleState)
3133 |
3134 | /** The display name of the item, as a `string`. */
3135 | name: string
3136 |
3137 | /** Defines how an item is displayed with regards to being expanded. The default value is `TreeItemCollapsibleState.None`, which indicates the item cannot be expanded. */
3138 | collapsibleState: TreeItemCollapsibleState
3139 |
3140 | /** An optional [Command](https://docs.nova.app/extensions/commands) to invoke when the item is double-clicked. */
3141 | command?: string
3142 |
3143 | /**
3144 | * When set to a [Color](https://docs.nova.app/api-reference/color) object, the color will be rendered as a swatch in the item’s row in place of its image.
3145 | *
3146 | * If both `image` and `color` are set on a tree item, the image will take priority.
3147 | */
3148 | color?: Color
3149 |
3150 | /** A value used when validating the `when` clause of commands for the tree view. This value may be used for when clauses of the form `viewItem == ''`. */
3151 | contextValue?: string
3152 |
3153 | /** A short description of the item, as a `string`. This will be displayed alongside the item’s label, if space allows. */
3154 | descriptiveText?: string
3155 |
3156 | /** An optional unique identifier for the item, as a `string`. This identifier must be unique across the entire tree. This will be used to preserve selection and expansion state. */
3157 | identifier?: string
3158 |
3159 | /**
3160 | * The name of an image to show for the item (see [Images](https://docs.nova.app/extensions/images) for more information).
3161 | *
3162 | * If both `image` and `color` are set on a tree item, the image will take priority.
3163 | */
3164 | image?: string
3165 |
3166 | /** The file-system path to the item as a `string`, if appropriate. If this is specified, and `image` is not defined, the image will by default use the appropriate file-type image for this path. */
3167 | path?: string
3168 |
3169 | /** A tooltip to display when hovering over the item, as a `string`. */
3170 | tooltip?: string
3171 | }
3172 |
3173 | /// https://docs.nova.app/api-reference/tree-view/
3174 |
3175 | /**
3176 | * A `TreeView` object acts as the interface to working with a custom extension sidebar using a tree style (an outline of objects with disclosure buttons). When you define a tree sidebar, you also create a `TreeView` object to provide data and respond to events for that sidebar.
3177 | *
3178 | * The `TreeView` class is not subclassable.
3179 | * @implements {Disposable}
3180 | * @example
3181 | * // Create the TreeView
3182 | * let treeView = new TreeView("my-identifier", {
3183 | * dataProvider: new MyDataProvider()
3184 | * });
3185 | *
3186 | * treeView.onDidChangeSelection((selection) => {
3187 | * console.log("New selection: " + selection.map((e) => e.name));
3188 | * });
3189 | *
3190 | * treeView.onDidExpandElement((element) => {
3191 | * console.log("Expanded: " + element.name);
3192 | * });
3193 | *
3194 | * treeView.onDidCollapseElement((element) => {
3195 | * console.log("Collapsed: " + element.name);
3196 | * });
3197 | *
3198 | * treeView.onDidChangeVisibility(() => {
3199 | * console.log("Visibility Changed");
3200 | * });
3201 | */
3202 | declare class TreeView extends Disposable {
3203 | /** Creates a new `TreeView` object. The `identifier` argument should match the identifier specified for a sidebar section in your extension’s `extension.json` file. */
3204 | constructor(identifier: string, options?: {
3205 | /** Object that provides data to the tree (see [TreeDataProvider](https://docs.nova.app/api-reference/tree-data-provider)). */
3206 | dataProvider?: TreeDataProvider
3207 | })
3208 |
3209 | /** Whether the tree view is currently visible. */
3210 | readonly visible: boolean
3211 |
3212 | /** An array of elements that are currently selected within the tree view. */
3213 | readonly selection: ReadonlyArray
3214 |
3215 | /**
3216 | * Adds an event listener that invokes the provided `callback` when the tree view’s selection change. The callback will receive as an argument the array of selected elements.
3217 | *
3218 | * The optional `thisValue` argument may be used to set what `this` is bound to when the callable is invoked. If omitted, `this` will be `undefined`.
3219 | */
3220 | onDidChangeSelection(callback: (this: T, selectedElements: E[]) => void, thisValue?: T): Disposable
3221 |
3222 | /**
3223 | * Adds an event listener that invokes the provided `callback` when the tree view’s visibility change.
3224 | *
3225 | * The optional `thisValue` argument may be used to set what `this` is bound to when the callable is invoked. If omitted, `this` will be `undefined`.
3226 | */
3227 | onDidChangeVisibility(callback: (this: T) => void, thisValue?: T): Disposable
3228 |
3229 | /**
3230 | * Adds an event listener that invokes the provided `callback` when the an element is expanded. The callback will receive as an argument the element that was expanded.
3231 | *
3232 | * The optional `thisValue` argument may be used to set what `this` is bound to when the callable is invoked. If omitted, `this` will be `undefined`.
3233 | */
3234 | onDidExpandElement(callback: (this: T, element: E) => void, thisValue?: T): Disposable
3235 |
3236 | /**
3237 | * Adds an event listener that invokes the provided `callback` when the an element is collapsed. The callback will receive as an argument the element that was collapsed.
3238 | *
3239 | * The optional `thisValue` argument may be used to set what `this` is bound to when the callable is invoked. If omitted, `this` will be `undefined`.
3240 | */
3241 | onDidCollapseElement(callback: (this: T, element: E) => void, thisValue?: T): Disposable
3242 |
3243 | /**
3244 | * Causes the tree view to reload the specified element (if it is visible) and any descendants. Invoke this method with no argument (or with a `null` or `undefined` argument) to reload the entire tree view. Returns a `Promise` object that resolves when the reload has finished.
3245 | */
3246 | reload(element?: E | null): Promise
3247 |
3248 | /** Attempts to reveal the element in the tree. */
3249 | reveal(element: E, options?: {
3250 | /** Whether the element should be selected (default is `true`). */
3251 | select?: boolean
3252 |
3253 | /** Whether the scroll view of the tree should be scrolled to make the element visible (default is `false`). */
3254 | focus?: boolean
3255 |
3256 | /** The number of ancestors to attempt to expand to reveal the element (up to a maximum of 3). */
3257 | reveal?: number
3258 | }): void
3259 | }
3260 |
3261 | /// https://docs.nova.app/api-reference/web-apis/
3262 |
3263 | // TODO: Finish WEB APIs
3264 |
3265 | declare function atob(data: string): string
3266 | declare function btoa(data: string): string
3267 |
3268 | type TimerHandler = string | Function
3269 |
3270 | declare function setTimeout(handler: TimerHandler, timeout?: number, ...arguments: any[]): number
3271 | declare function clearTimeout(handle?: number): void
3272 |
3273 | declare function setInterval(handler: TimerHandler, timeout?: number, ...arguments: any[]): number
3274 | declare function clearInterval(handle?: number): void
3275 |
3276 | /// https://docs.nova.app/api-reference/workspace/
3277 |
3278 | /**
3279 | * A `Workspace` contains properties and methods related to an open workspace window. Extensions are loaded on a per-workspace basis, so there is generally only one workspace object available from the perspective of executing extension code.
3280 | *
3281 | * An instance representing the current workspace is always available via the `workspace` property of the global `nova` [Environment](https://docs.nova.app/api-reference/environment) object.
3282 | */
3283 | interface Workspace {
3284 | /** The `TextEditor` instance that is currently focused in the workspace. This may be `null` if no text editor is focused. */
3285 | readonly activeTextEditor: TextEditor | null
3286 |
3287 | /**
3288 | * The [Configuration](https://docs.nova.app/api-reference/configuration) object for the workspace, written into the workspace’s internal metadata folder.
3289 | *
3290 | * Extensions may store values in this configuration that should be written into a per-workspace storage, and potentially stored in source control by the user.
3291 | */
3292 | readonly config: Configuration
3293 |
3294 | /**
3295 | * An array of [DebugSession](https://docs.nova.app/api-reference/debug-session) objects which are running for the workspace.
3296 | * @since 9.0
3297 | */
3298 | readonly debugSessions: ReadonlyArray
3299 |
3300 | /** Returns the workspace’s path on disk, as a `String`. If the workspace is not bound to a folder this may be `null` or `undefined`. */
3301 | readonly path?: string | null
3302 |
3303 | /**
3304 | * The root path of the workspace’s preview. This path represents the directory being served at the root of previews. This property will return `null` or `undefined` in cases where previewing is not available for the workspace.
3305 | * @since 9.0
3306 | */
3307 | readonly previewRootPath?: string | null
3308 |
3309 | /**
3310 | * The computed URL for the workspace’s preview as a `String`. If the workspace is using Nova’s built-in web server this property will represent that server’s root. If the workspace has a custom preview URL set by the user this property will represent that URL. This method will return `null` or `undefined` in cases where previewing is not available for the workspace.
3311 | * @since 9.0
3312 | */
3313 | readonly previewURL?: string | null
3314 |
3315 | /** An array of [TextDocument](https://docs.nova.app/api-reference/text-document) objects representing each document open in the workspace. Text Documents are not necessarily one-to-one with the `textEditors` properties, as multiple editors can be opened for a single text document. */
3316 | readonly textDocuments: ReadonlyArray
3317 |
3318 | /** An array of [TextEditor](https://docs.nova.app/api-reference/text-editor) objects representing each text editor open in the workspace. Text Editors are not necessarily one-to-one with the `textDocuments` properties, as multiple editors can be opened for a single document. */
3319 | readonly textEditors: ReadonlyArray
3320 |
3321 | /** Returns `true` if the workspace contains the file at a specified path. If the workspace is not bound to a folder, this method always returns `false`. */
3322 | contains(path: string): boolean
3323 |
3324 | /**
3325 | * Adds an event listener that invokes the provided `callback` when the workspace opens a text editor. The callback will receive as an argument the [TextEditor](https://docs.nova.app/api-reference/text-editor) object.
3326 | *
3327 | * As a convenience, when this method is invoked the callback will also immediately be called with all open text editors.
3328 | *
3329 | * The optional `thisValue` argument may be used to set what `this` is bound to when the callable is invoked. If omitted, `this` will be `undefined`.
3330 | */
3331 | onDidAddTextEditor(callback: (this: T, editor: TextEditor) => void, thisValue?: T): Disposable
3332 |
3333 | /**
3334 | * Adds an event listener that invokes the provided `callback` when the workspace’s path changes. The callback will receive as an argument the new path as a string.
3335 | *
3336 | * The optional `thisValue` argument may be used to set what `this` is bound to when the callable is invoked. If omitted, `this` will be `undefined`.
3337 | */
3338 | onDidChangePath(callback: (this: T, newPath: string) => void, thisValue?: T): Disposable
3339 |
3340 | /**
3341 | * Adds an event listener that invokes the provided `callback` when the workspace ends a debug session. The callback will receive as an argument the [DebugSession](https://docs.nova.app/api-reference/debug-session) object.
3342 | *
3343 | * The optional `thisValue` argument may be used to set what `this` is bound to when the callable is invoked. If omitted, `this` will be `undefined`.
3344 | * @since 9.0
3345 | */
3346 | onDidEndDebugSession(callback: (this: T, debugSession: DebugSession) => void, thisValue?: T): Disposable
3347 |
3348 | /**
3349 | * Adds an event listener that invokes the provided `callback` when the workspace opens a text document. The callback will receive as an argument the [TextDocument](https://docs.nova.app/api-reference/text-document) object.
3350 | *
3351 | * As a convenience, when this method is invoked the callback will also immediately be called with all open text documents.
3352 | *
3353 | * The optional `thisValue` argument may be used to set what `this` is bound to when the callable is invoked. If omitted, `this` will be `undefined`.
3354 | */
3355 | onDidOpenTextDocument(callback: (this: T, document: TextDocument) => void, thisValue?: T): Disposable
3356 |
3357 | /**
3358 | * Adds an event listener that invokes the provided `callback` when the workspace starts a debug session. The callback will receive as an argument the [DebugSession](https://docs.nova.app/api-reference/debug-session) object.
3359 | *
3360 | * The optional `thisValue` argument may be used to set what `this` is bound to when the callable is invoked. If omitted, `this` will be `undefined`.
3361 | * @since 9.0
3362 | */
3363 | onDidStartDebugSession(callback: (this: T, debugSession: DebugSession) => void, thisValue?: T): Disposable
3364 |
3365 | /** Requests the workspace open the project settings view for a specified extension, by identifier. If no identifier is specified, the current extension’s project settings will be opened. */
3366 | openConfig(identifier?: string): void
3367 |
3368 | /** Requests the workspace open a file by URI. For local files, this can be either a file:// URI or a path on disk. Returns a `Promise` object that, on success, resolves to the new editor’s object (usually a [TextEditor](https://docs.nova.app/api-reference/text-editor) object), or `null` if the editor does not expose extension API. */
3369 | openFile(uri: string, options?: {
3370 | /** Line number to jump to after opening. */
3371 | line?: number,
3372 |
3373 | /** Column number to jump to after opening (requires `line`). */
3374 | column?: number
3375 | }): Promise | null
3376 |
3377 | /** Requests the workspace open a new, untitled document tab. */
3378 | openNewTextDocument(options?: {
3379 | /** The content of the new document, if any. */
3380 | content?: string
3381 |
3382 | /** Line number to jump to after opening. */
3383 | line?: number
3384 |
3385 | /** Column number to jump to after opening (requires `line`). */
3386 | column?: number
3387 |
3388 | /** The identifier for a syntax to set for the document. If not specified, the user’s default syntax will be used. */
3389 | syntax: string
3390 | })
3391 |
3392 | /**
3393 | * Returns a `String` representing the URL for previewing the file at the specified path. This method will return `null` or `undefined` in cases where previewing is not available for the workspace or if the specified file is not within the directory tree being served by the workspace’s preview.
3394 | * @since 9.0
3395 | */
3396 | previewURLForPath(path: string): string | null | undefined
3397 |
3398 | /** Converts an absolute path into a path relative to the workspace root. If the provided path is not a descendant of the workspace root then relative prefix components (`../`) will be applied as necessary to create a relative path. If the workspace is not bound to a folder this method returns the path unchanged. */
3399 | relativizePath(path): string
3400 |
3401 | /**
3402 | * Requests that the IDE reload tasks from the [task assistant](https://docs.nova.app/api-reference/assistants-registry) with the provided identifier. This will cause the IDE to invoke the `provideTasks()` method on the assistant asynchronously.
3403 | *
3404 | * If an assistant with the provided identifier is not registered this method has no effect.
3405 | */
3406 | reloadTasks(identifier: string): void
3407 |
3408 | /**
3409 | * Displays an action panel to the user. The panel will be titled with the calling extension’s name, and the provided `message` will be displayed as the panel body.
3410 | *
3411 | * The optional `callback` argument should be a callable, which will be invoked when the user chooses a button in the alert. The callback will be passed the button index chosen (as a `Number`), or `null` if the alert was dismissed by other means (such as the application cancelling the alert without user intervention).
3412 | */
3413 | showActionPanel(message: string, options?: {
3414 | /**
3415 | * An array of strings, used as button names in the alert.
3416 | *
3417 | * If not specified, a single “OK” button will be included.
3418 | */
3419 | buttons?: string[]
3420 | }, callback?: (buttonIndex: number | null) => void): void
3421 |
3422 | /**
3423 | * Displays a choice palette to the user (in the style of the command palette). The provided array of strings, `choices`, will be displayed as the initial results of the palette, and can be filtered by the user by typing.
3424 | *
3425 | * The optional `callback` argument should be a callable, which will be invoked when the user confirms with the Return key. The callback will be passed the choice (from the `choices` array) selected by the user or `null` if the palette was cancelled, as well as optionally the index of the choice within the provided array as the second argument.
3426 | */
3427 | showChoicePalette(choices: string[], options?: {
3428 | /** Text to display if no value is present. */
3429 | placeholder?: string
3430 | }, callback?: (choice: string | null, choiceIndex: number | null) => void): void
3431 |
3432 | /** Displays an error message to the user as an alert. The alert will be titled with the calling extension’s name, and the provided `message` will be displayed as the alert body. This method is similar to `showInformativeMessage` except it includes additional UI indications that the message indicates an error, and may bring the workspace’s window to the foreground. */
3433 | showErrorMessage(message: string): void
3434 |
3435 | /**
3436 | * Displays a file chooser panel to the user. The panel will be titled with the calling extension’s name, and the provided `message` will be displayed as the panel body.
3437 | *
3438 | * File chooser panels show a standard macOS open panel to request file(s) and folder(s) be selected by the user.
3439 | *
3440 | * The optional `callback` argument should be a callable, which will be invoked when the user dismisses the panel. The callback will be passed an array of paths chosen, or `null` if the alert was cancelled.
3441 | */
3442 | showFileChooser(message: string, options?: {
3443 | /** Text to display instead for the “OK” button. */
3444 | prompt?: string
3445 |
3446 | /** Whether the user may choose files. */
3447 | allowFiles?: boolean
3448 |
3449 | /** Whether the user may choose folders. */
3450 | allowFolders?: boolean
3451 |
3452 | /** Whether the user may choose multiple files. */
3453 | allowMultiple?: boolean
3454 |
3455 | /** The file types allowed, as an array of strings. Types may be file extensions or uniform type identifiers. */
3456 | filetype?: string[]
3457 |
3458 | /** Whether to return paths to the caller which are relative to the workspace. */
3459 | relative?: boolean
3460 | }, callback?: (paths: string[] | null) => void): void
3461 |
3462 | /** Displays an informative message to the user as an alert. The alert will be titled with the calling extension’s name, and the provided `message` will be displayed as the alert body. */
3463 | showInformativeMessage(message: string): void
3464 |
3465 | /**
3466 | * Displays an input palette to the user (in the style of the command palette). The provided `message` will be displayed as the palette’s descriptive text.
3467 | *
3468 | * Input palettes include a single text field to ask user for a value.
3469 | *
3470 | * The optional `callback` argument should be a callable, which will be invoked when the user confirms with the Return key. The callback will be passed the value provided by the user (as a `String`), or `null` if the palette was cancelled.
3471 | */
3472 | showInputPalette(message: string, options?: {
3473 | /** Text to display if no value is present. */
3474 | placeholder?: string
3475 |
3476 | /**
3477 | * Text with which to pre-fill the palette.
3478 | * @since 4.0
3479 | */
3480 | value?: string
3481 | }, callback?: (value: string | null) => void): void
3482 |
3483 | /**
3484 | * Displays an input panel to the user (in the style of a modal sheet). The panel will be titled with the calling extension’s name, and the provided `message` will be displayed as the panel body.
3485 | *
3486 | * Input panels include a single text field to ask user for a value, as well as two buttons (“Cancel” and “OK”).
3487 | *
3488 | * The optional `callback` argument should be a callable, which will be invoked when the user chooses a button in the alert. The callback will be passed the value provided by the user (as a `String`), or `null` if the alert was cancelled.
3489 | */
3490 | showInputPanel(message: string, options?: {
3491 | /** Label to display before the input field. */
3492 | label?: string
3493 |
3494 | /** Text to display if no value is present. */
3495 | placeholder?: string
3496 |
3497 | /** Default value to display. */
3498 | value?: string
3499 |
3500 | /** Text to display instead for the “OK” button. */
3501 | prompt?: string
3502 |
3503 | /** Whether the field should be “secure” (display its value using dots). */
3504 | secure?: boolean
3505 | }, callback?: (value: string | null) => void): void
3506 |
3507 | /** Displays a warning message to the user as an alert. The alert will be titled with the calling extension’s name, and the provided `message` will be displayed as the alert body. This method is similar to `showInformativeMessage` except it includes additional UI indications that the message indicates a warning, and may bring the workspace’s window to the foreground. */
3508 | showWarningMessage(message: string): void
3509 | }
3510 |
--------------------------------------------------------------------------------