aboutsummaryrefslogtreecommitdiff
path: root/helix-view/src/editor.rs
diff options
context:
space:
mode:
authorPascal Kuthe2023-11-30 23:03:27 +0000
committerBlaž Hrastnik2024-01-23 02:20:19 +0000
commit8e592a151fe7adfbf3fb35ae134b7f2a70700f09 (patch)
tree603a94042068620e52f50cb26cf881d5461d1c8d /helix-view/src/editor.rs
parent13ed4f6c4748019787d24c2b686d417b71604242 (diff)
refactor completion and signature help using hooks
Diffstat (limited to 'helix-view/src/editor.rs')
-rw-r--r--helix-view/src/editor.rs35
1 files changed, 18 insertions, 17 deletions
diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs
index 44c706d7..dc10a604 100644
--- a/helix-view/src/editor.rs
+++ b/helix-view/src/editor.rs
@@ -31,10 +31,7 @@ use std::{
};
use tokio::{
- sync::{
- mpsc::{unbounded_channel, UnboundedReceiver, UnboundedSender},
- oneshot,
- },
+ sync::mpsc::{unbounded_channel, UnboundedReceiver, UnboundedSender},
time::{sleep, Duration, Instant, Sleep},
};
@@ -244,12 +241,19 @@ pub struct Config {
/// Set a global text_width
pub text_width: usize,
/// Time in milliseconds since last keypress before idle timers trigger.
- /// Used for autocompletion, set to 0 for instant. Defaults to 250ms.
+ /// Used for various UI timeouts. Defaults to 250ms.
#[serde(
serialize_with = "serialize_duration_millis",
deserialize_with = "deserialize_duration_millis"
)]
pub idle_timeout: Duration,
+ /// Time in milliseconds after typing a word character before auto completions
+ /// are shown, set to 5 for instant. Defaults to 250ms.
+ #[serde(
+ serialize_with = "serialize_duration_millis",
+ deserialize_with = "deserialize_duration_millis"
+ )]
+ pub completion_timeout: Duration,
/// Whether to insert the completion suggestion on hover. Defaults to true.
pub preview_completion_insert: bool,
pub completion_trigger_len: u8,
@@ -829,6 +833,7 @@ impl Default for Config {
auto_format: true,
auto_save: false,
idle_timeout: Duration::from_millis(250),
+ completion_timeout: Duration::from_millis(250),
preview_completion_insert: true,
completion_trigger_len: 2,
auto_info: true,
@@ -953,14 +958,6 @@ pub struct Editor {
/// avoid calculating the cursor position multiple
/// times during rendering and should not be set by other functions.
pub cursor_cache: Cell<Option<Option<Position>>>,
- /// When a new completion request is sent to the server old
- /// unfinished request must be dropped. Each completion
- /// request is associated with a channel that cancels
- /// when the channel is dropped. That channel is stored
- /// here. When a new completion request is sent this
- /// field is set and any old requests are automatically
- /// canceled as a result
- pub completion_request_handle: Option<oneshot::Sender<()>>,
pub handlers: Handlers,
}
@@ -989,13 +986,16 @@ enum ThemeAction {
#[derive(Debug, Clone)]
pub enum CompleteAction {
+ Triggered,
+ /// A savepoint of the currently selected completion. The savepoint
+ /// MUST be restored before sending any event to the LSP
+ Selected {
+ savepoint: Arc<SavePoint>,
+ },
Applied {
trigger_offset: usize,
changes: Vec<Change>,
},
- /// A savepoint of the currently selected completion. The savepoint
- /// MUST be restored before sending any event to the LSP
- Selected { savepoint: Arc<SavePoint> },
}
#[derive(Debug, Copy, Clone)]
@@ -1029,6 +1029,7 @@ impl Editor {
theme_loader: Arc<theme::Loader>,
syn_loader: Arc<syntax::Loader>,
config: Arc<dyn DynAccess<Config>>,
+ handlers: Handlers,
) -> Self {
let language_servers = helix_lsp::Registry::new(syn_loader.clone());
let conf = config.load();
@@ -1073,7 +1074,7 @@ impl Editor {
config_events: unbounded_channel(),
needs_redraw: false,
cursor_cache: Cell::new(None),
- completion_request_handle: None,
+ handlers,
}
}