clangd: download the correct binary on Linux (#8820)

Thorben Kröger created

Release Notes:

- Fixed clangd LSP download not working on Linux

Change summary

crates/languages/src/c.rs | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)

Detailed changes

crates/languages/src/c.rs 🔗

@@ -1,10 +1,10 @@
-use anyhow::{anyhow, Context, Result};
+use anyhow::{anyhow, bail, Context, Result};
 use async_trait::async_trait;
 use futures::StreamExt;
 pub use language::*;
 use lsp::LanguageServerBinary;
 use smol::fs::{self, File};
-use std::{any::Any, path::PathBuf, sync::Arc};
+use std::{any::Any, env::consts, path::PathBuf, sync::Arc};
 use util::{
     async_maybe,
     fs::remove_matching,
@@ -26,7 +26,12 @@ impl super::LspAdapter for CLspAdapter {
     ) -> Result<Box<dyn 'static + Send + Any>> {
         let release =
             latest_github_release("clangd/clangd", true, false, delegate.http_client()).await?;
-        let asset_name = format!("clangd-mac-{}.zip", release.tag_name);
+        let os_suffix = match consts::OS {
+            "macos" => "mac",
+            "linux" => "linux",
+            other => bail!("Running on unsupported os: {other}"),
+        };
+        let asset_name = format!("clangd-{}-{}.zip", os_suffix, release.tag_name);
         let asset = release
             .assets
             .iter()