Show message indicating when we're downloading language servers

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
Antonio Scandurra 2022-02-21 17:25:52 +01:00
parent d2c83a7097
commit aee479d615
16 changed files with 214 additions and 93 deletions

View file

@ -2,6 +2,7 @@ use anyhow::anyhow;
use async_compression::futures::bufread::GzipDecoder;
use client::http;
use futures::{future::BoxFuture, FutureExt, StreamExt};
use gpui::executor;
pub use language::*;
use lazy_static::lazy_static;
use regex::Regex;
@ -45,7 +46,7 @@ impl RustLsp {
.ok_or_else(|| anyhow!("no release found matching {:?}", release_name))?;
let destination_path = destination_dir_path.join(format!("rust-analyzer-{}", release.name));
if fs::metadata(&destination_path).await.is_ok() {
if fs::metadata(&destination_path).await.is_err() {
let response = client
.get(&asset.browser_download_url)
.send()
@ -195,10 +196,10 @@ impl LspExt for RustLsp {
}
}
pub fn build_language_registry() -> LanguageRegistry {
let mut languages = LanguageRegistry::default();
languages.add(Arc::new(rust()));
languages.add(Arc::new(markdown()));
pub fn build_language_registry(executor: &Arc<executor::Background>) -> LanguageRegistry {
let mut languages = LanguageRegistry::new();
languages.add(Arc::new(rust()), executor);
languages.add(Arc::new(markdown()), executor);
languages
}

View file

@ -39,7 +39,7 @@ fn main() {
},
);
let (settings_tx, settings) = postage::watch::channel_with(settings);
let languages = Arc::new(language::build_language_registry());
let languages = Arc::new(language::build_language_registry(&app.background()));
languages.set_theme(&settings.borrow().theme.editor.syntax);
app.run(move |cx| {

View file

@ -26,14 +26,17 @@ pub fn test_app_state(cx: &mut MutableAppContext) -> Arc<AppState> {
let client = Client::new(http.clone());
let user_store = cx.add_model(|cx| UserStore::new(client.clone(), http, cx));
let mut languages = LanguageRegistry::new();
languages.add(Arc::new(language::Language::new(
language::LanguageConfig {
name: "Rust".to_string(),
path_suffixes: vec!["rs".to_string()],
..Default::default()
},
Some(tree_sitter_rust::language()),
)));
languages.add(
Arc::new(language::Language::new(
language::LanguageConfig {
name: "Rust".to_string(),
path_suffixes: vec!["rs".to_string()],
..Default::default()
},
Some(tree_sitter_rust::language()),
)),
cx.background(),
);
Arc::new(AppState {
settings_tx: Arc::new(Mutex::new(settings_tx)),
settings,

View file

@ -97,11 +97,19 @@ pub fn build_workspace(
cx,
)
});
let lsp_status = cx.add_view(|cx| {
workspace::lsp_status::LspStatus::new(
app_state.languages.clone(),
app_state.settings.clone(),
cx,
)
});
let cursor_position =
cx.add_view(|_| editor::items::CursorPosition::new(app_state.settings.clone()));
workspace.status_bar().update(cx, |status_bar, cx| {
status_bar.add_left_item(diagnostic_summary, cx);
status_bar.add_left_item(diagnostic_message, cx);
status_bar.add_left_item(lsp_status, cx);
status_bar.add_right_item(cursor_position, cx);
});