mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-12 05:27:07 +00:00
gleam: Check for gleam
on the PATH before installing the latest version (#9882)
This PR updates the Gleam extension to give priority to the `gleam` binary that is already on the PATH before downloading/installing a separate Gleam version. Release Notes: - N/A
This commit is contained in:
parent
894b39a918
commit
95699a07f4
1 changed files with 12 additions and 3 deletions
|
@ -6,13 +6,22 @@ struct GleamExtension {
|
|||
}
|
||||
|
||||
impl GleamExtension {
|
||||
fn language_server_binary_path(&mut self, config: zed::LanguageServerConfig) -> Result<String> {
|
||||
fn language_server_binary_path(
|
||||
&mut self,
|
||||
config: zed::LanguageServerConfig,
|
||||
worktree: &zed::Worktree,
|
||||
) -> Result<String> {
|
||||
if let Some(path) = &self.cached_binary_path {
|
||||
if fs::metadata(path).map_or(false, |stat| stat.is_file()) {
|
||||
return Ok(path.clone());
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(path) = worktree.which("gleam") {
|
||||
self.cached_binary_path = Some(path.clone());
|
||||
return Ok(path);
|
||||
}
|
||||
|
||||
zed::set_language_server_installation_status(
|
||||
&config.name,
|
||||
&zed::LanguageServerInstallationStatus::CheckingForUpdate,
|
||||
|
@ -88,10 +97,10 @@ impl zed::Extension for GleamExtension {
|
|||
fn language_server_command(
|
||||
&mut self,
|
||||
config: zed::LanguageServerConfig,
|
||||
_worktree: &zed::Worktree,
|
||||
worktree: &zed::Worktree,
|
||||
) -> Result<zed::Command> {
|
||||
Ok(zed::Command {
|
||||
command: self.language_server_binary_path(config)?,
|
||||
command: self.language_server_binary_path(config, worktree)?,
|
||||
args: vec!["lsp".to_string()],
|
||||
env: Default::default(),
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue