diff --git a/crates/zed/src/languages/html.rs b/crates/zed/src/languages/html.rs index 20f097ba7f..be5493b4cb 100644 --- a/crates/zed/src/languages/html.rs +++ b/crates/zed/src/languages/html.rs @@ -1,4 +1,4 @@ -use anyhow::{anyhow, Context, Result}; +use anyhow::{anyhow, Result}; use async_trait::async_trait; use futures::StreamExt; use language::{LanguageServerBinary, LanguageServerName, LspAdapter}; @@ -8,7 +8,6 @@ use smol::fs; use std::ffi::OsString; use std::path::Path; use std::{any::Any, path::PathBuf, sync::Arc}; -use util::fs::remove_matching; use util::http::HttpClient; use util::ResultExt; @@ -53,21 +52,15 @@ impl LspAdapter for HtmlLspAdapter { container_dir: PathBuf, ) -> Result { let version = version.downcast::().unwrap(); - let version_dir = container_dir.join(version.as_str()); - fs::create_dir_all(&version_dir) - .await - .context("failed to create version directory")?; - let server_path = version_dir.join(Self::SERVER_PATH); + let server_path = container_dir.join(Self::SERVER_PATH); if fs::metadata(&server_path).await.is_err() { self.node .npm_install_packages( [("vscode-langservers-extracted", version.as_str())], - &version_dir, + &container_dir, ) .await?; - - remove_matching(container_dir.as_path(), |entry| entry != version_dir).await; } Ok(LanguageServerBinary { diff --git a/crates/zed/src/languages/json.rs b/crates/zed/src/languages/json.rs index 6bb3d94c5a..a318be512c 100644 --- a/crates/zed/src/languages/json.rs +++ b/crates/zed/src/languages/json.rs @@ -1,4 +1,4 @@ -use anyhow::{anyhow, Context, Result}; +use anyhow::{anyhow, Result}; use async_trait::async_trait; use collections::HashMap; use futures::{future::BoxFuture, FutureExt, StreamExt}; @@ -16,7 +16,7 @@ use std::{ sync::Arc, }; use theme::ThemeRegistry; -use util::{fs::remove_matching, http::HttpClient}; +use util::http::HttpClient; use util::{paths, ResultExt, StaffMode}; const SERVER_PATH: &'static str = @@ -70,21 +70,15 @@ impl LspAdapter for JsonLspAdapter { container_dir: PathBuf, ) -> Result { let version = version.downcast::().unwrap(); - let version_dir = container_dir.join(version.as_str()); - fs::create_dir_all(&version_dir) - .await - .context("failed to create version directory")?; - let server_path = version_dir.join(SERVER_PATH); + let server_path = container_dir.join(SERVER_PATH); if fs::metadata(&server_path).await.is_err() { self.node .npm_install_packages( [("vscode-json-languageserver", version.as_str())], - &version_dir, + &container_dir, ) .await?; - - remove_matching(&container_dir, |entry| entry != version_dir).await; } Ok(LanguageServerBinary { diff --git a/crates/zed/src/languages/python.rs b/crates/zed/src/languages/python.rs index d5fd865221..08476c9c21 100644 --- a/crates/zed/src/languages/python.rs +++ b/crates/zed/src/languages/python.rs @@ -1,4 +1,4 @@ -use anyhow::{anyhow, Context, Result}; +use anyhow::{anyhow, Result}; use async_trait::async_trait; use futures::StreamExt; use language::{LanguageServerBinary, LanguageServerName, LspAdapter}; @@ -10,7 +10,6 @@ use std::{ path::{Path, PathBuf}, sync::Arc, }; -use util::fs::remove_matching; use util::http::HttpClient; use util::ResultExt; @@ -50,18 +49,12 @@ impl LspAdapter for PythonLspAdapter { container_dir: PathBuf, ) -> Result { let version = version.downcast::().unwrap(); - let version_dir = container_dir.join(version.as_str()); - fs::create_dir_all(&version_dir) - .await - .context("failed to create version directory")?; - let server_path = version_dir.join(Self::SERVER_PATH); + let server_path = container_dir.join(Self::SERVER_PATH); if fs::metadata(&server_path).await.is_err() { self.node - .npm_install_packages([("pyright", version.as_str())], &version_dir) + .npm_install_packages([("pyright", version.as_str())], &container_dir) .await?; - - remove_matching(&container_dir, |entry| entry != version_dir).await; } Ok(LanguageServerBinary { diff --git a/crates/zed/src/languages/typescript.rs b/crates/zed/src/languages/typescript.rs index 0c6e7e3c09..d6097d9b06 100644 --- a/crates/zed/src/languages/typescript.rs +++ b/crates/zed/src/languages/typescript.rs @@ -1,4 +1,4 @@ -use anyhow::{anyhow, Context, Result}; +use anyhow::{anyhow, Result}; use async_trait::async_trait; use futures::StreamExt; use language::{LanguageServerBinary, LanguageServerName, LspAdapter}; @@ -12,7 +12,6 @@ use std::{ path::{Path, PathBuf}, sync::Arc, }; -use util::fs::remove_matching; use util::http::HttpClient; use util::ResultExt; @@ -69,14 +68,7 @@ impl LspAdapter for TypeScriptLspAdapter { container_dir: PathBuf, ) -> Result { let versions = versions.downcast::().unwrap(); - let version_dir = container_dir.join(&format!( - "typescript-{}:server-{}", - versions.typescript_version, versions.server_version - )); - fs::create_dir_all(&version_dir) - .await - .context("failed to create version directory")?; - let server_path = version_dir.join(Self::NEW_SERVER_PATH); + let server_path = container_dir.join(Self::NEW_SERVER_PATH); if fs::metadata(&server_path).await.is_err() { self.node @@ -88,11 +80,9 @@ impl LspAdapter for TypeScriptLspAdapter { versions.server_version.as_str(), ), ], - &version_dir, + &container_dir, ) .await?; - - remove_matching(&container_dir, |entry| entry != version_dir).await; } Ok(LanguageServerBinary { diff --git a/crates/zed/src/languages/yaml.rs b/crates/zed/src/languages/yaml.rs index 7339512f1a..a34bbeb596 100644 --- a/crates/zed/src/languages/yaml.rs +++ b/crates/zed/src/languages/yaml.rs @@ -1,4 +1,4 @@ -use anyhow::{anyhow, Context, Result}; +use anyhow::{anyhow, Result}; use async_trait::async_trait; use futures::{future::BoxFuture, FutureExt, StreamExt}; use gpui::MutableAppContext; @@ -14,8 +14,8 @@ use std::{ path::{Path, PathBuf}, sync::Arc, }; +use util::http::HttpClient; use util::ResultExt; -use util::{fs::remove_matching, http::HttpClient}; fn server_binary_arguments(server_path: &Path) -> Vec { vec![server_path.into(), "--stdio".into()] @@ -57,18 +57,12 @@ impl LspAdapter for YamlLspAdapter { container_dir: PathBuf, ) -> Result { let version = version.downcast::().unwrap(); - let version_dir = container_dir.join(version.as_str()); - fs::create_dir_all(&version_dir) - .await - .context("failed to create version directory")?; - let server_path = version_dir.join(Self::SERVER_PATH); + let server_path = container_dir.join(Self::SERVER_PATH); if fs::metadata(&server_path).await.is_err() { self.node - .npm_install_packages([("yaml-language-server", version.as_str())], &version_dir) + .npm_install_packages([("yaml-language-server", version.as_str())], &container_dir) .await?; - - remove_matching(&container_dir, |entry| entry != version_dir).await; } Ok(LanguageServerBinary {