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 path within the extension's
66 /// working directory. Extracts the file according to the given file type.
67 import download-file: func(url: string, file-path: string, file-type: downloaded-file-type) -> result<_, string>;
68
69 /// Makes the file at the given path executable.
70 import make-file-executable: func(filepath: string) -> result<_, string>;
71
72 /// Updates the installation status for the given language server.
73 import set-language-server-installation-status: func(language-server-name: string, status: language-server-installation-status);
74
75 type env-vars = list<tuple<string, string>>;
76
77 record command {
78 command: string,
79 args: list<string>,
80 env: env-vars,
81 }
82
83 resource worktree {
84 read-text-file: func(path: string) -> result<string, string>;
85 which: func(binary-name: string) -> option<string>;
86 shell-env: func() -> env-vars;
87 }
88
89 record language-server-config {
90 name: string,
91 language-name: string,
92 }
93
94 export language-server-command: func(config: language-server-config, worktree: borrow<worktree>) -> result<command, string>;
95 export language-server-initialization-options: func(config: language-server-config, worktree: borrow<worktree>) -> result<option<string>, string>;
96}