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
This commit is contained in:
versecafe 2024-08-22 09:45:04 -04:00 committed by GitHub
parent 5250866c1a
commit bb725d3158
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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 {
// 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,
},
)?;
let arch: &str = match arch {
zed::Architecture::Aarch64 => "aarch64",
zed::Architecture::X86 => "x86",
zed::Architecture::X8664 => "x86_64",
},
os = match platform {
};
let os: &str = match platform {
zed::Os::Mac => "macos",
zed::Os::Linux => "linux",
zed::Os::Windows => "windows",
},
extension = match platform {
};
let extension: &str = 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 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,