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 {
|
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 let Some(path) = &self.cached_binary_path {
|
||||||
if fs::metadata(path).map_or(false, |stat| stat.is_file()) {
|
if fs::metadata(path).map_or(false, |stat| stat.is_file()) {
|
||||||
return Ok(path.clone());
|
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(
|
zed::set_language_server_installation_status(
|
||||||
&config.name,
|
&config.name,
|
||||||
&zed::LanguageServerInstallationStatus::CheckingForUpdate,
|
&zed::LanguageServerInstallationStatus::CheckingForUpdate,
|
||||||
|
@ -88,10 +97,10 @@ impl zed::Extension for GleamExtension {
|
||||||
fn language_server_command(
|
fn language_server_command(
|
||||||
&mut self,
|
&mut self,
|
||||||
config: zed::LanguageServerConfig,
|
config: zed::LanguageServerConfig,
|
||||||
_worktree: &zed::Worktree,
|
worktree: &zed::Worktree,
|
||||||
) -> Result<zed::Command> {
|
) -> Result<zed::Command> {
|
||||||
Ok(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()],
|
args: vec!["lsp".to_string()],
|
||||||
env: Default::default(),
|
env: Default::default(),
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue