Skip to main content

Module context_source

Module context_source 

Source
Expand description

The native seam for an async producer of structural context scopes (TC.2).

The tree-sitter-context analogue of AsyncGutterDecorationSource: the host drives it OFF the render path on a trigger (a completed reparse), caches the returned scopes per buffer, and every later read is native. The renderer never touches a producer.

The trait lives here rather than in lattice-plugin-host for the reason the decoration one does: lattice-mode and the renderers must stay free of any wasmtime dependency, so the loader hands a trait object across the seam. The single implementor today is the plugin host’s WasmContextSource.

Why scopes and not rows. A [ContextScope] is a pure function of the parse tree — no viewport, no cursor, no options — so the host can cache the set per parse version and answer “which apply to THIS pane right now” itself with resolve_context. A producer that returned finished rows would have to be re-driven on every scroll and cursor move, which is a WASM call on the keystroke path (paramount #1) and a cache that thrashes by construction.

Design anchor: docs/dev/architecture/treesitter-context.md.

Structs§

ContextSourceRegistry
Runtime-mutable registry of AsyncContextSources.

Traits§

AsyncContextSource
An async, off-render-path producer of a buffer’s structural context scopes.

Type Aliases§

ContextFuture
The boxed future an AsyncContextSource::produce returns.
ContextSourceRegistryHandle
Boot-service handle: Arc<ArcSwap<…>> so the loader RCU-registers producers at runtime while the host reads wait-free. Register and look up with this exact alias (the ServiceRegistry TypeId rule).