1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//! Unified event type for the main loop.
//!
//! Terminal input and LSP reader threads both feed into a single
//! `mpsc::Sender<AppEvent>` so the main loop can block on one channel
//! and drain bursts of either kind.
use std::path::PathBuf;
use crossterm::event::Event;
use crate::finder::PreviewEntry;
use crate::lsp::{LspClient, LspEvent};
use crate::syntax::Highlighter;
pub enum AppEvent {
Term(Event),
Lsp(LspEvent),
/// A worker thread spawned by `open_path` finished building a
/// tree-sitter highlighter (grammar dlopen + query compile + initial
/// parse). `gen` is the generation the worker was spawned for — the
/// main loop drops the event when `app.open_gen != gen` so a stale
/// result from a previous file doesn't clobber the current buffer.
HighlighterReady {
generation: u64,
result: anyhow::Result<Highlighter>,
},
/// A worker thread finished spawning an LSP client and running its
/// `initialize` handshake. The main loop adopts the client and
/// fires `didOpen` with a fresh snapshot of the current buffer.
/// `client_key` is the per-server identifier (`"<lang>::<server>"`)
/// the coordinator stores the client under; one of these events is
/// emitted per `[[languages.<lang>.lsp]]` entry configured for the
/// opened file.
LspReady {
generation: u64,
client_key: String,
lang: String,
path: PathBuf,
result: anyhow::Result<LspClient>,
},
/// The fuzzy-finder preview worker finished building a highlighted
/// snapshot for a file. The main loop drops it into the preview LRU.
/// Stale results are kept anyway — the LRU is keyed by path, so a
/// late-arriving response just becomes a cheap cache entry for next
/// time the user navigates back to that file.
PreviewReady(PreviewEntry),
}