Open History to see the last commit
1import * as Schema from "effect/Schema";
2import { TrimmedNonEmptyString } from "./baseSchemas.ts";
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 baseArgs?: readonly string[];
12 readonly launchStyle: EditorLaunchStyle;
13};
14
15export const EDITORS = [
16 { id: "cursor", label: "Cursor", commands: ["cursor"], launchStyle: "goto" },
17 { id: "trae", label: "Trae", commands: ["trae"], launchStyle: "goto" },
18 { id: "kiro", label: "Kiro", commands: ["kiro"], baseArgs: ["ide"], launchStyle: "goto" },
19 { id: "vscode", label: "VS Code", commands: ["code"], launchStyle: "goto" },
20 {
21 id: "vscode-insiders",
22 label: "VS Code Insiders",
23 commands: ["code-insiders"],
24 launchStyle: "goto",
25 },
26 { id: "vscodium", label: "VSCodium", commands: ["codium"], launchStyle: "goto" },
27 { id: "zed", label: "Zed", commands: ["zed", "zeditor"], launchStyle: "direct-path" },
28 { id: "antigravity", label: "Antigravity", commands: ["agy"], launchStyle: "goto" },
29 { id: "idea", label: "IntelliJ IDEA", commands: ["idea"], launchStyle: "line-column" },
30 { id: "aqua", label: "Aqua", commands: ["aqua"], launchStyle: "line-column" },
31 { id: "clion", label: "CLion", commands: ["clion"], launchStyle: "line-column" },
32 { id: "datagrip", label: "DataGrip", commands: ["datagrip"], launchStyle: "line-column" },
33 { id: "dataspell", label: "DataSpell", commands: ["dataspell"], launchStyle: "line-column" },
34 { id: "goland", label: "GoLand", commands: ["goland"], launchStyle: "line-column" },
35 { id: "phpstorm", label: "PhpStorm", commands: ["phpstorm"], launchStyle: "line-column" },
36 { id: "pycharm", label: "PyCharm", commands: ["pycharm"], launchStyle: "line-column" },
37 { id: "rider", label: "Rider", commands: ["rider"], launchStyle: "line-column" },
38 { id: "rubymine", label: "RubyMine", commands: ["rubymine"], launchStyle: "line-column" },
39 { id: "rustrover", label: "RustRover", commands: ["rustrover"], launchStyle: "line-column" },
40 { id: "webstorm", label: "WebStorm", commands: ["webstorm"], launchStyle: "line-column" },
41 { id: "file-manager", label: "File Manager", commands: null, launchStyle: "direct-path" },
42] as const satisfies ReadonlyArray<EditorDefinition>;
43
44export const EditorId = Schema.Literals(EDITORS.map((e) => e.id));
45export type EditorId = typeof EditorId.Type;
46
47export const LaunchEditorInput = Schema.Struct({
48 cwd: TrimmedNonEmptyString,
49 editor: EditorId,
50});
51export type LaunchEditorInput = typeof LaunchEditorInput.Type;
52
53export class ExternalLauncherError extends Schema.TaggedErrorClass<ExternalLauncherError>()(
54 "ExternalLauncherError",
55 {
56 message: Schema.String,
57 cause: Schema.optional(Schema.Defect),
58 },
59) {}