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 none,
42 downloading,
43 checking-for-update,
44 failed(string),
45 }
46
47 /// Gets the current operating system and architecture
48 import current-platform: func() -> tuple<os, architecture>;
49
50 /// Get the path to the node binary used by Zed.
51 import node-binary-path: func() -> result<string, string>;
52
53 /// Gets the latest version of the given NPM package.
54 import npm-package-latest-version: func(package-name: string) -> result<string, string>;
55
56 /// Returns the installed version of the given NPM package, if it exists.
57 import npm-package-installed-version: func(package-name: string) -> result<option<string>, string>;
58
59 /// Installs the specified NPM package.
60 import npm-install-package: func(package-name: string, version: string) -> result<_, string>;
61
62 /// Gets the latest release for the given GitHub repository.
63 import latest-github-release: func(repo: string, options: github-release-options) -> result<github-release, string>;
64
65 /// Downloads a file from the given url, and saves it to the given filename within the extension's
66 /// working directory. Extracts the file according to the given file type.
67 import download-file: func(url: string, output-filename: string, file-type: downloaded-file-type) -> result<_, string>;
68
69 /// Updates the installation status for the given language server.
70 import set-language-server-installation-status: func(language-server-name: string, status: language-server-installation-status);
71
72 type env-vars = list<tuple<string, string>>;
73
74 record command {
75 command: string,
76 args: list<string>,
77 env: env-vars,
78 }
79
80 resource worktree {
81 read-text-file: func(path: string) -> result<string, string>;
82 which: func(binary-name: string) -> option<string>;
83 shell-env: func() -> env-vars;
84 }
85
86 record language-server-config {
87 name: string,
88 language-name: string,
89 }
90
91 export language-server-command: func(config: language-server-config, worktree: borrow<worktree>) -> result<command, string>;
92 export language-server-initialization-options: func(config: language-server-config, worktree: borrow<worktree>) -> result<option<string>, string>;
93}