Skip to main content

Module context

Module context 

Source
Expand description

Structural context scopes and the resolver that turns them into the header lines a pane pins above its text.

A ContextScope is a structural range plus the line span that names it — impl Renderer for TuiRenderer { naming the impl block, fn paint(…) { naming the function. It is a pure function of the parse tree: no viewport, no cursor, no fold state, no user option. That is what makes it correct to compute once per parse (off-thread, in a plugin) and resolve against any anchor line afterwards.

resolve_context is the resolution half, and it lives here rather than in either renderer for the same reason IndentBlock::paints_on does: one implementation means a bug is a failing test here instead of a wrong strip in one peer and not the other. The host calls it when it publishes pane inputs, so the scroll model reserves exactly the rows that get painted.

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

Structs§

ContextOptions
The knobs resolve_context reads. Mirrors the context.* options the plugin registers; the host resolves them per buffer and passes them in, so this stays a pure function.
ContextScope
One structural scope: the range it spans, and the lines that name it.

Enums§

TrimScope
Which end of the stack to drop when there are more context rows than the budget allows.

Functions§

resolve_context
Resolve the context header lines for anchor.