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