Expand description
Ex-command registry and dispatch layer for the hjkl editor stack.
Phase 1: provides an extensible Registry and a minimal set of
built-in commands (:q, :q!). Additional commands migrate in
subsequent phases.
Phase 2a: adds range parsing infrastructure and migrates the no-arg /
no-range terminal commands (:w, :wq, :x, :wa, :wqa, :noh,
:undo, :redo, :qall, :qall!, :wqall, :wqall!).
Re-exports§
pub use expand::ExpandContext;pub use expand::expand_args;pub use expand::expand_filename;
Modules§
Structs§
- ArgSources
- Sources for arg completion. Caller fills the slots applicable to their context. None means “no candidates” — completer returns empty.
- Completions
- Completion candidates for an input line at a given caret offset.
- ExCommand
- A single registered ex command.
- Host
Registry - Registry of host-level ex commands, generic over an opaque context type.
- Line
Range - A parsed line range. 1-based, inclusive.
- Registry
- Registry of ex commands for a concrete host type
H.
Enums§
- ArgKind
- The kinds of argument an ex command accepts.
- Completion
Kind - What kind of token is being completed. Phase 5a only emits
Command; Phase 6 adds Path/Setting/Buffer/Register/Mark for arg completion. - ExEffect
- Describes what the caller should do after an ex command runs.
Traits§
- HostCmd
- Application-side ex command.
Ctxis opaque to hjkl-ex —apps/hjklsupplies itsApptype. Commands here can mutate any application state, not just the editor.
Functions§
- all_
setting_ names - All
:setoption names and their short aliases. - collect_
host_ registry_ names - Same for HostRegistry.
- collect_
registry_ names - Collect command-name candidates (canonical name + aliases) from a Registry.
- complete
- High-level orchestrator: resolve the command name in
lineagainst both registries, then dispatch to arg completer or command-name completer. - complete_
arg - Per-arg-kind completion. Caller resolves the command and passes its arg_kind. Returns empty Completions when caret isn’t in arg position, or when no sources match.
- complete_
command_ from_ names - Complete a partial command name at the given caret position from a flat
list of candidate names. The line may contain a leading range prefix
(
5,10,%, etc.) — those are NOT consumed here; the caller must pass the substring after any range. Phase 6 generalizes this for arg completion. - default_
registry - Build a
Registryseeded with the Phase 1 + Phase 2a default commands. - first_
word_ end - Returns
(end_byte_offset_of_command_token, did_find_space_after). - longest_
common_ prefix - Compute the longest common prefix of a non-empty slice of strings. Returns “” when the slice is empty or the LCP is empty.
- parse_
range - Parse a leading range prefix from
cmd. Supports: - try_
dispatch - Try to dispatch
input(without the leading:) through the registry. - try_
dispatch_ host - Try to dispatch
input(without the leading:) through a host registry.