Add typescript language server
Currently not tested for tsx files Co-authored-by: Max Brunsfeld <max@zed.dev>
This commit is contained in:
parent
d466768eed
commit
0e1d371a67
7 changed files with 90 additions and 53 deletions
|
@ -6,7 +6,7 @@ pub use language::*;
|
|||
use lazy_static::lazy_static;
|
||||
use regex::Regex;
|
||||
use smol::fs::{self, File};
|
||||
use std::{borrow::Cow, env::consts, path::PathBuf, str, sync::Arc};
|
||||
use std::{any::Any, borrow::Cow, env::consts, path::PathBuf, str, sync::Arc};
|
||||
use util::{ResultExt, TryFutureExt};
|
||||
|
||||
use super::GithubRelease;
|
||||
|
@ -21,7 +21,7 @@ impl LspAdapter for RustLspAdapter {
|
|||
fn fetch_latest_server_version(
|
||||
&self,
|
||||
http: Arc<dyn HttpClient>,
|
||||
) -> BoxFuture<'static, Result<LspBinaryVersion>> {
|
||||
) -> BoxFuture<'static, Result<Box<dyn 'static + Send + Any>>> {
|
||||
async move {
|
||||
let release = http
|
||||
.send(
|
||||
|
@ -46,27 +46,28 @@ impl LspAdapter for RustLspAdapter {
|
|||
.iter()
|
||||
.find(|asset| asset.name == asset_name)
|
||||
.ok_or_else(|| anyhow!("no release found matching {:?}", asset_name))?;
|
||||
Ok(LspBinaryVersion {
|
||||
Ok(Box::new(GitHubLspBinaryVersion {
|
||||
name: release.name,
|
||||
url: Some(asset.browser_download_url.clone()),
|
||||
})
|
||||
url: asset.browser_download_url.clone(),
|
||||
}) as Box<_>)
|
||||
}
|
||||
.boxed()
|
||||
}
|
||||
|
||||
fn fetch_server_binary(
|
||||
&self,
|
||||
version: LspBinaryVersion,
|
||||
version: Box<dyn 'static + Send + Any>,
|
||||
http: Arc<dyn HttpClient>,
|
||||
container_dir: PathBuf,
|
||||
) -> BoxFuture<'static, Result<PathBuf>> {
|
||||
async move {
|
||||
let version = version.downcast::<GitHubLspBinaryVersion>().unwrap();
|
||||
let destination_path = container_dir.join(format!("rust-analyzer-{}", version.name));
|
||||
|
||||
if fs::metadata(&destination_path).await.is_err() {
|
||||
let response = http
|
||||
.send(
|
||||
surf::RequestBuilder::new(Method::Get, version.url.unwrap())
|
||||
surf::RequestBuilder::new(Method::Get, version.url)
|
||||
.middleware(surf::middleware::Redirect::default())
|
||||
.build(),
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue