Expand description
N.1.4c: structural (tree-sitter) text objects – the universal
af/if (function), ac/ic (class), aa/ia (parameter),
al/il (loop) grammar objects. They are first-class citizens of
Lattice’s vim grammar (compose with every operator: daf, vic,
yaa, and the zn narrow operator’s znaf), owned here in
lattice-syntax per the locked N.1 design.
Each object’s apply reads the cursor’s enclosing scope from
ctx.scope_resolver – the host threads the active buffer’s
SyntaxSnapshot (which impls [lattice_grammar::ScopeResolver],
N.1.4b) into the [lattice_grammar::registry::TextObjectContext] via
Document::dispatch_with_scope_resolver. The resolver returns the
byte-precise [start, end) span of the smallest matching
textobjects.scm capture (@function.outer, @loop.inner, …).
Graceful failure: with no resolver (a plain-language buffer with no
syntax tree) or no enclosing match (cursor outside any function /
class / …), apply returns an empty range at the cursor, so the
paired operator no-ops – matching vim, where daf with no enclosing
function does nothing.
Structs§
- Syntax
Text Object Ids - The eight structural text-object [
TextObjectId]s, returned byregister_syntax_text_objectsso the host can bind their chords (af/if/ac/ic/aa/ia/al/il) into the operator-pending and Visual text-object keymap tables (mirrors how the builtin objects’ ids driveregister_text_object_resolutions).
Functions§
- register_
syntax_ text_ objects - Register the eight structural text objects on
registry. Call once at boot (after the builtin grammar is registered); thread the returned ids into the keymap binder. Calling twice registers duplicates, so call exactly once.