diff --git a/helix-term/src/handlers/completion.rs b/helix-term/src/handlers/completion.rs index 6f0b73d7c..4e03a0636 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 93336beb5..e2f95ded5 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, + pub completions: Sender, pub signature_hints: Sender, pub auto_save: Sender, } @@ -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 000000000..27ca1d715 --- /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 e76b4c633..39e7dba99 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,