Skip to main content

Crate hjkl_ex

Crate hjkl_ex 

Source
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§

expand

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.
HostRegistry
Registry of host-level ex commands, generic over an opaque context type.
LineRange
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.
CompletionKind
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. Ctx is opaque to hjkl-ex — apps/hjkl supplies its App type. Commands here can mutate any application state, not just the editor.

Functions§

all_setting_names
All :set option 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 line against 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 Registry seeded 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.