Skip to main content

Module repl_mode

Module repl_mode 

Source
Expand description

repl-mode — a builtin minor mode contributing the REPL input surface.

The Normal-mode insert-entry keys (i/a/o/A/I/O) don’t insert in place: they move the caret to the buffer’s prompt (its last line) and enter Insert. That is the affordance a REPL-like buffer wants — the transcript above the prompt is read-only, so “start typing” should always land you at the prompt.

§Why a minor mode, not a major-mode keymap

This behaviour previously lived on ai-conversation-mode, a major mode, whose keymap overrides vim’s universal insert keys. A major-mode keymap is gated by the buffer’s active major (K.1.c), but binding the single most common Normal-mode keys there is fragile — any gap in that gating resurfaces them everywhere (the :describe-key i / dashboard-jumps-to-EOF saga).

Modelling the affordance as a Manual minor mode that each REPL major (ai-conversation, and later terminal / claude) pulls in via Mode::implies keeps it OFF every ordinary buffer (a regular i stays vim-native), reusable across REPLs, and rides the well-tested minor-mode keymap gating. The user is free to :set it on any buffer where it makes sense.

Structs§

ReplMode
repl-mode minor. A marker mode: it owns a keymap layer + one action handler, but allocates no per-buffer resources (Guard = ()).

Functions§

register_repl_mode
Register repl-mode against registry. Called from register_foundation_modes — it is a builtin, so there is no separate boot call.
register_repl_mode_actions
Register the action:repl-focus-input command so the mode’s keymap cmd name resolves at boot (the register_ai_conversation_actions pattern). The apply body is a dead Effect::None: the mode’s action_handlers closure intercepts before the grammar Action gate, so this never runs. It exists so the CommandId resolves for the chord binding + handler registration.