Show message indicating when we're downloading language servers
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
parent
d2c83a7097
commit
aee479d615
16 changed files with 214 additions and 93 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -5701,6 +5701,7 @@ dependencies = [
|
||||||
"client",
|
"client",
|
||||||
"clock",
|
"clock",
|
||||||
"collections",
|
"collections",
|
||||||
|
"futures",
|
||||||
"gpui",
|
"gpui",
|
||||||
"language",
|
"language",
|
||||||
"log",
|
"log",
|
||||||
|
|
|
@ -410,8 +410,6 @@ impl View for DiagnosticMessage {
|
||||||
diagnostic.message.split('\n').next().unwrap().to_string(),
|
diagnostic.message.split('\n').next().unwrap().to_string(),
|
||||||
theme.diagnostic_message.clone(),
|
theme.diagnostic_message.clone(),
|
||||||
)
|
)
|
||||||
.contained()
|
|
||||||
.with_margin_left(theme.item_spacing)
|
|
||||||
.boxed()
|
.boxed()
|
||||||
} else {
|
} else {
|
||||||
Empty::new().boxed()
|
Empty::new().boxed()
|
||||||
|
|
|
@ -12,10 +12,11 @@ use futures::{
|
||||||
future::{BoxFuture, Shared},
|
future::{BoxFuture, Shared},
|
||||||
FutureExt,
|
FutureExt,
|
||||||
};
|
};
|
||||||
use gpui::{AppContext, Task};
|
use gpui::{executor, AppContext, Task};
|
||||||
use highlight_map::HighlightMap;
|
use highlight_map::HighlightMap;
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
|
use postage::watch;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::{
|
use std::{
|
||||||
cell::RefCell,
|
cell::RefCell,
|
||||||
|
@ -127,18 +128,33 @@ pub struct Grammar {
|
||||||
pub(crate) highlight_map: Mutex<HighlightMap>,
|
pub(crate) highlight_map: Mutex<HighlightMap>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
|
||||||
pub struct LanguageRegistry {
|
pub struct LanguageRegistry {
|
||||||
languages: Vec<Arc<Language>>,
|
languages: Vec<Arc<Language>>,
|
||||||
|
pending_lsp_binaries_tx: Arc<Mutex<watch::Sender<usize>>>,
|
||||||
|
pending_lsp_binaries_rx: watch::Receiver<usize>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LanguageRegistry {
|
impl LanguageRegistry {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self::default()
|
let (pending_lsp_binaries_tx, pending_lsp_binaries_rx) = watch::channel();
|
||||||
|
Self {
|
||||||
|
languages: Default::default(),
|
||||||
|
pending_lsp_binaries_tx: Arc::new(Mutex::new(pending_lsp_binaries_tx)),
|
||||||
|
pending_lsp_binaries_rx,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add(&mut self, language: Arc<Language>) {
|
pub fn add(&mut self, language: Arc<Language>, cx: &executor::Background) {
|
||||||
self.languages.push(language);
|
self.languages.push(language.clone());
|
||||||
|
if let Some(lsp_binary_path) = language.lsp_binary_path() {
|
||||||
|
let pending_lsp_binaries_tx = self.pending_lsp_binaries_tx.clone();
|
||||||
|
cx.spawn(async move {
|
||||||
|
*pending_lsp_binaries_tx.lock().borrow_mut() += 1;
|
||||||
|
lsp_binary_path.await;
|
||||||
|
*pending_lsp_binaries_tx.lock().borrow_mut() -= 1;
|
||||||
|
})
|
||||||
|
.detach();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_theme(&self, theme: &SyntaxTheme) {
|
pub fn set_theme(&self, theme: &SyntaxTheme) {
|
||||||
|
@ -166,6 +182,10 @@ impl LanguageRegistry {
|
||||||
.any(|suffix| path_suffixes.contains(&Some(suffix.as_str())))
|
.any(|suffix| path_suffixes.contains(&Some(suffix.as_str())))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn pending_lsp_binaries(&self) -> watch::Receiver<usize> {
|
||||||
|
self.pending_lsp_binaries_rx.clone()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Language {
|
impl Language {
|
||||||
|
|
|
@ -22,28 +22,31 @@ fn init_logger() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[gpui::test]
|
||||||
fn test_select_language() {
|
fn test_select_language(cx: &mut MutableAppContext) {
|
||||||
let registry = LanguageRegistry {
|
let mut registry = LanguageRegistry::new();
|
||||||
languages: vec![
|
registry.add(
|
||||||
Arc::new(Language::new(
|
Arc::new(Language::new(
|
||||||
LanguageConfig {
|
LanguageConfig {
|
||||||
name: "Rust".to_string(),
|
name: "Rust".to_string(),
|
||||||
path_suffixes: vec!["rs".to_string()],
|
path_suffixes: vec!["rs".to_string()],
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
Some(tree_sitter_rust::language()),
|
Some(tree_sitter_rust::language()),
|
||||||
)),
|
)),
|
||||||
Arc::new(Language::new(
|
cx.background(),
|
||||||
LanguageConfig {
|
);
|
||||||
name: "Make".to_string(),
|
registry.add(
|
||||||
path_suffixes: vec!["Makefile".to_string(), "mk".to_string()],
|
Arc::new(Language::new(
|
||||||
..Default::default()
|
LanguageConfig {
|
||||||
},
|
name: "Make".to_string(),
|
||||||
Some(tree_sitter_rust::language()),
|
path_suffixes: vec!["Makefile".to_string(), "mk".to_string()],
|
||||||
)),
|
..Default::default()
|
||||||
],
|
},
|
||||||
};
|
Some(tree_sitter_rust::language()),
|
||||||
|
)),
|
||||||
|
cx.background(),
|
||||||
|
);
|
||||||
|
|
||||||
// matching file extension
|
// matching file extension
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|
|
@ -3069,8 +3069,10 @@ mod tests {
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
let project = Project::test(fs, &mut cx);
|
let project = Project::test(fs, &mut cx);
|
||||||
project.update(&mut cx, |project, _| {
|
project.update(&mut cx, |project, cx| {
|
||||||
Arc::get_mut(&mut project.languages).unwrap().add(language);
|
Arc::get_mut(&mut project.languages)
|
||||||
|
.unwrap()
|
||||||
|
.add(language, cx.background());
|
||||||
});
|
});
|
||||||
|
|
||||||
let (tree, _) = project
|
let (tree, _) = project
|
||||||
|
@ -3215,8 +3217,10 @@ mod tests {
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
let project = Project::test(fs, &mut cx);
|
let project = Project::test(fs, &mut cx);
|
||||||
project.update(&mut cx, |project, _| {
|
project.update(&mut cx, |project, cx| {
|
||||||
Arc::get_mut(&mut project.languages).unwrap().add(language);
|
Arc::get_mut(&mut project.languages)
|
||||||
|
.unwrap()
|
||||||
|
.add(language, cx.background());
|
||||||
});
|
});
|
||||||
|
|
||||||
let (tree, _) = project
|
let (tree, _) = project
|
||||||
|
@ -4108,8 +4112,10 @@ mod tests {
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
let project = Project::test(fs.clone(), &mut cx);
|
let project = Project::test(fs.clone(), &mut cx);
|
||||||
project.update(&mut cx, |project, _| {
|
project.update(&mut cx, |project, cx| {
|
||||||
Arc::get_mut(&mut project.languages).unwrap().add(language);
|
Arc::get_mut(&mut project.languages)
|
||||||
|
.unwrap()
|
||||||
|
.add(language, cx.background());
|
||||||
});
|
});
|
||||||
|
|
||||||
let (tree, _) = project
|
let (tree, _) = project
|
||||||
|
|
|
@ -2001,9 +2001,8 @@ mod tests {
|
||||||
|
|
||||||
// Set up a fake language server.
|
// Set up a fake language server.
|
||||||
let (language_server_config, mut fake_language_servers) = LanguageServerConfig::fake();
|
let (language_server_config, mut fake_language_servers) = LanguageServerConfig::fake();
|
||||||
Arc::get_mut(&mut lang_registry)
|
Arc::get_mut(&mut lang_registry).unwrap().add(
|
||||||
.unwrap()
|
Arc::new(Language::new(
|
||||||
.add(Arc::new(Language::new(
|
|
||||||
LanguageConfig {
|
LanguageConfig {
|
||||||
name: "Rust".to_string(),
|
name: "Rust".to_string(),
|
||||||
path_suffixes: vec!["rs".to_string()],
|
path_suffixes: vec!["rs".to_string()],
|
||||||
|
@ -2011,7 +2010,9 @@ mod tests {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
Some(tree_sitter_rust::language()),
|
Some(tree_sitter_rust::language()),
|
||||||
)));
|
)),
|
||||||
|
&cx_a.background(),
|
||||||
|
);
|
||||||
|
|
||||||
// Connect to a server as 2 clients.
|
// Connect to a server as 2 clients.
|
||||||
let mut server = TestServer::start(cx_a.foreground(), cx_a.background()).await;
|
let mut server = TestServer::start(cx_a.foreground(), cx_a.background()).await;
|
||||||
|
@ -2232,9 +2233,8 @@ mod tests {
|
||||||
}),
|
}),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
Arc::get_mut(&mut lang_registry)
|
Arc::get_mut(&mut lang_registry).unwrap().add(
|
||||||
.unwrap()
|
Arc::new(Language::new(
|
||||||
.add(Arc::new(Language::new(
|
|
||||||
LanguageConfig {
|
LanguageConfig {
|
||||||
name: "Rust".to_string(),
|
name: "Rust".to_string(),
|
||||||
path_suffixes: vec!["rs".to_string()],
|
path_suffixes: vec!["rs".to_string()],
|
||||||
|
@ -2242,7 +2242,9 @@ mod tests {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
Some(tree_sitter_rust::language()),
|
Some(tree_sitter_rust::language()),
|
||||||
)));
|
)),
|
||||||
|
&cx_a.background(),
|
||||||
|
);
|
||||||
|
|
||||||
// Connect to a server as 2 clients.
|
// Connect to a server as 2 clients.
|
||||||
let mut server = TestServer::start(cx_a.foreground(), cx_a.background()).await;
|
let mut server = TestServer::start(cx_a.foreground(), cx_a.background()).await;
|
||||||
|
@ -2434,9 +2436,8 @@ mod tests {
|
||||||
|
|
||||||
// Set up a fake language server.
|
// Set up a fake language server.
|
||||||
let (language_server_config, mut fake_language_servers) = LanguageServerConfig::fake();
|
let (language_server_config, mut fake_language_servers) = LanguageServerConfig::fake();
|
||||||
Arc::get_mut(&mut lang_registry)
|
Arc::get_mut(&mut lang_registry).unwrap().add(
|
||||||
.unwrap()
|
Arc::new(Language::new(
|
||||||
.add(Arc::new(Language::new(
|
|
||||||
LanguageConfig {
|
LanguageConfig {
|
||||||
name: "Rust".to_string(),
|
name: "Rust".to_string(),
|
||||||
path_suffixes: vec!["rs".to_string()],
|
path_suffixes: vec!["rs".to_string()],
|
||||||
|
@ -2444,7 +2445,9 @@ mod tests {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
Some(tree_sitter_rust::language()),
|
Some(tree_sitter_rust::language()),
|
||||||
)));
|
)),
|
||||||
|
&cx_a.background(),
|
||||||
|
);
|
||||||
|
|
||||||
// Connect to a server as 2 clients.
|
// Connect to a server as 2 clients.
|
||||||
let mut server = TestServer::start(cx_a.foreground(), cx_a.background()).await;
|
let mut server = TestServer::start(cx_a.foreground(), cx_a.background()).await;
|
||||||
|
@ -2551,9 +2554,8 @@ mod tests {
|
||||||
|
|
||||||
// Set up a fake language server.
|
// Set up a fake language server.
|
||||||
let (language_server_config, mut fake_language_servers) = LanguageServerConfig::fake();
|
let (language_server_config, mut fake_language_servers) = LanguageServerConfig::fake();
|
||||||
Arc::get_mut(&mut lang_registry)
|
Arc::get_mut(&mut lang_registry).unwrap().add(
|
||||||
.unwrap()
|
Arc::new(Language::new(
|
||||||
.add(Arc::new(Language::new(
|
|
||||||
LanguageConfig {
|
LanguageConfig {
|
||||||
name: "Rust".to_string(),
|
name: "Rust".to_string(),
|
||||||
path_suffixes: vec!["rs".to_string()],
|
path_suffixes: vec!["rs".to_string()],
|
||||||
|
@ -2561,7 +2563,9 @@ mod tests {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
Some(tree_sitter_rust::language()),
|
Some(tree_sitter_rust::language()),
|
||||||
)));
|
)),
|
||||||
|
&cx_a.background(),
|
||||||
|
);
|
||||||
|
|
||||||
// Connect to a server as 2 clients.
|
// Connect to a server as 2 clients.
|
||||||
let mut server = TestServer::start(cx_a.foreground(), cx_a.background()).await;
|
let mut server = TestServer::start(cx_a.foreground(), cx_a.background()).await;
|
||||||
|
@ -2699,9 +2703,8 @@ mod tests {
|
||||||
// Set up a fake language server.
|
// Set up a fake language server.
|
||||||
let (language_server_config, mut fake_language_servers) = LanguageServerConfig::fake();
|
let (language_server_config, mut fake_language_servers) = LanguageServerConfig::fake();
|
||||||
|
|
||||||
Arc::get_mut(&mut lang_registry)
|
Arc::get_mut(&mut lang_registry).unwrap().add(
|
||||||
.unwrap()
|
Arc::new(Language::new(
|
||||||
.add(Arc::new(Language::new(
|
|
||||||
LanguageConfig {
|
LanguageConfig {
|
||||||
name: "Rust".to_string(),
|
name: "Rust".to_string(),
|
||||||
path_suffixes: vec!["rs".to_string()],
|
path_suffixes: vec!["rs".to_string()],
|
||||||
|
@ -2709,7 +2712,9 @@ mod tests {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
Some(tree_sitter_rust::language()),
|
Some(tree_sitter_rust::language()),
|
||||||
)));
|
)),
|
||||||
|
&cx_a.background(),
|
||||||
|
);
|
||||||
|
|
||||||
// Connect to a server as 2 clients.
|
// Connect to a server as 2 clients.
|
||||||
let mut server = TestServer::start(cx_a.foreground(), cx_a.background()).await;
|
let mut server = TestServer::start(cx_a.foreground(), cx_a.background()).await;
|
||||||
|
@ -2800,9 +2805,8 @@ mod tests {
|
||||||
|
|
||||||
// Set up a fake language server.
|
// Set up a fake language server.
|
||||||
let (language_server_config, mut fake_language_servers) = LanguageServerConfig::fake();
|
let (language_server_config, mut fake_language_servers) = LanguageServerConfig::fake();
|
||||||
Arc::get_mut(&mut lang_registry)
|
Arc::get_mut(&mut lang_registry).unwrap().add(
|
||||||
.unwrap()
|
Arc::new(Language::new(
|
||||||
.add(Arc::new(Language::new(
|
|
||||||
LanguageConfig {
|
LanguageConfig {
|
||||||
name: "Rust".to_string(),
|
name: "Rust".to_string(),
|
||||||
path_suffixes: vec!["rs".to_string()],
|
path_suffixes: vec!["rs".to_string()],
|
||||||
|
@ -2810,7 +2814,9 @@ mod tests {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
Some(tree_sitter_rust::language()),
|
Some(tree_sitter_rust::language()),
|
||||||
)));
|
)),
|
||||||
|
&cx_a.background(),
|
||||||
|
);
|
||||||
|
|
||||||
// Connect to a server as 2 clients.
|
// Connect to a server as 2 clients.
|
||||||
let mut server = TestServer::start(cx_a.foreground(), cx_a.background()).await;
|
let mut server = TestServer::start(cx_a.foreground(), cx_a.background()).await;
|
||||||
|
@ -3039,9 +3045,8 @@ mod tests {
|
||||||
|
|
||||||
// Set up a fake language server.
|
// Set up a fake language server.
|
||||||
let (language_server_config, mut fake_language_servers) = LanguageServerConfig::fake();
|
let (language_server_config, mut fake_language_servers) = LanguageServerConfig::fake();
|
||||||
Arc::get_mut(&mut lang_registry)
|
Arc::get_mut(&mut lang_registry).unwrap().add(
|
||||||
.unwrap()
|
Arc::new(Language::new(
|
||||||
.add(Arc::new(Language::new(
|
|
||||||
LanguageConfig {
|
LanguageConfig {
|
||||||
name: "Rust".to_string(),
|
name: "Rust".to_string(),
|
||||||
path_suffixes: vec!["rs".to_string()],
|
path_suffixes: vec!["rs".to_string()],
|
||||||
|
@ -3049,7 +3054,9 @@ mod tests {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
Some(tree_sitter_rust::language()),
|
Some(tree_sitter_rust::language()),
|
||||||
)));
|
)),
|
||||||
|
&cx_a.background(),
|
||||||
|
);
|
||||||
|
|
||||||
// Connect to a server as 2 clients.
|
// Connect to a server as 2 clients.
|
||||||
let mut server = TestServer::start(cx_a.foreground(), cx_a.background()).await;
|
let mut server = TestServer::start(cx_a.foreground(), cx_a.background()).await;
|
||||||
|
@ -3845,9 +3852,8 @@ mod tests {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
Arc::get_mut(&mut host_lang_registry)
|
Arc::get_mut(&mut host_lang_registry).unwrap().add(
|
||||||
.unwrap()
|
Arc::new(Language::new(
|
||||||
.add(Arc::new(Language::new(
|
|
||||||
LanguageConfig {
|
LanguageConfig {
|
||||||
name: "Rust".to_string(),
|
name: "Rust".to_string(),
|
||||||
path_suffixes: vec!["rs".to_string()],
|
path_suffixes: vec!["rs".to_string()],
|
||||||
|
@ -3855,7 +3861,9 @@ mod tests {
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
None,
|
None,
|
||||||
)));
|
)),
|
||||||
|
&cx.background(),
|
||||||
|
);
|
||||||
|
|
||||||
let fs = FakeFs::new(cx.background());
|
let fs = FakeFs::new(cx.background());
|
||||||
fs.insert_tree(
|
fs.insert_tree(
|
||||||
|
|
|
@ -141,6 +141,7 @@ pub struct StatusBar {
|
||||||
pub item_spacing: f32,
|
pub item_spacing: f32,
|
||||||
pub cursor_position: TextStyle,
|
pub cursor_position: TextStyle,
|
||||||
pub diagnostic_message: TextStyle,
|
pub diagnostic_message: TextStyle,
|
||||||
|
pub lsp_message: TextStyle,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Default)]
|
#[derive(Deserialize, Default)]
|
||||||
|
|
|
@ -19,6 +19,7 @@ project = { path = "../project" }
|
||||||
theme = { path = "../theme" }
|
theme = { path = "../theme" }
|
||||||
util = { path = "../util" }
|
util = { path = "../util" }
|
||||||
anyhow = "1.0.38"
|
anyhow = "1.0.38"
|
||||||
|
futures = "0.3"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
parking_lot = "0.11.1"
|
parking_lot = "0.11.1"
|
||||||
postage = { version = "0.4.1", features = ["futures-traits"] }
|
postage = { version = "0.4.1", features = ["futures-traits"] }
|
||||||
|
|
65
crates/workspace/src/lsp_status.rs
Normal file
65
crates/workspace/src/lsp_status.rs
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
use crate::{ItemViewHandle, Settings, StatusItemView};
|
||||||
|
use futures::StreamExt;
|
||||||
|
use gpui::{elements::*, Entity, RenderContext, View, ViewContext};
|
||||||
|
use language::LanguageRegistry;
|
||||||
|
use postage::watch;
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
pub struct LspStatus {
|
||||||
|
pending_lsp_binaries: usize,
|
||||||
|
settings_rx: watch::Receiver<Settings>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl LspStatus {
|
||||||
|
pub fn new(
|
||||||
|
languages: Arc<LanguageRegistry>,
|
||||||
|
settings_rx: watch::Receiver<Settings>,
|
||||||
|
cx: &mut ViewContext<Self>,
|
||||||
|
) -> Self {
|
||||||
|
let mut pending_lsp_binaries = languages.pending_lsp_binaries();
|
||||||
|
cx.spawn_weak(|this, mut cx| async move {
|
||||||
|
while let Some(pending_lsp_binaries) = pending_lsp_binaries.next().await {
|
||||||
|
if let Some(this) = this.upgrade(&cx) {
|
||||||
|
this.update(&mut cx, |this, cx| {
|
||||||
|
this.pending_lsp_binaries = pending_lsp_binaries;
|
||||||
|
cx.notify();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.detach();
|
||||||
|
Self {
|
||||||
|
pending_lsp_binaries: 0,
|
||||||
|
settings_rx,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Entity for LspStatus {
|
||||||
|
type Event = ();
|
||||||
|
}
|
||||||
|
|
||||||
|
impl View for LspStatus {
|
||||||
|
fn ui_name() -> &'static str {
|
||||||
|
"LspStatus"
|
||||||
|
}
|
||||||
|
|
||||||
|
fn render(&mut self, _: &mut RenderContext<Self>) -> ElementBox {
|
||||||
|
if self.pending_lsp_binaries == 0 {
|
||||||
|
Empty::new().boxed()
|
||||||
|
} else {
|
||||||
|
let theme = &self.settings_rx.borrow().theme;
|
||||||
|
Label::new(
|
||||||
|
"Downloading language servers...".to_string(),
|
||||||
|
theme.workspace.status_bar.lsp_message.clone(),
|
||||||
|
)
|
||||||
|
.boxed()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl StatusItemView for LspStatus {
|
||||||
|
fn set_active_pane_item(&mut self, _: Option<&dyn ItemViewHandle>, _: &mut ViewContext<Self>) {}
|
||||||
|
}
|
|
@ -42,17 +42,21 @@ impl View for StatusBar {
|
||||||
fn render(&mut self, _: &mut RenderContext<Self>) -> ElementBox {
|
fn render(&mut self, _: &mut RenderContext<Self>) -> ElementBox {
|
||||||
let theme = &self.settings.borrow().theme.workspace.status_bar;
|
let theme = &self.settings.borrow().theme.workspace.status_bar;
|
||||||
Flex::row()
|
Flex::row()
|
||||||
.with_children(
|
.with_children(self.left_items.iter().map(|i| {
|
||||||
self.left_items
|
ChildView::new(i.as_ref())
|
||||||
.iter()
|
.aligned()
|
||||||
.map(|i| ChildView::new(i.as_ref()).aligned().boxed()),
|
.contained()
|
||||||
)
|
.with_margin_right(theme.item_spacing)
|
||||||
|
.boxed()
|
||||||
|
}))
|
||||||
.with_child(Empty::new().flexible(1., true).boxed())
|
.with_child(Empty::new().flexible(1., true).boxed())
|
||||||
.with_children(
|
.with_children(self.right_items.iter().map(|i| {
|
||||||
self.right_items
|
ChildView::new(i.as_ref())
|
||||||
.iter()
|
.aligned()
|
||||||
.map(|i| ChildView::new(i.as_ref()).aligned().boxed()),
|
.contained()
|
||||||
)
|
.with_margin_left(theme.item_spacing)
|
||||||
|
.boxed()
|
||||||
|
}))
|
||||||
.contained()
|
.contained()
|
||||||
.with_style(theme.container)
|
.with_style(theme.container)
|
||||||
.constrained()
|
.constrained()
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
pub mod lsp_status;
|
||||||
pub mod menu;
|
pub mod menu;
|
||||||
pub mod pane;
|
pub mod pane;
|
||||||
pub mod pane_group;
|
pub mod pane_group;
|
||||||
|
|
|
@ -77,9 +77,10 @@ border = { width = 1, color = "$border.0", left = true }
|
||||||
[workspace.status_bar]
|
[workspace.status_bar]
|
||||||
padding = { left = 6, right = 6 }
|
padding = { left = 6, right = 6 }
|
||||||
height = 24
|
height = 24
|
||||||
item_spacing = 24
|
item_spacing = 8
|
||||||
cursor_position = "$text.2"
|
cursor_position = "$text.2"
|
||||||
diagnostic_message = "$text.2"
|
diagnostic_message = "$text.2"
|
||||||
|
lsp_message = "$text.2"
|
||||||
|
|
||||||
[workspace.toolbar]
|
[workspace.toolbar]
|
||||||
height = 44
|
height = 44
|
||||||
|
@ -188,7 +189,7 @@ corner_radius = 6
|
||||||
|
|
||||||
[project_panel]
|
[project_panel]
|
||||||
extends = "$panel"
|
extends = "$panel"
|
||||||
padding.top = 6 # ($workspace.tab.height - $project_panel.entry.height) / 2
|
padding.top = 6 # ($workspace.tab.height - $project_panel.entry.height) / 2
|
||||||
|
|
||||||
[project_panel.entry]
|
[project_panel.entry]
|
||||||
text = "$text.1"
|
text = "$text.1"
|
||||||
|
|
|
@ -2,6 +2,7 @@ use anyhow::anyhow;
|
||||||
use async_compression::futures::bufread::GzipDecoder;
|
use async_compression::futures::bufread::GzipDecoder;
|
||||||
use client::http;
|
use client::http;
|
||||||
use futures::{future::BoxFuture, FutureExt, StreamExt};
|
use futures::{future::BoxFuture, FutureExt, StreamExt};
|
||||||
|
use gpui::executor;
|
||||||
pub use language::*;
|
pub use language::*;
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
@ -45,7 +46,7 @@ impl RustLsp {
|
||||||
.ok_or_else(|| anyhow!("no release found matching {:?}", release_name))?;
|
.ok_or_else(|| anyhow!("no release found matching {:?}", release_name))?;
|
||||||
|
|
||||||
let destination_path = destination_dir_path.join(format!("rust-analyzer-{}", 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
|
let response = client
|
||||||
.get(&asset.browser_download_url)
|
.get(&asset.browser_download_url)
|
||||||
.send()
|
.send()
|
||||||
|
@ -195,10 +196,10 @@ impl LspExt for RustLsp {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn build_language_registry() -> LanguageRegistry {
|
pub fn build_language_registry(executor: &Arc<executor::Background>) -> LanguageRegistry {
|
||||||
let mut languages = LanguageRegistry::default();
|
let mut languages = LanguageRegistry::new();
|
||||||
languages.add(Arc::new(rust()));
|
languages.add(Arc::new(rust()), executor);
|
||||||
languages.add(Arc::new(markdown()));
|
languages.add(Arc::new(markdown()), executor);
|
||||||
languages
|
languages
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ fn main() {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
let (settings_tx, settings) = postage::watch::channel_with(settings);
|
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);
|
languages.set_theme(&settings.borrow().theme.editor.syntax);
|
||||||
|
|
||||||
app.run(move |cx| {
|
app.run(move |cx| {
|
||||||
|
|
|
@ -26,14 +26,17 @@ pub fn test_app_state(cx: &mut MutableAppContext) -> Arc<AppState> {
|
||||||
let client = Client::new(http.clone());
|
let client = Client::new(http.clone());
|
||||||
let user_store = cx.add_model(|cx| UserStore::new(client.clone(), http, cx));
|
let user_store = cx.add_model(|cx| UserStore::new(client.clone(), http, cx));
|
||||||
let mut languages = LanguageRegistry::new();
|
let mut languages = LanguageRegistry::new();
|
||||||
languages.add(Arc::new(language::Language::new(
|
languages.add(
|
||||||
language::LanguageConfig {
|
Arc::new(language::Language::new(
|
||||||
name: "Rust".to_string(),
|
language::LanguageConfig {
|
||||||
path_suffixes: vec!["rs".to_string()],
|
name: "Rust".to_string(),
|
||||||
..Default::default()
|
path_suffixes: vec!["rs".to_string()],
|
||||||
},
|
..Default::default()
|
||||||
Some(tree_sitter_rust::language()),
|
},
|
||||||
)));
|
Some(tree_sitter_rust::language()),
|
||||||
|
)),
|
||||||
|
cx.background(),
|
||||||
|
);
|
||||||
Arc::new(AppState {
|
Arc::new(AppState {
|
||||||
settings_tx: Arc::new(Mutex::new(settings_tx)),
|
settings_tx: Arc::new(Mutex::new(settings_tx)),
|
||||||
settings,
|
settings,
|
||||||
|
|
|
@ -97,11 +97,19 @@ pub fn build_workspace(
|
||||||
cx,
|
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 =
|
let cursor_position =
|
||||||
cx.add_view(|_| editor::items::CursorPosition::new(app_state.settings.clone()));
|
cx.add_view(|_| editor::items::CursorPosition::new(app_state.settings.clone()));
|
||||||
workspace.status_bar().update(cx, |status_bar, cx| {
|
workspace.status_bar().update(cx, |status_bar, cx| {
|
||||||
status_bar.add_left_item(diagnostic_summary, cx);
|
status_bar.add_left_item(diagnostic_summary, cx);
|
||||||
status_bar.add_left_item(diagnostic_message, 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);
|
status_bar.add_right_item(cursor_position, cx);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue