helix/helix-term/src/handlers.rs

54 lines
1.7 KiB
Rust
Raw Normal View History

2023-12-01 07:03:26 +08:00
use std::sync::Arc;
use arc_swap::ArcSwap;
2025-01-27 15:22:21 +08:00
use diagnostics::PullAllDocumentsDiagnosticHandler;
use helix_event::AsyncHook;
2023-12-01 07:03:26 +08:00
use crate::config::Config;
use crate::events;
use crate::handlers::auto_save::AutoSaveHandler;
2025-01-27 15:22:21 +08:00
use crate::handlers::diagnostics::PullDiagnosticsHandler;
use crate::handlers::signature_help::SignatureHelpHandler;
2023-12-01 07:03:26 +08:00
pub use helix_view::handlers::{word_index, Handlers};
use self::document_colors::DocumentColorsHandler;
mod auto_save;
pub mod completion;
2025-01-27 15:22:21 +08:00
pub mod diagnostics;
mod document_colors;
mod signature_help;
2024-03-04 06:23:34 +08:00
mod snippet;
2023-12-01 07:03:26 +08:00
pub fn setup(config: Arc<ArcSwap<Config>>) -> Handlers {
events::register();
let event_tx = completion::CompletionHandler::new(config).spawn();
let signature_hints = SignatureHelpHandler::new().spawn();
let auto_save = AutoSaveHandler::new().spawn();
let document_colors = DocumentColorsHandler::default().spawn();
let word_index = word_index::Handler::spawn();
2025-01-27 15:22:21 +08:00
let pull_diagnostics = PullDiagnosticsHandler::new().spawn();
let pull_all_documents_diagnostics = PullAllDocumentsDiagnosticHandler::new().spawn();
2023-12-01 07:03:26 +08:00
let handlers = Handlers {
completions: helix_view::handlers::completion::CompletionHandler::new(event_tx),
signature_hints,
auto_save,
document_colors,
word_index,
2025-01-27 15:22:21 +08:00
pull_diagnostics,
pull_all_documents_diagnostics,
2023-12-01 07:03:26 +08:00
};
helix_view::handlers::register_hooks(&handlers);
completion::register_hooks(&handlers);
signature_help::register_hooks(&handlers);
auto_save::register_hooks(&handlers);
diagnostics::register_hooks(&handlers);
2024-03-04 06:23:34 +08:00
snippet::register_hooks(&handlers);
document_colors::register_hooks(&handlers);
2023-12-01 07:03:26 +08:00
handlers
}