zig: Add Windows support (#15197)

Release Notes:

- N/A

Currently Windows environments do not have a `shell_env`. This causes
the Zig extension to error when trying to call `worktree.shell_env()`
since extensions api isn't yet on `0.0.7` and thus not using wasm-host
`0.0.7` we need to only call for the shell env only on non-windows
systems. 0.0.7 and onward at the moment return a Result from
`shell_env()`. The binary path is also slightly different on windows.

---------

Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
This commit is contained in:
Uberlicious 2024-07-25 10:30:02 -05:00 committed by GitHub
parent 3ce864e69e
commit cd9dd5ccf7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -19,7 +19,12 @@ impl ZigExtension {
worktree: &zed::Worktree,
) -> Result<ZlsBinary> {
let mut args: Option<Vec<String>> = None;
let environment = Some(worktree.shell_env());
let (platform, arch) = zed::current_platform();
let environment = match platform {
zed::Os::Mac | zed::Os::Linux => Some(worktree.shell_env()),
zed::Os::Windows => None,
};
if let Ok(lsp_settings) = LspSettings::for_worktree("zls", worktree) {
if let Some(binary) = lsp_settings.binary {
@ -72,7 +77,6 @@ impl ZigExtension {
},
)?;
let (platform, arch) = zed::current_platform();
let asset_name = format!(
"zls-{arch}-{os}.{extension}",
arch = match arch {
@ -98,7 +102,10 @@ impl ZigExtension {
.ok_or_else(|| format!("no asset found matching {:?}", asset_name))?;
let version_dir = format!("zls-{}", release.version);
let binary_path = format!("{version_dir}/bin/zls");
let binary_path = match platform {
zed::Os::Mac | zed::Os::Linux => format!("{version_dir}/bin/zls"),
zed::Os::Windows => format!("{version_dir}/zls.exe"),
};
if !fs::metadata(&binary_path).map_or(false, |stat| stat.is_file()) {
zed::set_language_server_installation_status(