From bb725d3158884badf64e57e25980ab1fc7e13d01 Mon Sep 17 00:00:00 2001 From: versecafe <147033096+versecafe@users.noreply.github.com> Date: Thu, 22 Aug 2024 09:45:04 -0400 Subject: [PATCH] zig: Unpin Zig LSP grab newest version off GH releases, and download from zigtools.org (#16645) Fixed Zig LSP being pinned to 0.11.0 due to discontinuation of `.tar.gz` Release Notes: - N/A --- extensions/zig/src/zig.rs | 57 ++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/extensions/zig/src/zig.rs b/extensions/zig/src/zig.rs index b62b4ed642..44a68a4b6a 100644 --- a/extensions/zig/src/zig.rs +++ b/extensions/zig/src/zig.rs @@ -61,39 +61,40 @@ impl ZigExtension { &language_server_id, &zed::LanguageServerInstallationStatus::CheckingForUpdate, ); - // We're pinning ZLS to a release that has `.tar.gz` assets, since the latest release does not have - // them, at time of writing. - // - // ZLS tracking issue: https://github.com/zigtools/zls/issues/1879 - let release = zed::github_release_by_tag_name("zigtools/zls", "0.11.0")?; - let asset_name = format!( - "zls-{arch}-{os}.{extension}", - arch = match arch { - zed::Architecture::Aarch64 => "aarch64", - zed::Architecture::X86 => "x86", - zed::Architecture::X8664 => "x86_64", + // Note that in github releases and on zlstools.org the tar.gz asset is not shown + // but is available at https://builds.zigtools.org/zls-{os}-{arch}-{version}.tar.gz + let release = zed::latest_github_release( + "zigtools/zls", + zed::GithubReleaseOptions { + require_assets: true, + pre_release: false, }, - os = match platform { - zed::Os::Mac => "macos", - zed::Os::Linux => "linux", - zed::Os::Windows => "windows", - }, - extension = match platform { - zed::Os::Mac | zed::Os::Linux => "tar.gz", - zed::Os::Windows => "zip", - } - ); + )?; - let asset = release - .assets - .iter() - .find(|asset| asset.name == asset_name) - .ok_or_else(|| format!("no asset found matching {:?}", asset_name))?; + let arch: &str = match arch { + zed::Architecture::Aarch64 => "aarch64", + zed::Architecture::X86 => "x86", + zed::Architecture::X8664 => "x86_64", + }; + + let os: &str = match platform { + zed::Os::Mac => "macos", + zed::Os::Linux => "linux", + zed::Os::Windows => "windows", + }; + + let extension: &str = match platform { + zed::Os::Mac | zed::Os::Linux => "tar.gz", + zed::Os::Windows => "zip", + }; + + let asset_name: String = format!("zls-{}-{}-{}.{}", os, arch, release.version, extension); + let download_url = format!("https://builds.zigtools.org/{}", asset_name); let version_dir = format!("zls-{}", release.version); let binary_path = match platform { - zed::Os::Mac | zed::Os::Linux => format!("{version_dir}/bin/zls"), + zed::Os::Mac | zed::Os::Linux => format!("{version_dir}/zls"), zed::Os::Windows => format!("{version_dir}/zls.exe"), }; @@ -104,7 +105,7 @@ impl ZigExtension { ); zed::download_file( - &asset.download_url, + &download_url, &version_dir, match platform { zed::Os::Mac | zed::Os::Linux => zed::DownloadedFileType::GzipTar,