extension.wit

 1package zed:extension;
 2
 3world extension {
 4    export init-extension: func();
 5
 6    record github-release {
 7        version: string,
 8        assets: list<github-release-asset>,
 9    }
10
11    record github-release-asset {
12        name: string,
13        download-url: string,
14    }
15
16    record github-release-options {
17        require-assets: bool,
18        pre-release: bool,
19    }
20
21    enum os {
22        mac,
23        linux,
24        windows,
25    }
26
27    enum architecture {
28        aarch64,
29        x86,
30        x8664,
31    }
32
33    enum downloaded-file-type {
34        gzip,
35        gzip-tar,
36        zip,
37        uncompressed,
38    }
39
40    variant language-server-installation-status {
41        checking-for-update,
42        downloaded,
43        downloading,
44        cached,
45        failed(string),
46    }
47
48    /// Gets the current operating system and architecture
49    import current-platform: func() -> tuple<os, architecture>;
50
51    /// Gets the latest version of the given NPM package.
52    import npm-package-latest-version: func(package-name: string) -> result<string, string>;
53
54    /// Gets the latest release for the given GitHub repository.
55    import latest-github-release: func(repo: string, options: github-release-options) -> result<github-release, string>;
56
57    /// Downloads a file from the given url, and saves it to the given filename within the extension's
58    /// working directory. Extracts the file according to the given file type.
59    import download-file: func(url: string, output-filename: string, file-type: downloaded-file-type) -> result<_, string>;
60
61    /// Updates the installation status for the given language server.
62    import set-language-server-installation-status: func(language-server-name: string, status: language-server-installation-status);
63
64    record command {
65        command: string,
66        args: list<string>,
67        env: list<tuple<string, string>>,
68    }
69
70    resource worktree {
71        read-text-file: func(path: string) -> result<string, string>;
72    }
73
74    record language-server-config {
75        name: string,
76        language-name: string,
77    }
78
79    export language-server-command: func(config: language-server-config, worktree: borrow<worktree>) -> result<command, string>;
80}