Skip to main content

Module command

Module command 

Source
Expand description

CommandInvocation – the unified call type that flows through the dispatcher (DESIGN.md §5.2.1).

Vim ex-syntax (the : parser front-end), keymap chord resolution, command palette selection, and plugin-to-plugin calls all produce values of this shape. The dispatcher’s execute() consumes them.

An invocation is plain data: Clone, serializable, and free of borrowed state, so it can be recorded (macros record invocations, not keystrokes), replayed (.), sent across the core protocol, or built by a plugin. It names its command by CommandId, which is only meaningful against the CommandRegistry that minted it.

§Examples

The slots of "a3dd (register a, count 3, the delete operator over the current line), filled by hand:

use lattice_grammar::{CommandInvocation, CommandRegistry, Count, Range, Register, builtins};

let mut registry = CommandRegistry::new();
let b = builtins::populate(&mut registry);

let inv = CommandInvocation::of(b.delete.0)
    .with_count(Count(3))
    .with_register(Register::Named('a'))
    .with_range(Range::CurrentLine);

assert_eq!(inv.count_or_default().get(), 3);
assert_eq!(inv.register_or_default(), Register::Named('a'));

// Unset slots fall back to vim's defaults.
let bare = CommandInvocation::of(b.delete.0);
assert_eq!(bare.count, None);
assert_eq!(bare.count_or_default(), Count::ONE);
assert_eq!(bare.register_or_default(), Register::Unnamed);

Structs§

CommandInvocation
One call of one command, with every grammar slot vim can fill: the unified call type every front-end produces and execute consumes (DESIGN.md §5.2.1).
CommandSpec
Metadata + the actual implementation of a registered command. Stored in the CommandRegistry.
Count
A vim count prefix: the 3 in 3dw or 3j. Each command decides what it multiplies; an absent count is Count::ONE (the Default), but CommandInvocation::count keeps None distinct so a command that cares (G vs 5G) can tell “no count” from “count 1”.

Enums§

CommandKind
What kind of command an entry in the registry is. Determines how the dispatcher resolves the invocation.
LatencyClass
How the runtime should schedule a command, and what budget the CI test harness will eventually enforce on it (DESIGN.md §5.2.5).

Functions§

kind_icon
Map a kind-label string to its display icon. Covers all labels emitted by KindLabelAnnotator and Introspectable::kind_label. Returns · for unknown labels.