Expand description
Phase 2->3 ex-command parser.
Every :-line input becomes a CommandInvocation dispatched
through lattice_grammar::execute() (DESIGN.md §5.2.1). Two parse
shapes feed the same dispatcher:
- Keyword form (
:w foo.txt,:q!,:set number): split off the command word + optional bang, look up by alias in the registry, call the spec’sparse_args(rest, bang)to get typedArgs, build aCommandInvocation. - Delimiter form (
:s/.../.../,:%s/.../.../,:g/.../.../,:v/.../.../): the delimiter syntax doesn’t fit the keyword parse, so the front-end parses the body itself and produces anArgs::List([pattern, replacement, flags])for:substituteorArgs::List([pattern, inverted, body])for:global(DESIGN.md §B.1, §B.2). The same dispatcher then resolves the registered command id and runs the matching apply closure.
Structs§
- Command
Line Decorations - Live decorations for the
:line (MB.4): syntax spans, an optional validation error, and an optional parameter hint. - Command
Line Span - One highlighted span of the
:command line.rangeis a byte range into the line text (the:prompt is NOT included — spans are relative tocommand_line()). - Substitute
Partial - Result of a best-effort parse of an in-progress substitute
command line, used by the live-preview path
(
refresh_substitute_previewin App). Unlike the fulltry_parse_substitutepath, this never errors on incomplete input – a half-typed pattern or a missing second/is fine. ReturnsNoneonly when the input doesn’t look like a substitute at all.
Enums§
- ExCommand
Error - Substitute
Partial Scope - Vim’s
[%]s/pattern/replacement/[flags]. Produces a registered-invocation pointing atex:substitutewith the scope expressed viaRange::CurrentLine/Range::WholeandArgs::List([pattern, replacement, flags]). Scope (current line vs. whole buffer) detected on the partial or full:s/:%sform. Used by both the substitute parser and the live-preview parser below.
Functions§
- aliases
- Built-in aliases as a
(short, canonical)map. Exposed for tests and any future:describe-aliasesview. - command_
line_ decorations - Compute the live decorations for a
:command line (MB.4).lineis the text without the leading:(i.e.command_line()). Pure + cheap (one line, no I/O) so it runs on the actor thread each edit. - parse
- Parse a
:line into aCommandInvocationdispatchable through the unifiedgrammar::execute(). - preferred_
alias_ for - Reverse map of the alias table: for each canonical name, the
preferred user-facing alias (the longest one). Used by completion
to rewrite raw
gen:commandsoutput (which produces canonical names likeex:describe-command) into the form a user actually types (describe-command). - resolve_
command_ name_ or_ alias - Resolve a user-typed command spelling against the registry,
trying the canonical form first then falling back to the alias
table. Mirrors
parse’s two-stage resolution so introspection (:describe-command,:apropos) accepts both forms a user can type at:(canonicalex:writeor aliasw/write). - try_
parse_ substitute_ partial - Best-effort parse of a partial
:s/:%scommand line. Used by the live-preview path: as the user types, we want to highlight matches of the in-progress pattern even before the second/or closing/is typed. Backslash-escapes are honored the same waytry_parse_substitutehonors them, so a partial\/doesn’t flip the field state mid-stream.