Expand description
The grammar-extension boundary conversions (plugin-host.md §4.1, PH7.7a).
Mirrors the data a plugin authors against when it EXTENDS the vim grammar
via register_{motion,operator,text_object,ex_command,action}. The grammar
handling (dispatcher, parser, composition) stays native + sync + untouched
(PH7.7 fork, locked): a plugin only contributes entries; it never observes
or reimplements dispatch.
Two directions, matching the picker seam (boundary_picker.rs):
- Contexts are host→guest one-way projections of the dispatch
environment (
project_*free fns — the contexts carry&Buffer/&CancellationToken/Option<&dyn ScopeResolver>borrows, so they cannot round-trip; the guest never sends a context back). Bulk buffer text never rides a context — it crosses via thebufferdocumentresource handle (§4.2), so a projection reads only the owned scalars. - Results come back guest→host:
MotionResulthere; a text object returnsrange(NativeRange::from_wit), an operator/ex-command returnseffect(NativeEffect::from_wit),parse_argsreturnsargs(NativeArgs::from_wit) — all reusing the PH7.3b conversions.
The contribution spec records (motion-spec/…) mirror each native *Spec
with the apply / parse_args closure dropped — the behavior is a sync
guest export the host calls back by callback-id (PH7.7b/c), not a field that
crosses. Their scalar fields reuse the conversions this module adds
(LatencyClass, SurfaceForm) plus the existing ArgSpec mirror; the
WIT-record → native-*Spec direction is PH7.7c’s trampoline job (it needs
the callback closure), so no spec from_wit lands here.
Functions§
- project_
action_ context - Project an
ActionContext(host→guest). Thebufferfield is NOT projected here — it rides theborrow<document>handle the trampoline mints (AP.0.1), keeping bulk rope text off the boundary; only thecursorscalar crosses in the record. - project_
ex_ command_ context - Project an
ExCommandContext(host→guest). The nativerange: Option<grammar::Range>is absent — the recursive grammarRangecannot cross a WIT record (theGlobal/NarrowTriggerprecedent), so a v1 ex-command plugin getsbang/args/register/count. - project_
motion_ context - Project a live
MotionContextinto its owned WIT mirror (host→guest). Reads only the owned scalars —&Buffer,&CancellationToken, and the tree-sitterscope_resolverare host-owned and reached (if at all) through thedocumenthandle, never this record. - project_
operator_ context - Project an
OperatorContext(host→guest). The&mut Documentis not projected — mutation is the returnedeffect(§4.5). - project_
text_ object_ context - Project a
TextObjectContext(host→guest). The scope/comment env rides thedocumenthandle, not this record.