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.
This commit is contained in:
parent
018081a5b1
commit
1ab35ade2d
4 changed files with 31 additions and 30 deletions
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
27
helix-view/src/handlers/completion.rs
Normal file
27
helix-view/src/handlers/completion.rs
Normal file
|
@ -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,
|
||||
}
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Reference in a new issue