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:
parent
3ce864e69e
commit
cd9dd5ccf7
1 changed files with 10 additions and 3 deletions
|
@ -19,7 +19,12 @@ impl ZigExtension {
|
||||||
worktree: &zed::Worktree,
|
worktree: &zed::Worktree,
|
||||||
) -> Result<ZlsBinary> {
|
) -> Result<ZlsBinary> {
|
||||||
let mut args: Option<Vec<String>> = None;
|
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 Ok(lsp_settings) = LspSettings::for_worktree("zls", worktree) {
|
||||||
if let Some(binary) = lsp_settings.binary {
|
if let Some(binary) = lsp_settings.binary {
|
||||||
|
@ -72,7 +77,6 @@ impl ZigExtension {
|
||||||
},
|
},
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
let (platform, arch) = zed::current_platform();
|
|
||||||
let asset_name = format!(
|
let asset_name = format!(
|
||||||
"zls-{arch}-{os}.{extension}",
|
"zls-{arch}-{os}.{extension}",
|
||||||
arch = match arch {
|
arch = match arch {
|
||||||
|
@ -98,7 +102,10 @@ impl ZigExtension {
|
||||||
.ok_or_else(|| format!("no asset found matching {:?}", asset_name))?;
|
.ok_or_else(|| format!("no asset found matching {:?}", asset_name))?;
|
||||||
|
|
||||||
let version_dir = format!("zls-{}", release.version);
|
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()) {
|
if !fs::metadata(&binary_path).map_or(false, |stat| stat.is_file()) {
|
||||||
zed::set_language_server_installation_status(
|
zed::set_language_server_installation_status(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue