Open History to see the last commit
1import { Schema } from "effect";
2import { TrimmedNonEmptyString } from "./baseSchemas";
3
4export const EditorLaunchStyle = Schema.Literals(["direct-path", "goto", "line-column"]);
5export type EditorLaunchStyle = typeof EditorLaunchStyle.Type;
6
7type EditorDefinition = {
8 readonly id: string;
9 readonly label: string;
10 readonly commands: readonly [string, ...string[]] | null;
11 readonly launchStyle: EditorLaunchStyle;
12};
13
14export const EDITORS = [
15 { id: "cursor", label: "Cursor", commands: ["cursor"], launchStyle: "goto" },
16 { id: "trae", label: "Trae", commands: ["trae"], launchStyle: "goto" },
17 { id: "vscode", label: "VS Code", commands: ["code"], launchStyle: "goto" },
18 {
19 id: "vscode-insiders",
20 label: "VS Code Insiders",
21 commands: ["code-insiders"],
22 launchStyle: "goto",
23 },
24 { id: "vscodium", label: "VSCodium", commands: ["codium"], launchStyle: "goto" },
25 { id: "zed", label: "Zed", commands: ["zed", "zeditor"], launchStyle: "direct-path" },
26 { id: "antigravity", label: "Antigravity", commands: ["agy"], launchStyle: "goto" },
27 { id: "idea", label: "IntelliJ IDEA", commands: ["idea"], launchStyle: "line-column" },
28 { id: "file-manager", label: "File Manager", commands: null, launchStyle: "direct-path" },
29] as const satisfies ReadonlyArray<EditorDefinition>;
30
31export const EditorId = Schema.Literals(EDITORS.map((e) => e.id));
32export type EditorId = typeof EditorId.Type;
33
34export const OpenInEditorInput = Schema.Struct({
35 cwd: TrimmedNonEmptyString,
36 editor: EditorId,
37});
38export type OpenInEditorInput = typeof OpenInEditorInput.Type;
39
40export class OpenError extends Schema.TaggedErrorClass<OpenError>()("OpenError", {
41 message: Schema.String,
42 cause: Schema.optional(Schema.Defect),
43}) {}