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