Skip to content

Milestone 2: the Vim engine - #2

Merged
y0sif merged 16 commits into
mainfrom
feat/m2-engine
Oct 12, 2026
Merged

y0sif merged 16 commits into
mainfrom
feat/m2-engine

Conversation

@y0sif

@y0sif y0sif commented Oct 12, 2026

Copy link
Copy Markdown
Owner

What

  • Engine (lawh-core): modes (Normal, Visual, Insert, block-Normal, command line), counts, grid and object cursor, d y p, undo and redo, . and @:, and : commands for shapes, text, math, files and :set.
  • Text and math blocks: Vim editing inside them, moving and deleting by grapheme.
  • Key maps: the map/noremap families, <Leader>, mapping timeouts, and lawhrc read from the config dir.
  • Overlay (lawh-render): cursor, selection, caret, status line and command line.
  • App: keys go to the engine; atomic :w; click to select; the view follows the cursor; a warning before closing with unsaved changes.
  • Caps: a work budget per key (MAX_KEY_WORK), at most 4 writes per key, and limits on undo history and mappings.
  • Docs: docs/keys.md, the architecture, testing and security docs, and M2 measurements.

Result

examples/area.lawh is built from 62 keys (crates/lawh-core/tests/acceptance.rs).

Checks

  • Locally: fmt, clippy -D warnings, 669 tests, the Rust 1.95 check and cargo-deny all pass.
  • Tested by hand on Linux (Hyprland, Wayland). Not tried on macOS or Windows.

🤖 Generated with Claude Code

y0sif and others added 16 commits October 11, 2026 21:27
Vim key notation parser, Board remove/insert_at/replace, and an engine
with a grid cursor, counts, the : line with :ci, and undo/redo.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Object motions (w, b, HJKL), operators and the unnamed register, put
with the place-below rule, Visual selection, . and @:, every shape
command, write and quit effects, and an undo property test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Insert mode and a small Normal mode inside blocks, stepping by
grapheme, the escape setting, and the acceptance test: 62 keys build
examples/area.lawh from an empty board. The label moves to (1,-1),
where the key path lands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
map/noremap in every mode with Vim's typeahead model, timeouts as an
effect, :set escape/leader/timeoutlen, and Engine::source for a lawhrc
that warns per line. examples/lawhrc mirrors a jkl; setup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
render_with draws the grid cursor, the current object, the Visual
rectangle and selection, the text caret (a math block being edited
shows its source) and a status bar with the command line. The renderer
also measures objects for the engine, finds carets and hit-tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
winit keys become engine keys (typed character plus modifiers, AltGr
never a chord), the overlay and status line are drawn every frame, :w
writes atomically, mapping timeouts use a deadline, the view follows
the cursor, a click selects, missing and unnamed files open as new
boards, lawhrc loads from the config dir, and the math worker logs to
stderr.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Stop . when its insert is refused, bound the keys one typed key may set
off (MAX_EXPANDED_KEYS) and index the maps, keep Insert motions local
to their line, count flat boxes in the place rule, treat Shift with
Esc/CR/BS/Del as the plain key, compare write paths with dots worked
out, and add gg/G plus Engine::go_first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Hit-test shapes by their geometry and prefer the smallest hit, route
Cmd+Q on macOS through the unsaved-changes check, keep permissions and
follow symlinks in atomic writes and sync the directory, start the
cursor on the first object and open the board above the status bar.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- MAX_KEY_WORK caps the work one typed key may cause; counts stop on no-op.
- Board::apply batches a step's changes and rebuilds the index once (undo, redo, deletes, puts).
- Backward text motions cache grapheme starts instead of rescanning the line.
- Adding or dropping the empty block bumps the board version.
- Pending writes are a bounded queue (MAX_PENDING_WRITES) matched by path.
- Document the worst-case lawhrc load time next to MAX_MAPS.
- Super+Q closes the window on macOS only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… budget

- MAX_WRITES_PER_KEY (4): a fifth write in one key is refused and stops the key;
  :wq/:x past the cap do not quit. MAX_PENDING_WRITES now equals it.
- The app serializes the board once per batch of effects and writes each file once,
  still reporting every write in order.
- A Visual motion cut short by the work budget keeps the selection matching its rectangle.
- Rewrap doc comments past 100 columns; fix the pending-writes doc.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Within one key, an info message no longer replaces an error; a later error still
replaces any message, so the message says why a key was cut short.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- New docs/keys.md (key and command reference) and docs/research/m2-measurements.md.
- architecture.md: key-press data flow, the engine, the settled cursor design, text editing.
- CLAUDE.md, README.md, SECURITY.md, testing.md, tech-stack.md, CONTRIBUTING.md updated.
- examples/lawhrc commented.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Correct :wq/:x/:x! and :li descriptions, derived vs measured numbers, moved file
references; list the board property tests, per-key caps for mappings, and click
behaviour in block-Normal mode.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- An unnamed board takes its name when the write is reported as done, so a failed
  :w name leaves it unnamed. A later :w in the same key goes to the pending name.
- A leading ~ in a :w path is the home directory (etcetera); ~user is left as typed.
- The close warning is armed only while it is on the status line, so a click or a
  timeout disarms it like a key does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Linux runner ran out of disk during `cargo test --workspace` on PR #2: full
debug info for every test binary no longer fits. Line tables keep file and line
numbers in backtraces.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LbT1KUQukgkZNgWh8f8U7i
@y0sif
y0sif merged commit a6c36eb into main Oct 12, 2026
4 checks passed
@y0sif
y0sif deleted the feat/m2-engine branch October 25, 2026 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant