mirror of https://github.com/helix-editor/helix
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.2 KiB
Rust
42 lines
1.2 KiB
Rust
use helix_event::send_blocking;
|
|
use tokio::sync::mpsc::Sender;
|
|
|
|
use crate::handlers::lsp::SignatureHelpInvoked;
|
|
use crate::{DocumentId, Editor, ViewId};
|
|
|
|
pub mod dap;
|
|
pub mod lsp;
|
|
|
|
pub struct Handlers {
|
|
// only public because most of the actual implementation is in helix-term right now :/
|
|
pub completions: Sender<lsp::CompletionEvent>,
|
|
pub signature_hints: Sender<lsp::SignatureHelpEvent>,
|
|
}
|
|
|
|
impl Handlers {
|
|
/// Manually trigger completion (c-x)
|
|
pub fn trigger_completions(&self, trigger_pos: usize, doc: DocumentId, view: ViewId) {
|
|
send_blocking(
|
|
&self.completions,
|
|
lsp::CompletionEvent::ManualTrigger {
|
|
cursor: trigger_pos,
|
|
doc,
|
|
view,
|
|
},
|
|
);
|
|
}
|
|
|
|
pub fn trigger_signature_help(&self, invocation: SignatureHelpInvoked, editor: &Editor) {
|
|
let event = match invocation {
|
|
SignatureHelpInvoked::Automatic => {
|
|
if !editor.config().lsp.auto_signature_help {
|
|
return;
|
|
}
|
|
lsp::SignatureHelpEvent::Trigger
|
|
}
|
|
SignatureHelpInvoked::Manual => lsp::SignatureHelpEvent::Invoked,
|
|
};
|
|
send_blocking(&self.signature_hints, event)
|
|
}
|
|
}
|