Expand description
Vim-mode editor engine built on top of hjkl_buffer.
Exposes an Editor that is fully toolkit-agnostic. Covers the bulk
of vim’s normal / insert / visual / visual-line / visual-block modes,
text-object operators, dot-repeat, and ex-command handling
(:s/foo/bar/g, :w, :q, :noh, …). Rendering goes through
hjkl_buffer::BufferView; selection / gutter highlights are painted in
the same single-pass as text. TUI/crossterm adapters live in the
hjkl-engine-tui companion crate.
Imported wholesale from sqeel-vim with full git history. The trait
extraction (Selection / SelectionSet / View + Host sub-traits) lands
progressively under crate::types. Pre-1.0 churn — the public surface
may change in patch bumps. See docs.rs for
the canonical API reference.
The legacy public surface is intentionally narrow:
Re-exports§
pub use input::Input;pub use input::Key;pub use input::decode_macro;pub use input::from_planned as decode_planned_input;pub use selection_shift::Sel;pub use selection_shift::shift_position;pub use selection_shift::shift_sel;pub use keymap_motion::MotionKind;pub use substitute::SubstError;pub use substitute::SubstFlags;pub use substitute::SubstituteCmd;pub use substitute::SubstituteMatch;pub use substitute::SubstituteOutcome;pub use substitute::apply_collected_matches;pub use substitute::apply_substitute;pub use substitute::collect_substitute_matches;pub use substitute::parse_substitute;pub use types::Attrs;pub use types::BufferEdit;pub use types::BufferId;pub use types::Color;pub use types::Cursor;pub use types::CursorShape;pub use types::DefaultHost;pub use types::EditorSnapshot;pub use types::EngineError;pub use types::FoldProvider;pub use types::Highlight;pub use types::HighlightKind;pub use types::Host;pub use types::Input as PlannedInput;pub use types::Mode;pub use types::Modifiers;pub use types::MouseEvent;pub use types::MouseKind;pub use types::NoopFoldProvider;pub use types::OptionValue;pub use types::Options;pub use types::Query;pub use types::RenderFrame;pub use types::Search;pub use types::Selection;pub use types::SelectionKind;pub use types::SelectionSet;pub use types::SnapshotMode;pub use types::SpecialKey;pub use types::Style;pub use types::View;pub use types::WrapMode;pub use abbrev::Abbrev;pub use abbrev::AbbrevTrigger;pub use search::SearchPrompt;pub use tag::matching_tag_pair;pub use types::InsertDir;pub use types::ScrollDir;
Modules§
- abbrev
- Engine-owned abbreviation types.
- buf_
helpers - Trait-surface cast helpers shared between [
crate::editor] and the discipline crates (hjkl-vim) that drive it. - input
- Backend-agnostic key input types used by the vim engine.
- keymap_
motion - motions
- Vim-shaped cursor motions, computed over the SPEC trait surface.
- rope_
util - Pure rope helpers — no editor, host, or vim state involved.
- search
- Engine-owned search state + execution helpers.
- selection_
shift - Keep selections valid across an edit (#63).
- substitute
- Public substitute command parser and applicator.
- tag
- HTML/XML tag matching — discipline-agnostic buffer substrate.
- types
- Core types for the engine trait surface.
Structs§
- Buffer
Fold Provider FoldProvideradapter wrapping a&hjkl_buffer::View. Lets engine call sites ask the buffer’s fold storage about visible rows without reaching intoView::next_visible_row&c. directly.- Buffer
Fold Provider Mut - Mutable
FoldProvideradapter wrapping a&mut hjkl_buffer::View. Engine call sites that need to dispatch aFoldOp(vim’sz…keystrokes, the:fold*Ex commands, edit-pipeline invalidation) construct this on the fly from&mut self.bufferand callFoldProvider::apply/FoldProvider::invalidate_rangeon it. - Change
Bank - Per-buffer changelist bank:
g;/g,history plus the'./`.“last change” mark. Shared viaArc<Mutex<ChangeBank>>across every window’sEditorviewing the SAME buffer — vim’s changelist and last-change mark are per-buffer, not per-window, so an edit made in one split must be visible tog;/`.from any other split on that buffer (audit B3). - Content
Edit - Engine-native representation of a single buffer mutation in the
shape tree-sitter’s
InputEditconsumes. Emitted byhjkl_engine::Editor::mutate_editand drained by hosts viahjkl_engine::Editor::take_content_editsso the syntax layer can fan edits into a retained tree without the engine taking a tree-sitter dependency. - Edit
- A pending or applied edit. Multi-cursor edits fan out to
Vec<EngineEdit>ordered in reverse byte offset so each entry’s positions remain valid after the prior entry applies. - Editor
- Insert
Session - Last
Visual - Saved visual-mode anchor + cursor for
gv(re-enters the last visual selection).modecarries which visual flavour to restore;anchor/cursormean different things per flavour: - NoDiscipline
- Default discipline for an
Editorthat has not had a real discipline installed: no FSM, always reportsCoarseMode::Normal. Editors that receive vim/vscode/etc. input install their discipline at construction (e.g.hjkl_vim::install_vim_discipline). - Pos
- Grapheme-indexed position.
lineis zero-based row;colis zero-based grapheme column within that line. - Registers
- Search
Bank - Session-global search state: the last committed
//?pattern, its direction, and the search-prompt history. Shared across every window’sEditorviaArc<Mutex<SearchBank>>— seeEditor::set_search_arc. - Settings
- Vim-style options surfaced by
:set. New fields land here as individual ex commands gain:setplumbing. - Slot
- Snapshot
Fold Provider - Owned-snapshot
FoldProvideradapter. Carries a copy of the buffer’s fold list (oneVec<Fold>clone — fold lists are tiny in practice) plus the buffer’srow_count, so the call site can hold the snapshot for fold queries while passing&mut hjkl_buffer::Viewto a motion function that needs cursor mutation. - Viewport
- Visible region of a buffer — the runtime viewport state the host owns and mutates per render frame.
Enums§
- Coarse
Mode - Discipline-agnostic coarse mode for app chrome (status badge, cursor
shape). Unlike
VimMode— which names vim-specific states —CoarseModeis a minimal projection: “are we inserting text, selecting, or idle?” - Cursor
Scroll Target - Where the cursor should land in the viewport after a
z-family scroll (zz/zt/zb). - FoldOp
- A fold operation dispatched by the engine’s
z…keystrokes,:fold*ex commands, and the edit-pipeline’s “edits inside a fold open it” invalidation. - FsmMode
- The FSM-internal mode discriminator used by
Editor::fsm_mode()andEditor::set_fsm_mode(). Re-exported asFsmModeto avoid clashing with thetypes::Modebuffer-side enum that is already exported asMode. - Insert
Entry - Insert
Reason - Last
Change - Information needed to replay a mutating change via
.. - LspIntent
- Host-observable LSP requests triggered by editor bindings. The
hjkl-engine crate doesn’t talk to an LSP itself — it just raises an
intent that the TUI layer picks up and routes to
sqls. - Mark
Jump - Return value from the engine’s
try_goto_mark_*methods. Tells the caller (app layer) whether a cross-buffer switch is required. - Motion
- Operator
- Pending
- Range
Kind - Classification determines how operators treat the range end.
- Undo
Granularity - Controls the granularity of per-insert-session undo steps.
- View
Mode - A read-only view layered over the real input
VimMode. Unlike a vim mode (which decides how keystrokes are interpreted), aViewModeonly changes what the buffer presents — input is still interpreted as Normal. - VimMode
- Coarse vim-mode a host app can display in its status line.
Traits§
- Discipline
State - Discipline-private FSM state, stored type-erased on the
Editor.
Type Aliases§
- Global
Marks - Uppercase (global) vim marks, keyed by
'A'–'Z'; values are(buffer_id, row, col). Shared across every window’sEditorviaArc<Mutex<GlobalMarks>>— seeEditor::set_global_marks_arc. Named so the app host can spell the shared-bank type without repeating the nested generic (mirrorscrate::Registers).