Skip to main content

hjkl_vim/
motion.rs

1/// Cursor motion identity carried by the host keymap path.
2///
3/// Phase 3a introduces this enum so the `hjkl-vim` keymap can name motions
4/// without depending on engine internals. The host converts a `MotionKind` to
5/// the appropriate `Editor::apply_motion` call.
6///
7/// Designed for extensibility: Phases 3b–3g will add further variants
8/// (word motions, line-boundary motions, jump motions, scroll motions, …)
9/// without breaking any existing match arms — callers must use `..` or
10/// add the new arms when they bump the hjkl-vim minor version.
11#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
12#[non_exhaustive]
13pub enum MotionKind {
14    /// `h` / `<Backspace>` — move the cursor one character to the left.
15    /// Clamps at column 0 (no line-wrap), matching vim's normal-mode `h`.
16    CharLeft,
17    /// `l` / `<Space>` — move the cursor one character to the right.
18    /// Clamps at the last character of the line (no line-wrap), matching
19    /// vim's normal-mode `l`.
20    CharRight,
21    /// `j` — move the cursor one line down, restoring the sticky column.
22    LineDown,
23    /// `k` — move the cursor one line up, restoring the sticky column.
24    LineUp,
25    /// `+` / `<CR>` (not yet bound) — move down one line and land on the
26    /// first non-blank character. Sets the sticky column.
27    FirstNonBlankDown,
28    /// `-` — move up one line and land on the first non-blank character.
29    /// Sets the sticky column.
30    FirstNonBlankUp,
31    /// `w` — move the cursor forward to the start of the next small word.
32    /// Counts repeat the motion; wraps across lines matching vim's `w`.
33    WordForward,
34    /// `W` — move the cursor forward to the start of the next BIG word
35    /// (whitespace-delimited). Counts repeat; wraps across lines.
36    BigWordForward,
37    /// `b` — move the cursor backward to the start of the current or previous
38    /// small word. Counts repeat; wraps across lines matching vim's `b`.
39    WordBackward,
40    /// `B` — move the cursor backward to the start of the current or previous
41    /// BIG word (whitespace-delimited). Counts repeat; wraps across lines.
42    BigWordBackward,
43    /// `e` — move the cursor forward to the end of the current or next small
44    /// word. Counts repeat; wraps across lines matching vim's `e`.
45    WordEnd,
46    /// `E` — move the cursor forward to the end of the current or next BIG
47    /// word (whitespace-delimited). Counts repeat; wraps across lines.
48    BigWordEnd,
49}