Skip to content

Commit

Permalink
Check for user installed clangd (zed-industries#9605)
Browse files Browse the repository at this point in the history
Release Notes:

- Improved C/C++ support using user installed clangd when available
  • Loading branch information
zaucy authored Mar 21, 2024
1 parent 85fdcef commit b6201a3
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions crates/languages/src/c.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use anyhow::{anyhow, bail, Context, Result};
use async_trait::async_trait;
use futures::StreamExt;
use gpui::AsyncAppContext;
pub use language::*;
use lsp::LanguageServerBinary;
use smol::fs::{self, File};
Expand Down Expand Up @@ -29,6 +30,7 @@ impl super::LspAdapter for CLspAdapter {
let os_suffix = match consts::OS {
"macos" => "mac",
"linux" => "linux",
"windows" => "windows",
other => bail!("Running on unsupported os: {other}"),
};
let asset_name = format!("clangd-{}-{}.zip", os_suffix, release.tag_name);
Expand All @@ -44,6 +46,20 @@ impl super::LspAdapter for CLspAdapter {
Ok(Box::new(version) as Box<_>)
}

async fn check_if_user_installed(
&self,
delegate: &dyn LspAdapterDelegate,
_: &AsyncAppContext,
) -> Option<LanguageServerBinary> {
let env = delegate.shell_env().await;
let path = delegate.which("clangd".as_ref()).await?;
Some(LanguageServerBinary {
path,
arguments: vec![],
env: Some(env),
})
}

async fn fetch_server_binary(
&self,
version: Box<dyn 'static + Send + Any>,
Expand Down

0 comments on commit b6201a3

Please sign in to comment.