summaryrefslogtreecommitdiff
path: root/helix-term/src/application.rs
diff options
context:
space:
mode:
Diffstat (limited to 'helix-term/src/application.rs')
-rw-r--r--helix-term/src/application.rs50
1 files changed, 42 insertions, 8 deletions
diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs
index 08853ed0..f06ccff2 100644
--- a/helix-term/src/application.rs
+++ b/helix-term/src/application.rs
@@ -2,11 +2,18 @@ use helix_core::syntax;
use helix_lsp::{lsp, LspProgressMap};
use helix_view::{document::Mode, theme, Document, Editor, Theme, View};
-use crate::{args::Args, compositor::Compositor, config::Config, keymap::Keymaps, ui};
+use crate::{
+ args::Args,
+ compositor::Compositor,
+ config::Config,
+ keymap::Keymaps,
+ ui::{self, Spinner},
+};
use log::{error, info};
use std::{
+ collections::HashMap,
future::Future,
io::{self, stdout, Stdout, Write},
path::PathBuf,
@@ -37,12 +44,13 @@ pub struct Application {
compositor: Compositor,
editor: Editor,
+ config: Config,
+
theme_loader: Arc<theme::Loader>,
syn_loader: Arc<syntax::Loader>,
- callbacks: LspCallbacks,
+ callbacks: LspCallbacks,
lsp_progress: LspProgressMap,
- lsp_progress_enabled: bool,
}
impl Application {
@@ -62,7 +70,7 @@ impl Application {
.as_deref()
.unwrap_or(include_bytes!("../../languages.toml"));
- let theme = if let Some(theme) = &config.global.theme {
+ let theme = if let Some(theme) = &config.theme {
match theme_loader.load(theme) {
Ok(theme) => theme,
Err(e) => {
@@ -79,7 +87,7 @@ impl Application {
let mut editor = Editor::new(size, theme_loader.clone(), syn_loader.clone());
- let mut editor_view = Box::new(ui::EditorView::new(config.keymaps));
+ let mut editor_view = Box::new(ui::EditorView::new(config.keymaps.clone()));
compositor.push(editor_view);
if !args.files.is_empty() {
@@ -108,11 +116,13 @@ impl Application {
compositor,
editor,
+ config,
+
theme_loader,
syn_loader,
+
callbacks: FuturesUnordered::new(),
lsp_progress: LspProgressMap::new(),
- lsp_progress_enabled: config.global.lsp_progress,
};
Ok(app)
@@ -198,6 +208,15 @@ impl Application {
server_id: usize,
) {
use helix_lsp::{Call, MethodCall, Notification};
+ let editor_view = self
+ .compositor
+ .find(std::any::type_name::<ui::EditorView>())
+ .expect("expected at least one EditorView");
+ let editor_view = editor_view
+ .as_any_mut()
+ .downcast_mut::<ui::EditorView>()
+ .unwrap();
+
match call {
Call::Notification(helix_lsp::jsonrpc::Notification { method, params, .. }) => {
let notification = match Notification::parse(&method, params) {
@@ -305,11 +324,18 @@ impl Application {
(None, message, &None)
} else {
self.lsp_progress.end_progress(server_id, &token);
+ if !self.lsp_progress.is_progressing(server_id) {
+ editor_view.spinners_mut().get_or_create(server_id).stop();
+ }
self.editor.clear_status();
+
+ // we want to render to clear any leftover spinners or messages
+ self.render();
return;
}
}
};
+
let token_d: &dyn std::fmt::Display = match &token {
lsp::NumberOrString::Number(n) => n,
lsp::NumberOrString::String(s) => s,
@@ -342,14 +368,17 @@ impl Application {
if let lsp::WorkDoneProgress::End(_) = work {
self.lsp_progress.end_progress(server_id, &token);
+ if !self.lsp_progress.is_progressing(server_id) {
+ editor_view.spinners_mut().get_or_create(server_id).stop();
+ }
} else {
self.lsp_progress.update(server_id, token, work);
}
- if self.lsp_progress_enabled {
+ if self.config.lsp.display_messages {
self.editor.set_status(status);
- self.render();
}
+ self.render();
}
_ => unreachable!(),
}
@@ -372,6 +401,11 @@ impl Application {
MethodCall::WorkDoneProgressCreate(params) => {
self.lsp_progress.create(server_id, params.token);
+ let spinner = editor_view.spinners_mut().get_or_create(server_id);
+ if spinner.is_stopped() {
+ spinner.start();
+ }
+
let doc = self.editor.documents().find(|doc| {
doc.language_server()
.map(|server| server.id() == server_id)