Skip to main content

Module modeline

Module modeline 

Source
Expand description

LSP modeline element (ML.3c) + the shared progress/status store it is built from. Produced entirely in lattice-lsp (the owner) and pushed over the event bus.

§Why a forwarder task + shared store here, not host accumulation

Decision (A): $/progress + experimental/serverStatus are LSP protocol state, so their accumulation belongs in lattice-lsp, not dispatch.rs. The LSP actor only parses and emits these as events (actor.rs); nothing accumulates them server-side. This module owns that accumulation in LspProgressStore (an ArcSwap-backed shared handle):

  • the forwarder task subscribes the relevant events, folds them into the store, and publishes [ModelineElementUpdate] for each LSP-attached buffer — exactly as a WASM plugin would (docs/dev/architecture/modeline.md §6). The host’s §12 wake forwarder turns each push into an off-keystroke repaint; no producer runs on the render path (paramount #1).
  • the host reads the same store (via the LspProgressStoreHandle it stashes at boot, the pattern it already uses for LspSupervisorHandle) for :lsp-progress-cancel, which needs the in-flight cancellable-token list. One accumulator, two readers — no duplication, and the accumulation logic + state are out of the host.

Per-buffer keying gates the badge to LSP buffers: content is pushed keyed Buffer(id) for each attached buffer (the badge is process-wide today, so every attached buffer gets the same value) and cleared on detach. A non-LSP pane has no lsp content and renders nothing.

Replaces the retired LspMode::status_line_items (badge) + LspProgressMode::status_line_items (progress) pull and the host-side drain_lsp_progress_events / drain_lsp_server_status accumulators.

Structs§

LspProgressStore
The relocated LSP progress/status accumulator (decision A). The LSP actor only emits $/progress / serverStatus as events; this is the single place they are folded into a queryable map. Two ArcSwaps for wait-free reads + lock-free single-writer (forwarder) updates, so the host can read Self::progress_snapshot from the actor thread for :lsp-progress-cancel while the off-actor forwarder writes.

Constants§

LSP_ELEMENT
Modeline element id for the LSP readiness badge + progress. Owned by lattice-lsp (feedback_mode_owns_its_surface).

Functions§

lsp_content
Build the lsp element content from progress + server-status maps. Always non-empty (the badge always shows on an attached buffer): lsp ✗ on any health error, lsp ⟳ while any server is busy / a $/progress token is in flight, else lsp ✓, with the highest-percentage in-flight token’s <title> NN% appended. Glyphs are BMP-safe (lsp-architecture.md §14). Pure — unit-tested.
register_lsp_modeline_element
Register the lsp descriptor (ML.3c). PaneLocal (content pushed per attached buffer), Right zone before core.position (priority 5).
spawn_modeline_forwarder
Spawn the LSP modeline forwarder (ML.3c). Subscribes the four event types, folds progress/status into the shared store, and republishes the lsp element content per attached buffer on every change. The host wires this at boot with the shared bus + the store handle it also keeps for :lsp-progress-cancel + the LSP runtime handle. A closed bus (all senders dropped) ends the task cleanly — never panics.

Type Aliases§

LspProgressStoreHandle
Shared handle to the LspProgressStore — the host stashes one at boot; the forwarder writes through its clone.