reovim_plugin_context/events.rs
1//! Context update events
2//!
3//! Events emitted by the `ContextPlugin` when context changes.
4//! Consumers subscribe to these events instead of polling `get_context()`.
5
6use reovim_core::{context_provider::ContextHierarchy, event_bus::Event};
7
8/// Emitted when cursor context changes
9///
10/// Statusline and other cursor-position-dependent UI should subscribe to this.
11#[derive(Debug, Clone)]
12pub struct CursorContextUpdated {
13 /// Buffer where cursor moved
14 pub buffer_id: usize,
15 /// Current cursor line (0-indexed)
16 pub line: u32,
17 /// Current cursor column (0-indexed)
18 pub col: u32,
19 /// New context hierarchy (None if no context at this position)
20 pub context: Option<ContextHierarchy>,
21}
22
23impl Event for CursorContextUpdated {
24 fn priority(&self) -> u32 {
25 100
26 }
27}
28
29/// Emitted when viewport context changes
30///
31/// Sticky context headers and other viewport-dependent UI should subscribe to this.
32#[derive(Debug, Clone)]
33pub struct ViewportContextUpdated {
34 /// Window that scrolled
35 pub window_id: usize,
36 /// Buffer being viewed
37 pub buffer_id: usize,
38 /// Top visible line (0-indexed)
39 pub top_line: u32,
40 /// New context hierarchy for the viewport (None if no context)
41 pub context: Option<ContextHierarchy>,
42}
43
44impl Event for ViewportContextUpdated {
45 fn priority(&self) -> u32 {
46 100
47 }
48}