Skip to content

Commit

Permalink
🤖 Merge PR DefinitelyTyped#49538 nova-editor: New features from Nova …
Browse files Browse the repository at this point in the history
…3 by @apexskier

* nova-editor: New features from Nova 3

* Add some missing promise types to editor methods
  • Loading branch information
apexskier authored Dec 4, 2020
1 parent ec0603c commit 64aaf4f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
21 changes: 17 additions & 4 deletions types/nova-editor-node/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Type definitions for non-npm package nova-editor-node 2.0
// Type definitions for non-npm package nova-editor-node 3.0
// Project: https://docs.nova.app/api-reference/
// Definitions by: Cameron Little <https://github.com/apexskier>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
Expand All @@ -19,7 +19,11 @@ type WritableStream<T = any> = unknown;
type AssistantsRegistrySelector = string | { syntax: string };

interface AssistantsRegistry {
registerCompletionAssistant(selector: AssistantsRegistrySelector, object: CompletionAssistant): Disposable;
registerCompletionAssistant(
selector: AssistantsRegistrySelector,
object: CompletionAssistant,
options?: { triggerChars?: Charset },
): Disposable;
registerIssueAssistant(
selector: AssistantsRegistrySelector,
object: IssueAssistant,
Expand Down Expand Up @@ -692,6 +696,15 @@ declare class Task {
setAction(name: string, action?: TaskProcessAction | null): void;
}

/// https://docs.nova.app/api-reference/task-command-action/

declare class TaskCommandAction {
constructor(command: string, options?: { args?: string[] });

readonly args: string[];
readonly command: string;
}

/// https://docs.nova.app/api-reference/task-process-action/

declare class TaskProcessAction {
Expand Down Expand Up @@ -757,12 +770,12 @@ declare class TextEditor {

edit(callback: (edit: TextEditorEdit) => void, options?: unknown): Promise<void>;
insert(string: string, format?: InsertTextFormat): Promise<void>;
save(): void;
save(): Promise<void>;
getTextInRange(range: Range): string;
getLineRangeForRange(range: Range): Range;
onDidChange(callback: (textEditor: TextEditor) => void): Disposable;
onDidStopChanging(callback: (textEditor: TextEditor) => void): Disposable;
onWillSave(callback: (textEditor: TextEditor) => void): Disposable;
onWillSave(callback: (textEditor: TextEditor) => void | Promise<void>): Disposable;
onDidSave(callback: (textEditor: TextEditor) => void): Disposable;
onDidChangeSelection(callback: (textEditor: TextEditor) => void): Disposable;
onDidDestroy(callback: (textEditor: TextEditor) => void): Disposable;
Expand Down
8 changes: 8 additions & 0 deletions types/nova-editor-node/nova-editor-node-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,14 @@ task.setAction(
}),
);

/// https://docs.nova.app/api-reference/task-command-action/

const action = new TaskCommandAction('myextension.runAction', {
args: ["I'm Running!"]
});

task.setAction(Task.Run, action);

/// https://novadocs.panic.com/api-reference/text-editor/

// $ExpectError
Expand Down

0 comments on commit 64aaf4f

Please sign in to comment.