Unnamed repository; edit this file 'description' to name the repository.
minor: Move `CompletionEvent` to a new completion handler module
Completions are not specific to LSP anymore. In the child commits we
will expand on the types in this module so this refactor is done
eagerly to minimize changes later.
| -rw-r--r-- | helix-term/src/handlers/completion.rs | 2 | ||||
| -rw-r--r-- | helix-view/src/handlers.rs | 5 | ||||
| -rw-r--r-- | helix-view/src/handlers/completion.rs | 27 | ||||
| -rw-r--r-- | helix-view/src/handlers/lsp.rs | 27 |
4 files changed, 31 insertions, 30 deletions
diff --git a/helix-term/src/handlers/completion.rs b/helix-term/src/handlers/completion.rs index 6f0b73d7..4e03a063 100644 --- a/helix-term/src/handlers/completion.rs +++ b/helix-term/src/handlers/completion.rs @@ -12,7 +12,7 @@ use helix_lsp::lsp; use helix_lsp::util::pos_to_lsp_pos; use helix_stdx::rope::RopeSliceExt; use helix_view::document::{Mode, SavePoint}; -use helix_view::handlers::lsp::CompletionEvent; +use helix_view::handlers::completion::CompletionEvent; use helix_view::{DocumentId, Editor, ViewId}; use path::path_completion; use tokio::sync::mpsc::Sender; diff --git a/helix-view/src/handlers.rs b/helix-view/src/handlers.rs index 93336beb..e2f95ded 100644 --- a/helix-view/src/handlers.rs +++ b/helix-view/src/handlers.rs @@ -4,6 +4,7 @@ use tokio::sync::mpsc::Sender; use crate::handlers::lsp::SignatureHelpInvoked; use crate::{DocumentId, Editor, ViewId}; +pub mod completion; pub mod dap; pub mod diagnostics; pub mod lsp; @@ -16,7 +17,7 @@ pub enum AutoSaveEvent { pub struct Handlers { // only public because most of the actual implementation is in helix-term right now :/ - pub completions: Sender<lsp::CompletionEvent>, + pub completions: Sender<completion::CompletionEvent>, pub signature_hints: Sender<lsp::SignatureHelpEvent>, pub auto_save: Sender<AutoSaveEvent>, } @@ -26,7 +27,7 @@ impl Handlers { pub fn trigger_completions(&self, trigger_pos: usize, doc: DocumentId, view: ViewId) { send_blocking( &self.completions, - lsp::CompletionEvent::ManualTrigger { + completion::CompletionEvent::ManualTrigger { cursor: trigger_pos, doc, view, diff --git a/helix-view/src/handlers/completion.rs b/helix-view/src/handlers/completion.rs new file mode 100644 index 00000000..27ca1d71 --- /dev/null +++ b/helix-view/src/handlers/completion.rs @@ -0,0 +1,27 @@ +use crate::{DocumentId, ViewId}; + +pub enum CompletionEvent { + /// Auto completion was triggered by typing a word char + AutoTrigger { + cursor: usize, + doc: DocumentId, + view: ViewId, + }, + /// Auto completion was triggered by typing a trigger char + /// specified by the LSP + TriggerChar { + cursor: usize, + doc: DocumentId, + view: ViewId, + }, + /// A completion was manually requested (c-x) + ManualTrigger { + cursor: usize, + doc: DocumentId, + view: ViewId, + }, + /// Some text was deleted and the cursor is now at `pos` + DeleteText { cursor: usize }, + /// Invalidate the current auto completion trigger + Cancel, +} diff --git a/helix-view/src/handlers/lsp.rs b/helix-view/src/handlers/lsp.rs index e76b4c63..39e7dba9 100644 --- a/helix-view/src/handlers/lsp.rs +++ b/helix-view/src/handlers/lsp.rs @@ -2,37 +2,10 @@ use std::fmt::Display; use crate::editor::Action; use crate::Editor; -use crate::{DocumentId, ViewId}; use helix_core::Uri; use helix_lsp::util::generate_transaction_from_edits; use helix_lsp::{lsp, OffsetEncoding}; -pub enum CompletionEvent { - /// Auto completion was triggered by typing a word char - AutoTrigger { - cursor: usize, - doc: DocumentId, - view: ViewId, - }, - /// Auto completion was triggered by typing a trigger char - /// specified by the LSP - TriggerChar { - cursor: usize, - doc: DocumentId, - view: ViewId, - }, - /// A completion was manually requested (c-x) - ManualTrigger { - cursor: usize, - doc: DocumentId, - view: ViewId, - }, - /// Some text was deleted and the cursor is now at `pos` - DeleteText { cursor: usize }, - /// Invalidate the current auto completion trigger - Cancel, -} - #[derive(Debug, PartialEq, Eq, Clone, Copy)] pub enum SignatureHelpInvoked { Automatic, |