Improve installation of npm-based language servers

* Use --prefix flag to guarantee that they are installed in .zed
* Use the @latest tag when available
* Extract helper functions

Co-authored-by: Keith Simmons <keith@zed.dev>
This commit is contained in:
Max Brunsfeld 2022-03-30 16:48:57 -07:00
parent 4805cfe48c
commit cf9efd7005
6 changed files with 141 additions and 125 deletions

View file

@ -1,11 +1,10 @@
use client::http;
use gpui::Task;
pub use language::*;
use rust_embed::RustEmbed;
use serde::Deserialize;
use std::{borrow::Cow, str, sync::Arc};
mod c;
mod installation;
mod json;
mod rust;
mod typescript;
@ -15,18 +14,6 @@ mod typescript;
#[exclude = "*.rs"]
struct LanguageDir;
#[derive(Deserialize)]
struct GithubRelease {
name: String,
assets: Vec<GithubReleaseAsset>,
}
#[derive(Deserialize)]
struct GithubReleaseAsset {
name: String,
browser_download_url: http::Url,
}
pub fn build_language_registry(login_shell_env_loaded: Task<()>) -> LanguageRegistry {
let languages = LanguageRegistry::new(login_shell_env_loaded);
for (name, grammar, lsp_adapter) in [