Skip to content

Archived documentation. This historical release predates the Cobalt rename. Its executable, configuration paths and package names use the former product name. For current Cobalt usage, consult the latest release. Current Cobalt documentation.

Editor reference

Detailed keybindings, editing semantics, workspace behavior, and development checks for Ches.

Startup defaults

ches PATH starts with the Vim Classic (vim-classic) colour scheme in Zen: the document retains its frame, while status and supporting workspace tiles are suppressed. This is separate from borderless Bare mode.

  • Space v z toggles Zen/Workspace; --workspace starts directly in Workspace.
  • --bare (alias --superzen) starts borderless and takes priority over the Zen default and --workspace. Space v B toggles Bare; startup Bare returns to Workspace when disabled.
  • --theme NAME overrides Vim Classic; Space v T changes themes during use.
  • Tile hotkey hints, including those in Tile Terms, are hidden by default. In editor Normal mode, Space v ? toggles them for the session.

Floating terminal

The floating-terminal system is called Tile Terms. In Normal or Insert mode, press Space /, or choose Toggle Tile Term in the command palette. Ches lazily starts an interactive $SHELL (falling back to /bin/sh) inside a real pseudo-terminal. Its initial directory is the current file's parent, or the focused directory browser's directory. Changing files afterwards does not change the running shell's directory; use cd in the shell.

Numbered terminal sessions

Prefix the toggle with a positive count to choose a separate cached terminal:

  • 3 Space / opens terminal 3; 4 Space / opens terminal 4.
  • Uncounted Space / toggles the most recently selected terminal (initially 1).
  • Selecting the already-visible number hides it. Selecting a different number switches directly to that terminal in the same floating window.
  • These toggles work directly in editor and terminal Insert mode, as well as Normal mode and terminal Visual mode; no preliminary jk is needed.

Each terminal has its own shell PID, environment, working directory, jobs, screen, exit status, and preferred size. It starts only on first opening, in the then-current file/browser directory; explicit shell restarts reuse that initial directory. Numbers are sparse identifiers, so opening terminal 4 does not launch 1–3. The window title shows Tile Term N.

Hidden terminals stay running and continue consuming output without taking focus. Reopening a live terminal enters Insert; an exited terminal retains its final screen until Normal r restarts that terminal alone. All terminals are retained for the current Ches session and cleaned up when Ches exits; they are not restored across editor restarts.

The terminal floats over the existing workspace, including bare and zen modes. It initially prefers a 132×40 outer frame and shrinks to fit. Its shell receives the actual content dimensions. If fewer than 20 columns or 6 rows are available, Ches refuses to open it, or hides an already-open terminal. The shell keeps running while hidden and continues consuming output; reopen with Space / after making room.

The floating terminal has its own Insert, Normal, and Visual modes, independent of the document's mode. Opening or reopening a live shell starts in Insert.

Universal toggle timing

In editor Insert and terminal Insert, Ches recognizes Space / and N Space / with a 200 ms window between each successive key. A gap of 200 ms or more ends recognition. Normal/Visual mode keeps its usual untimed leader/count bindings.

This requires a short typeahead delay for Space and potential number prefixes:

  • A standalone Space or positive number is delivered after 200 ms of inactivity.
  • A key that cannot continue the shortcut flushes the held text immediately, in order, before processing that key normally.
  • A fast successful shortcut consumes the entire sequence. It does not insert spaces, digits, or / into the document or shell.
  • Type Space, pause at least 200 ms, then / to enter literal /. Bracketed clipboard paste always bypasses recognition, including pasted 2 / or jk.
  • Numbers start at 1; a standalone 0 remains ordinary text. Multi-digit IDs work as long as each key arrives within the window and the number fits an integer.

Toggling from editor Insert preserves that mode: hiding the terminal returns you to typing in the original document. Switching terminal numbers routes pending text to its original owner, never to the newly selected shell. If the original buffer/session loses ownership before replay, the prefix is canceled rather than redirected. The timeout runs even when cursor animation is disabled.

Terminal size preferences

Ches retains a requested outer size for each numbered terminal in the current editor session, separately from the size that fits on screen. This is ordinary UI state, not a separate daemon or an on-disk preference. It survives hide/reopen, shell restart, file changes, and temporary screen-size clamps, but resets when Ches itself exits. Size commands affect the currently selected terminal, including while it is hidden. New terminal numbers start with their own default 132×40 preference.

Context Keys Action
Terminal Normal/Visual + or = Grow by 10 columns and 2 rows
Terminal Normal/Visual - Shrink by 10 columns and 2 rows
Terminal Normal/Visual Space t r Reset requested size to 132×40
Editor Normal Space t + / Space t - Grow/shrink terminal preference, even while hidden
Editor Normal Space t r Reset terminal size

Counts multiply the adjustment: terminal Normal 3+ grows by 30 columns and 6 rows; editor 3 Space t + does the same. The palette also offers Grow Tile Term, Shrink Tile Term, and Reset Tile Term size.

Visible size changes take effect immediately and resize the child PTY. Hidden changes apply when reopening. Requested size is bounded to 20×6–1000×500 and is clamped to available screen space when displayed. Growing beyond the current screen still changes the preference: enlarging the outer terminal later reveals the requested size. Resizing in inspection preserves the frozen screen/selection; i resumes the latest resized live grid.

Terminal Insert mode

Keys go to the shell, including Escape, Ctrl-\, Tab, Shift-Tab, arrows, navigation/function keys, Ctrl-C, Ctrl-D, and Ctrl-Z. Escape remains available to nested terminal applications. Rapid Space / and N Space / toggle/select terminals directly, using the 200 ms matching window. Ctrl-C interrupts the foreground job normally.

Type jk within 150 ms to enter terminal Normal mode. Neither character is sent to the shell. A standalone j is held for up to 150 ms, then delivered even if no more input arrives. A different next key flushes j before that key; slower jk reaches the shell normally. Clipboard paste bypasses this shortcut, so pasted jk remains literal text.

Alternatively, press Ctrl-Space to enter terminal Normal mode. Ctrl-@ is equivalent on terminals that encode it as NUL. This freezes the visible screen for inspection; the PTY keeps consuming output and the shell keeps running.

Clipboard paste supports Unicode, tabs, and line breaks and uses bracketed paste when the application requests it. Other control characters are filtered. Pastes exceeding roughly 1 MiB are dropped as a whole; interrupted pastes are drained without inserting their remainder into the editor.

Terminal Normal and Visual modes

Keys Action
h / j / k / l, or arrows Move the inspection cursor
w / b, 0 / $, gg / G Word, line, and screen navigation; counts supported
v / V / Ctrl-v Characterwise / linewise / rectangular Visual selection
o in Visual Swap selection endpoints
y in Visual Yank selection to Ches's unnamed register and system clipboard
yy in Normal Yank the current terminal row
Escape Cancel selection or pending input, staying in terminal Normal
Ctrl-Space Cancel selection and return to terminal Normal
i / a Resume Insert and display the latest live screen
Space / Hide the terminal and restore the previous available editor/view focus
+ / = / - Grow/shrink terminal size; counts supported
Space t r Reset terminal size to 132×40
r after shell exit/failure Start a fresh shell

Selection is read-only and cannot change shell output or the edited document. After hiding, use the editor's p / P to paste a yank. Characterwise, linewise, and block yanks retain their kind; linewise copies include the terminal row's padding spaces. Wide glyphs and combining marks are copied as whole characters. Normal/Visual paste is swallowed rather than executed in the shell.

Inspection covers the screen captured when entering Normal mode, without scrollback history. New output does not move the inspection cursor or change the selected text. Resize clips the frozen grid around the cursor; returning to Insert shows the latest resized live grid. The footer indicates the terminal-local mode. Hotkey hints are hidden by default; toggle Space v ? in the editor before opening a Tile Term to show its key guidance. Mode, exit status, and errors remain visible with hints off, and hiding hints does not change PTY dimensions.

Hiding and reopening preserves the shell PID, environment, jobs, and screen. When the shell exits, Ches retains its final screen and displays its exit status in terminal Normal mode. Press r to start a fresh shell after exit or startup failure. Reopening an exited terminal alone does not restart it. Quitting Ches shuts down the terminal session and reaps its shell, escalating if children do not exit.

The implementation is Linux-only, with multiple cached numbered sessions and one visible floating terminal at a time. It supports UTF-8, wide/combining characters, ANSI/256/RGB colours, common text attributes, and alternate screens through vendored libvterm 0.3.3, advertising TERM=xterm-256color. There is no terminal scrollback browser, mouse forwarding, docking, or shell-session restoration across editor restarts. Use a program's own scrolling or a shell multiplexer when needed.

For a real-frontend check after building, run:

dune build -j 12 @scripts/smoke-embedded-terminal

This uses a private tmux server to check key delivery, persistent shell state, paste, resize, interrupt, exit/restart, child cleanup, and outer-terminal recovery. Backend details and focused checks are in terminal/README.md.

Keys

Mode Keys Action
Normal h j k l Move left, down, up, right; with a count, e.g. 20j, that many
Normal w / b / e Next word start / previous word start / word end
Normal W / B / E The same for blank-separated words
Normal 0 / ^ / $ Line start / first non-blank / line end
Normal _ / g_ First / last non-blank; with a count N, of the line N-1 below
Normal gg / G First / last line, or line N with a count (20G)
Normal % Matching (), [], or {} (see Matching delimiters)
Normal ]n / [n Next / previous conflict region (see Conflict markers); with a count N, the Nth (3]n)
Normal Space x u / l / a / b Keep the upper (ours) / lower (theirs) / both / base side of the conflict at the cursor
Normal f / F / t / T + character Find character forward/backward, on/before it
Normal ; / , Repeat the last find / repeat it in the opposite direction
Normal / / ? then text and Enter Search forward / backward (literal, case-sensitive)
Normal n / N Repeat the last search / repeat it in the opposite direction
Normal * / # Search the small word under the cursor forward / backward
Normal i / a Insert before / after the character under the cursor
Normal I / A Insert at the first non-blank / end of the line
Normal o / O Open a new line below / above, indented like this one
Normal >> / << Shift current line right / left; a count selects lines (3>>)
Normal d{motion}, dd, D Delete by motion, whole line(s), or through line end
Normal diw Delete the small word under the cursor
Normal x / X Delete character(s) under / before the cursor
Normal y{motion} / yy Yank by motion / whole line(s)
Normal p / P Paste the unnamed register after / before the cursor or line
Normal v / V / Ctrl-v Start characterwise / linewise / blockwise Visual selection
Normal Space v e Cycle retained problem details
Normal Space v b Show/hide the read-only bottom problems preview
Normal Space v f Switch problems preview between workspace/current document
Normal Space v o Show/focus problems, or return to the document
Normal Space v d / Space v D Show/hide, or show/focus, the static demo report (--demo-report only)
Normal Space v m / Space v M Show/hide, or show/focus, the notification history
Normal Space g g / Space g f Open the VCS view as a tab, or focus it where it is; from the focused view, back to the editor (see VCS view)
Normal Space g t / Space g s / Space g h Move the VCS view to a tab / the split, or close it
Normal Space g c / Space g a In a commit message opened from the VCS view (c): commit it / abort it
Normal Space g l Show the current file's history in the VCS view, opening and focusing it (see Browsing history)
Normal Space v R / Space v K Restart the diagnostic source (ocamllsp, slang-server, or --synthetic-checker), or crash the synthetic one (provisional keys)
Normal Space l i Open live Language servers status; also search lsp in the palette
Normal (file) K Hover: show server-provided type/documentation information
Normal (file) gd / gD Go to declaration/interface / definition/source, with capability-aware fallback
Normal (file) gr Find references, including declarations, in a searchable result picker
Normal/Insert (file) Ctrl-k Manually request signature help; automatic help is independently configurable
Normal (file) Ctrl-o / Ctrl-i Jump back / forward through symbol-navigation history
Normal (file) Tab Jump forward alias for terminals that encode Ctrl-i as Tab
Normal :e! then Enter Discard buffer changes and force-reload the file
Normal Ctrl-e / Ctrl-y Scroll the view down / up a line, or N with a count
Normal Ctrl-d / Ctrl-u Scroll view and cursor down / up half a screen, or N lines
Normal zz / zt / zb Put the cursor line at the middle / top / bottom of the view
Normal u / Ctrl-r Undo / redo
Normal Space w Save focused file / apply focused directory edits
Normal Space o Show file's parent in the main area (regardless of prior sidebar placement) / return to file
Normal Enter / - / Space r (directory) Open cursor entry / parent / refresh clean listing
Normal Space b n / Space b p Next / previous file tab (wraps)
Normal Space b c / Space b C Close tab / force-close and discard retained text
Normal Space b r Recreate missing file exclusively from retained text
Normal Space b t / Space b s Show file buffers in the top strip / as passive status rows
Normal/Visual Space m m/s/u/c/o (directory) Toggle mark / mark / unmark selection / clear marks / open marked files
Normal/Visual Space d m/s/h/f Major / side / hide / focus browser or editor
Normal/Visual Space d + / Space d - Grow / shrink side width by four columns; a count repeats (3 Space d +)
Normal/Visual Tab (side directory) Return focus to editor (Insert Tab edits normally)
Visual Enter (directory) Open files in intersected rows
Normal Space q Quit; refused for dirty/missing files and hidden dirty directories
Normal Space Q Quit, discarding unsaved changes
Normal Space v c Toggle the centered tile / full width
Normal Space v h / Space v l Move the tile 2 cells left / right; a count repeats (3 Space v l is 6)
Normal Space v H / Space v L Move the tile 10 cells left / right; a count repeats
Normal Space v - / Space v + (or =) Text width 10 cells narrower / wider; a count repeats (3 Space v + is 30)
Normal Space v n Toggle absolute line numbers (Vim's number)
Normal Space v N Toggle relative line numbers (Vim's relativenumber)
Normal Space v s Toggle the animated smear cursor (off by default; launch with --smear to opt in)
Normal Space v ? Show/hide tile hotkey hints (hidden by default)
Normal Space v t Show/hide the status cell (shown by default)
Normal Space v p h/l/k/j Place status left/right/above/below and show it
Normal Space v p -/+ Shrink/grow requested status size by 2 cells (= aliases +); a count repeats
Normal Space v z Toggle zen: hide status temporarily, retaining compact feedback
Normal Space v B Toggle bare mode: borderless full-width document and quiet feedback
Normal Space v T Open the live theme chooser (also Choose theme in the palette)
Normal Space v r Reset workspace document placement; in bare, reset only its line numbers to off
Normal Space c c Open the command palette (see Command palette)
Normal/Insert / Terminal modes Space / Toggle the persistent floating terminal; timed in Insert (see Floating terminal)
Normal/Insert / Terminal modes N Space / Select/open cached terminal N; uncounted toggle uses the last selected
Terminal Insert Rapid jk or Ctrl-Space Enter terminal Normal mode
Normal Space t + / Space t - / Space t r Grow / shrink / reset terminal size, even while hidden
Terminal Normal/Visual Space / Hide terminal, keeping its shell alive
Terminal Normal/Visual i / a Resume shell input
Terminal Normal/Visual v / V / Ctrl-v, then motions and y Select and yank terminal text
Terminal Normal r Restart an exited or failed shell
Normal Space f l Fuzzy search current-document lines (including unsaved edits)
Normal Space f f Find project files; open/activate retained buffers
Normal Space f g Search project contents on disk; validate and jump
Normal Escape Cancel pending input; when idle, clear search highlights and acknowledge the presented problem
Visual motions, %, ]n / [n Extend the selection
Visual v / V / Ctrl-v Switch the selection's kind, preserving its anchor
Visual d / c / y Delete / change / yank the selected range
Visual I / A On a block: insert before / append after it on every line; 2I repeats the text
Visual > / < Shift selected lines right / left; a count selects indentation steps (3>)
Visual Escape Cancel selection without moving the cursor
Insert text, Backspace, Delete Edit
Insert Enter New line, indented like the current one
Insert Tab Insert spaces to the next multiple of 2 columns
Insert Ctrl-t / Ctrl-d Increase / decrease current-line indentation by one step
Insert Escape, or j then k Back to Normal mode
Both Ctrl-c Nothing, except a hint to use Space q

Movement stops at the ends of a line: h and l do not wrap to the next line. j and k keep the column you were aiming for across shorter lines; every other motion sets that column to where it lands, except that after $, as in Vim, j and k stick to line ends. As in Vim, that column is a screen column, so j and k line up on screen around TABs and wide characters, landing on whichever character covers the column; on a TAB the cursor aims for the TAB's last cell (its first cell in Insert mode, and in Visual mode at or before where the selection started). Leaving Insert mode steps the cursor back one character, as in Vim. Motions never change the text, the undo history, or [+].

Workspace status

File buffers default to a top strip when more than one file is open. Start with --buffers status for rows inside the status tile, or switch using Space b s (Show open buffers as status rows in the palette). Space b t or --buffers top restores the strip. Status placement and size use the existing workspace controls; if status is hidden or cannot fit, buffers fall back to the strip. Zen hides both without changing the preference. Rows remain passive: Space b n/p switches files through the same session lifecycle. Both presentations disambiguate filenames and mark modified files with * and missing files with ! (rows also show [missing]). A constrained list follows the active file and marks hidden neighbors with ^/v where space permits.

All installed tiles are shown at startup: the document, Status, Problems, and History, plus the demo report when launched with --demo-report. Keyboard focus starts in the document. The existing show/hide keys still toggle each tile.

Status can occupy a cell on any side of the document. It shows mode, file/dirty state, position, pending keys, and current feedback; it never takes keyboard focus. Side-by-side width starts at 28 cells, stacked height at 6 rows, and each requested size is remembered separately. Small windows fall back to the bottom status row; expanding restores the requested layout automatically. Wider windows never turn status on by themselves.

Zen keeps the bottom row for essential feedback without changing document placement or saved workspace requests. Status controls used in zen update the saved layout; toggle zen off to see it. Space v r still resets only document placement. All settings are session-local. Save and reload failures remain visible across editing, layout changes, compact status, and zen until acknowledged. An idle Normal-mode Escape acknowledges the currently displayed problem and clears search highlighting. Leaving Insert/Visual mode or cancelling a command, count, or search takes precedence; press Escape again once idle to acknowledge. Acknowledgement leaves the problem active and does not change dirty state. Status then shows an unresolved-problem count; Space v e cycles retained details without retrying the operation. Repeated failure renews attention without adding another entry. Successful save and reload resolve only the corresponding failure for that file. Routine feedback, including refused quit, clears on the next completed editor command or is replaced by newer routine feedback. Pending prefixes, ignored keys, resize, and animation do not clear it.

Bare presentation

Start with ches --bare PATH (or its alias ches --superzen PATH), press Space v B, or choose Toggle bare mode in the palette. Bare puts text at the terminal's top-left, using the full width without a document border, title, padding, tab strip, workspace panes, or animated cursor. Line numbers start off and can be enabled independently. Syntax highlighting, search and selection overlays, modal editing, buffer switching, registers, and undo remain available.

Space v n toggles absolute numbering and Space v N toggles relative numbering, using the same commands and gutter renderer as the workspace. Enabling both gives hybrid numbering: the current line's absolute number and relative distances on the other lines. The palette's number commands work identically. The gutter disappears when the terminal is too narrow and returns with the chosen style when it grows.

Bare retains its own line-number preference for the session, across file switches and leaving/reentering bare. It neither inherits nor changes the workspace/zen number style. Space v r in bare resets only this profile to numbers off, leaving workspace placement and numbering untouched. For code-level startup configuration, Presentation.Bare_prefs.t holds these settings; for example, Ui_state.create ~bare:true ~bare_prefs:{ line_numbers = Absolute } controller starts bare with absolute numbers using the existing renderer. Preferences are session-local and are not saved across launches.

The bottom row stays allocated so feedback never shifts the document. It is blank when idle, showing only pending keys, search/command prompts, and operation feedback rather than permanent mode, filename, dirty, or position fields. The cursor shape still distinguishes Normal and Insert mode. Diagnostic findings stay retained without an unresolved-problem count in this row; save/reload errors and other operation feedback remain visible until cleared or acknowledged normally.

Entering bare returns input from a supporting view or side directory to the active file and releases floating capture and incomplete key sequences. A directory-only session keeps its listing usable until a file is opened. The same session owns the buffers in every presentation: switching does not reload files, discard unsaved text, or reset undo. Space v B restores the previous workspace or zen presentation and its requested layout; it returns to the file rather than reactivating the previously focused supporting view. Other placement controls used in bare update the saved workspace preferences while bare's effective geometry stays stripped down; number toggles and reset target bare's own profile.

The palette and all three pickers can open over bare and return to it. Explicitly opening or focusing a workspace view or directory browser leaves bare so the requested surface can be displayed. Space v z explicitly selects zen instead. Bare is a presentation choice; language-server startup still follows the usual rules (--no-lsp disables it).

Command palette

Space c c opens a centered floating palette, listing every command that can run from Normal mode with its shortcut (taken from the active bindings). Type part of a command's name, or a related word: rel num, rln, and gutter relative all find Toggle relative line numbers. Matching is fuzzy and in-process (no fzf needed): each space-separated word must match, in order, in the title, the command's ID, or one of its keywords, and matched title letters are highlighted. The current default catalog contains 79 commands, including all three pickers, VCS actions, Toggle tile hotkey hints, Toggle bare mode, and Choose theme. Bare and workspace use the same global catalog: bare does not hide commands. Commands local to a supporting view are added only when the palette is opened from that view or its help. Some placement commands in bare update saved workspace preferences; explicitly opening a supporting view leaves bare to display it.

Palette keys Action
text, including Space and j/k Edit the query (a paste goes into it too)
Backspace Delete the last character
Ctrl-Backspace or Ctrl-w Delete the last word (most terminals send Ctrl-Backspace as Ctrl-h, which works too)
Tab / Shift-Tab or Ctrl-n / Ctrl-p Select the next / previous command
Enter Close the palette and run the selected command once, on the document
Escape Close it without running anything
Ctrl-c Show the host's reminder to use Escape; keep the palette open

A command run from the palette behaves exactly as its key binding: an ordinary quit is still refused with unsaved changes, and save failures are reported the same way. The palette opens only from Normal mode, including in zen and bare. It is an opaque framed window above the workspace, not a bottom-band tile: opening, filtering, and closing do not reallocate the document, status, problems, report, or history tiles, or change the document scroll. Its preferred outer size is 80 columns by 14 rows, centered in the terminal and clamped with a one-cell margin where possible. Filtering does not change that size; results scroll inside the frame, with one bar cursor in the query.

It needs at least 14 columns and 4 rows for a frame, query, and one result row. Below that size it refuses to open with shared feedback. Resizing preserves the query and selected command while it still fits; if it cannot fit, it closes safely without execution and returns focus to the document. Closing restores the covered workspace and discards the query. Pasted text goes only into the query (line breaks become spaces); if the palette closes mid-paste, the rest is dropped even if the terminal grows before the paste ends. With no matching result, Enter leaves it open and reports that nothing matched. Opening from another supporting view still targets the document and returns there on cancellation.

To add a command, add an entry (ID, title, keywords, and the existing editor or view action) to Catalog.default in palette/catalog.ml. Its shortcut is derived from the bindings, so it needs no label and no execution code of its own.

File, document-line and project-content pickers

Space f l (Normal) or Search current document lines in the command palette opens numbered in-memory lines in the shared float. Type loose subsequences; Tab/Shift-Tab or Ctrl-n/p selects, Enter jumps to the earliest matched character and reveals it. Backspace/Ctrl-w edit the query; paste is sanitized like the palette. Escape cancels without moving the document; Ctrl-c shows a reminder, not cancellation. Filtering/no-match Enter is inert. Document changes invalidate results; reopen to refresh. Minimum 14×5, including zen; undersized resize closes safely.

Space f f / Find project files opens or activates retained buffers without reloading unsaved text. Its file-only float prefers 175×40 (80×40 below 104 terminal columns), centered and clamped with a one-cell margin where possible. At terminal widths of 104 cells or more, its wider float shows results left and a read-only numbered preview right (first 64 KiB/100 lines, current unsaved buffer text if retained). Narrow terminals hide preview; it never takes focus, opens tabs or changes Enter behavior. Loading/errors/truncation are labelled. Space f g / Search project contents searches on-disk case-sensitive literals, then validates the current target's entire raw line and literal byte range before activating and revealing it. Dirty matching lines are allowed; stale lines and missing new files fail visibly without changing tabs. See picker status and setup for scope, limits, coordinates and ripgrep dependencies. Existing / and ? search is unchanged.

Workspace commands include Save buffer, Next/Previous file tab, Close file tab (and its explicit discard variant), Recreate missing path, directory navigation, all five mark actions, and major/side/hide/focus/width actions. Save targets the owner from which the palette opened, including a side browser; it can permanently delete entries. Undo/Redo affect text only, not disk. There is no interactive open-path/save-as prompt; save-all is an application API, not a default binding or palette action.

Directory workspace

See the directory workspace reference for persistent tabs, placement/focus, visual and marked opening, identity tokens and filename escapes, copy/destination syntax, permanent empty-only deletion, missing-file recovery, cross-device limits, partial apply/retry and text-undo boundaries. Directory Save applies edits directly, without a confirmation dialog or filesystem undo.

Problems pane

Space v b toggles a bottom preview; Space v f switches workspace/current-file filtering. Tile hotkey hints are hidden by default; Space v ? toggles them in Problems, History, and the demo report, including focused lists and details, and in Tile Terms and all picker/palette control footers. For text-input floats, toggle before opening or use Toggle tile hotkey hints in the palette; captured keys still edit queries. Overflow counts, detail positions, picker status, errors and action feedback remain visible. Space v o shows and focuses the pane. It remains read-only:

Pane keys Action
j/k, gg/G, Ctrl-d/u Select problems; move the text cursor while inspecting details
yy / Y Copy the selected problem's whole description
e Toggle full wrapped details for the selected problem, as read-only text (below)
a Acknowledge only the selected problem, without resolving it
Enter Jump to a valid current-file location and return to the editor
Escape Cancel a prefix, end a selection, close details, then return to the editor
Tab or Space v o Return directly to the editor
Space v … Layout controls; editor commands and document scrolling are rejected

Supporting views (problems, the demo report, and a dedicated status cell with room for it) share one rounded, padded frame with their title in the top border and key hints, notices, or a pending prefix in the bottom border; side-by-side tiles are separated by a one-cell gap. The bottom band takes up to ten rows, never more than a third of the window. Frames sit on the dark backdrop, so their rounded borders alone separate tiles. The > marker, the Problems* title, and an accent-coloured frame show selection/focus; the terminal cursor is hidden in a pane's list and marks the text cursor in its details. Hiding, zen, or resizing too small returns focus to the editor. Pane pastes are ignored atomically, not treated as commands. Focus, Escape/Tab/prefix precedence, workspace bindings, and paste ownership come from the shared tile host (tile/), not the problems pane; any other supporting view gets the same rules. Missing/out-of-range locations and cross-file jumps are explained without touching the document. Currently save/reload failures have no locations; location navigation can be tried with language-server diagnostics or the opt-in synthetic demo below. Cross-file jumps are not supported.

To try navigation on a file with several lines:

dune exec ches -- --demo-problems PATH

Press Space v o, then G to select the last demo finding and Enter to jump to the file's last line. Refocus with Space v o; try gg and j/k to navigate, or G then e to inspect the long final finding (j/k scroll details; Escape closes them).

The flag adds eight clearly labelled DEMO entries, initially acknowledged so they do not demand failure attention. It does not change your text or write files; normal editing/saving still works. Entries are session-local and disappear on restart without the flag. Their locations are a startup snapshot, not refreshed after edits/reload. Short/empty files have repeated locations; use a multiline file to see distinct jump targets. No demo problems are added in an ordinary launch.

Demo diagnostics (checker findings fixture)

dune exec ches -- --demo-diagnostics PATH

This seeds static, labelled DEMO checker findings for reviewing the problems view independently of a language server. It adds two sources on PATH (one versioned, one unversioned, which reports a hint), a finding in another file, and a stopped source whose finding stays marked [source stopped] (its stop warning is in history). Findings are standing state: they count in the status line ([N problems: Space v e]) but never take attention or need acknowledging (a on one says so). The problems view lists problems first, then findings by file, severity, and position. Findings for the open file dim after an edit until their checker catches up; nothing updates the demo, so they stay dimmed. Other files' findings never dim from typing. A finding's selection survives lines inserted above it. Lists that arrive during Insert wait until it ends.

Language servers (ocamllsp and slang-server)

dune exec -j 12 ches -- PATH.ml    # or .mli, .mll, .mly; --no-lsp turns it off
dune exec -j 12 ches -- PATH.sv    # or .svh, .v, .vh; see Slang discovery below

Inspecting attached servers

Press Space l i, or open the palette and search lsp / Language servers. The live read-only tab shows:

  • Which managed servers are attached to the current file, or why none are listed.
  • Every managed server's ID, workspace root, launch command, and attached files.
  • Starting, Running, Stopped, or Unavailable, with the failure reason.

For example, opening both .ml and .sv files can show ocamllsp#1 and slang-server#2 simultaneously. Several files can share a server when their root and configuration match; distinct roots can have separate instances of the same server. State comes from the managed processes, not from whether they reported diagnostics. A server with zero findings can still be Running.

The report refreshes as files attach/close and servers start/stop. Reopening it also requests a fresh inventory. Its current-file section uses the underlying active file tab, so opening the report doesn't replace that context. Use the usual read-only motions, v / V, and yank to copy information. Space b n / Space b p switch tabs, and Space b c closes the report. With --no-lsp, it reports that the diagnostic source is disabled; the synthetic checker is not listed as a language server.

OCaml and pooled lifecycle

Like the owner's Neovim setup, ches starts ocamllsp from PATH for OCaml files. Its root is the nearest ancestor containing any of dune-project, dune-workspace, *.opam (a literal name), opam, esy.json, package.json, or .git; else the file's directory. Diagnostics go to the problems view and status count; Hints are their own, quieter severity.

ches never runs dune. Merlin needs a build's configuration, so in a project that has never been built the only finding is No config found … Try calling 'dune build', and errors from other files appear only while you run dune build --watch yourself. ocamllsp 1.19 sends its lists unversioned, so open-file findings dim from your first edit after a list arrives until the next one.

An unavailable server is recorded in history (Space v m) and the Language servers report; a server that exits or crashes is a one-off warning (ocamllsp stopped: … (Space v R to restart)), kept in history, its findings kept dimmed and marked stopped; nothing restarts on its own. On quit ches asks the server to shut down and waits up to 1 s. --synthetic-checker replaces it. To check the client against the installed server without the UI: dune exec source/bench/lsp_probe.exe -- -build.

Supported open files share one language-server process per workspace root and server configuration. Switching tabs retains it; closing a file sends didClose for only that document. The last close and session shutdown stop the process. Space v R restarts each pooled server once and reopens all its current documents; Space v K remains a synthetic-checker crash command. Document events retain buffer-generation ownership, including inactive files. Each document has its own bounded revision/text history, and monotonic wire versions map diagnostics back to editor revisions. LSP source names carry a stable server-pool suffix (for example ocamllsp#1), so one root/configuration stopping cannot dim another pool's findings. A restart retains that ID; a new pool after the last close gets a new ID. Edits keep only the latest pending snapshot per document. The first edit starts a 25 ms coalescing window; further typing replaces the snapshot without extending that window. Diffing and JSON serialization happen at flush, rather than on every key. Servers negotiating Full receive whole text; Incremental receives one encompassing replacement against the last sent text, with UTF-8/UTF-16/UTF-32 positions as negotiated. Invalid UTF-8 or unknown position encoding uses a safe full-text event; absent/None change support sends no changes. Save flushes its document before didSave, including text if requested. Close, restart, and shutdown cancel pending timers; initialization/restart opens the newest text. If the protocol stream closes while the server remains alive, the client allows the configured shutdown grace (normally 1 s), then reports the failure, kills and reaps the child. Revision history contains only sent versions (up to 32 per document).

Symlink paths stay separate LSP URIs and buffers. Two lexical names normalizing to the exact same URI cannot independently hold unsaved texts: the second is explicitly reported unavailable, and closing it cannot close the first. Late output for closed URIs is discarded. A URI reopened while its pooled server survives receives normal unversioned diagnostics using its current text and buffer ownership. These messages carry neither a revision nor a buffer lifetime: late output from an old lifetime is indistinguishable from fresh output and may temporarily replace current findings. Versioned diagnostics still require a sent version in the current document's history; old sessions and buffer generations remain isolated. The synthetic checker retains per-file runtimes and per-file #generation source names. Directories do not start diagnostic drivers.

For SystemVerilog (.sv, .svh) and Verilog (.v, .vh), ches starts slang-server with no arguments, using the same diagnostic and lifecycle handling. Its root is the nearest ancestor containing .slang or .git; else the file's directory. --no-lsp disables either server, and --synthetic-checker takes precedence over either.

Slang executable discovery

Ches looks for the built-in Slang server in this order:

  1. SLANG_SERVER, if set, as an explicit executable path or command name.
  2. slang-server on PATH.
  3. $HOME/slang-server/build/bin/slang-server, if it is an executable file.

An invalid explicit override reports Unavailable rather than silently selecting another server. The Language servers report shows the selected executable, root, and any failure reason. This fallback supports a local Slang build without changing your shell configuration; the separate slang compiler is not the LSP.

For an explicit launch:

SLANG_SERVER="$HOME/slang-server/build/bin/slang-server" ches path/to/design.sv

If no server is installed, follow the upstream installation guide. After making a missing executable available to the running Ches environment, Space v R retries the managed servers. Environment changes made in another shell require relaunching Ches to inherit them; executable selection is retained for each existing server pool.

Set include paths, defines, and file lists in the project's .slang/server.json, which the server reads itself. For example:

{ "flags": "-Irtl/include -DSIMULATION", "build": "build/top.f" }

See the slang-server configuration documentation. Ches consumes LSP diagnostics, completion, hover, declaration/definition navigation, and references, plus Slang active-instance selection and instantiation navigation. A full Slang hierarchy tree and waveform features are not wired into the editor.

Hover and symbol navigation

Place the text cursor on a symbol in a file's Normal mode:

Key Action
K Show hover information in a scrollable floating view
gd Request declaration first, then definition if unavailable or not found
gD Request definition first, then declaration if unavailable or not found
gr Find references in a searchable picker, including declarations
Ctrl-o Jump back
Ctrl-i / Tab Jump forward

The same actions appear in the palette as Hover, Go to declaration, Go to definition, Jump back, and Jump forward. Lowercase k remains upward movement, and Space v K retains its synthetic-source test action. Tab's history alias applies only to the Normal-mode file document; completion, snippets, pickers, directory focus and terminals retain their own Tab behavior.

Hover displays the server's content, with lightweight Markdown formatting, readable code blocks, and visible link text/URLs. In the popup, j/k or Ctrl-e/Ctrl-y scroll a row, Ctrl-d/Ctrl-u scroll a page portion, and gg/G go to the ends. q or Escape closes and returns focus. Long content is bounded and truncation is marked. The popup does not execute links.

One navigation destination opens directly. Multiple destinations open a searchable picker; filter by path/line, use Tab/Shift-Tab or Ctrl-n/Ctrl-p to select, and Enter to jump. Escape cancels. Locations use the server's selected symbol range and negotiated UTF-8/16/32 encoding. Existing dirty destination buffers are reused; missing files or invalid positions fail without creating files or discarding edits.

For the inspected OCaml server, declaration asks Merlin for the interface (.mli) and definition asks for implementation source (.ml). Actual locations depend on symbol resolution and source availability. The implementation request is not used. Slang advertises definition but not declaration, so both keys normally use its definition handler. Hover can include elaborated types, widths, enum/parameter values, and documentation according to server support. Instance-dependent results reflect Slang's analysis; see active-instance controls below for selecting context and the installed-server hover limitation.

Queries flush pending document changes before execution and are cancelled or ignored after cursor, mode, focus, buffer, document, or server-lifetime changes. Unsupported operations, no results, and failures produce notices rather than unexpected movement. A destination picker also rejects changed targets before acceptance; reopen the query to refresh it.

History records successful symbol jumps and preserves intervening cursor movement for reverse traversal. A new jump discards the forward branch. Each direction retains at most 128 entries, storing paths and byte offsets rather than snapshots. Edits do not relocate old marks: their numeric offsets are reused only if still valid, otherwise traversal reports an error without advancing history. History is session-local and navigation does not alter text undo history.

Find references

Press gr on a symbol in Normal mode, or choose Find references from the command palette. This uses the standard LSP references request with declarations included. It works with both ocamllsp and slang-server when advertised by the attached server; it does not fall back to definition lookup.

All nonempty results open the Find references picker, even a single result. The heading shows matching/total counts. Filter by path/line, use Tab/Shift-Tab or Ctrl-n/Ctrl-p to select, and Enter to jump. Escape cancels. Jumps reuse retained dirty buffers and enter the same Ctrl-o/Ctrl-i history. Changed destinations are rejected rather than jumping to stale coordinates. Empty or unsupported queries produce a notice. The existing 256-target transport limit applies; oversized responses report an error rather than silently omitting results.

Source previews in result pickers

References and multiple-destination pickers include a Source preview below the results when there are at least eight content rows. Move through results with Tab/Shift-Tab or Ctrl-n/Ctrl-p to inspect source without opening each file. The preview shows line numbers and highlights the selected symbol range, including multiline and zero-width locations. It keeps the target line visible as the picker resizes; small allocations retain the result list without the preview.

Already-open buffers supply their current text, including unsaved edits; the header identifies buffer rN or disk. Browsing previews never activates a buffer, starts a language server, changes text, or adds jump-history entries. Enter performs the usual validated jump; Escape cancels without moving the document.

Disk preview work is asynchronous, debounced by 40 ms, and limited to one physical read at a time. Rapid selection changes cancel or discard obsolete results. Loading, missing/unreadable files, unsupported text, stale targets and preview limits appear as explicit messages. Disk collection scans at most 8 MiB, retains at most 32 lines and 64 KiB, and copies at most 4096 bytes per line. Targets beyond the scan/line limits show a limit message; long surrounding lines indicate truncation. Previews highlight the target but do not apply language syntax highlighting yet.

File metadata is checked at result discovery, preview collection/delivery and navigation acceptance; retained buffers use document identity and revision. These checks catch ordinary replacements and edits, but cannot guarantee that a server's coordinates still refer to the same symbol after concurrent changes. A failed preview does not itself prevent an otherwise valid Enter navigation.

Slang active-instance context

With the cursor inside a module's definition in Normal mode, choose Select active instance from the command palette (Space c c). Ches asks the server for the enclosing module and lists its elaborated hierarchy paths. Search the list, select with Tab/Shift-Tab, and press Enter to activate; * marks the previously active path independently of the current picker selection. Escape cancels.

Activation changes server context only: it does not edit or navigate the file. Confirmed context appears as Instance: top.some_instance in the status fields when visible, in the selection notice, and alongside hover information for that module. It is cleared when document/server context can no longer be trusted. Hover, completion and navigation results from the previous context are invalidated; other server pools retain their own state.

Choose Go to instantiation to navigate to the current instance's use site. This uses normal target validation and jump history, so Ctrl-o returns. If the server provides no usable location, Ches reports that instead of guessing. Some server versions return the module's own range for a top-level instance.

These commands require Slang's advertised extensions and an elaborated design with reachable instances. A standalone file may support hover/references but have no instance list until the server has a configured build/source set. Ches does not silently select a build file or change project settings. Unsupported servers and contexts receive a notice; there is no source-text module-name guessing.

Installed-server observation: the tested Slang 0.3.1+a7a2d08 confirmed switching between top.narrow and top.wide, but subsequent fresh hover responses still included both 8-bit and 32-bit type variants. Ches displays what the server returns; active selection does not guarantee that this version narrows every hover to a single width. Standard references worked in the same probe, and ocamllsp returned the declaration and both uses of a test value.

Signature help

Signature help displays call information supplied by the attached language server, with the current argument highlighted when the server identifies it. Automatic help is enabled by default and follows the server's advertised trigger characters. The installed ocamllsp advertises space, ~, ?, :, and (; Ches does not infer calls from punctuation or parse language semantics itself.

  • Ctrl-k in a file's Normal or Insert mode, or palette Signature help, requests help manually, even with automatic help disabled.
  • Toggle automatic signature help changes the current session setting. Use Signature_help.set_enabled false in config.ml for a persistent preference.
  • While help is visible in Insert mode, Ctrl-g selects the next overload and Ctrl-b the previous. Tab and Ctrl-e/Ctrl-y retain completion/snippet behavior.

The overlay does not take focus or move the cursor. It shows bounded signature and documentation text, active-argument highlighting, and overload controls. It prefers above the cursor while completion appears below; in constrained space completion has priority. Movement, mode/focus changes, Escape, paste, snippet activation, configuration reload and server/context changes dismiss stale help. Automatic requests are suppressed while snippets, block insert, pastes, terminals or popups own input. Unsupported automatic requests remain silent; manual requests explain unavailability.

Current server support: the installed OCaml server returned signature help in the live probe. The installed Slang version and inspected Slang source advertise no signature-help provider, so this feature currently provides no SystemVerilog function/task signatures. Hover (K) remains available there.

Switch OCaml interface/implementation

Choose Switch interface/implementation from the command palette to request the current file's counterpart through ocamllsp. This switches companion files; unlike gd/gD, it does not locate the symbol under the cursor.

A single existing counterpart opens directly. Multiple returned paths open a Choose counterpart picker. Retained dirty buffers and their cursor positions are reused; new files start at their ordinary initial position. Successful switches enter Ctrl-o/Ctrl-i jump history. Missing/unreadable counterparts report an error without creating a file or moving the current cursor. The server can return a suggested filename that does not exist, so absence is a normal possible outcome. Unsupported servers, including Slang, receive a notice; Ches does not guess filename extensions.

Code completion

The menu colors labels, source tags, type/detail strings and matched prefixes separately. Selection uses a dedicated subdued background across the entire row, and documentation uses the menu background. Detail text receives a semantic type color rather than per-token syntax highlighting. Override individual colors with Completion.set_color ~role ... in config.ml; see completion menu colors.

Startup preferences can be set in OCaml configuration, including automatic completion, ghost preview, trigger length, and local-snippet priority. Palette changes last only for the current session; Reload configuration restores defaults plus the values in your file.

Automatic completion is enabled by default in ordinary Insert mode. After one identifier character, a small menu offers matching words from the current buffer and candidates from an attached language server. Punctuation ., :, >, and / also requests server suggestions. Buffer suggestions work without an LSP.

Ctrl-n explicitly requests completion in Insert mode, even with automatic completion disabled or with zero/one typed prefix characters. An empty prefix offers lexically ordered buffer words and available server candidates. The menu aligns candidate labels first, followed by aligned buffer/LSP source tags, and displays available kind, signature/detail, and selected-item documentation within the available space. One blank cell pads the right edge.

Key While candidates are available
Tab Insert the selected candidate; subsequent presses cycle forward
Shift-Tab Insert the selected candidate; subsequent presses cycle backward
Enter Accept the selected candidate and close the menu, without a newline
Escape Keep inserted text, close the menu, and return to Normal mode

The menu stays open while cycling, and each choice replaces the original completion slot. Cycling wraps and freezes the available choices after the first insertion. Continuing to type accepts inserted text and updates suggestions. Additional edits, such as imports, apply only when finalizing the selected choice. Completion joins the current Insert undo transaction. Without candidates, Tab retains its normal behavior. Bracketed paste and block insert do not start completion.

Open the command palette (Space c c) and search for:

  • Toggle automatic completion — turn suggestions off or back on.
  • Toggle completion ghost preview — optionally show the selected candidate's untyped suffix; off by default. Only straightforward prefix matches get a ghost preview, and it never changes buffer text.

These toggles last for the current editor session. Buffer matches are case-sensitive and lexically ordered; LSP candidates use server sorting and precede buffer-only matches. Buffer-word indexing covers the entire document and is cached per live buffer; ordinary edits update only affected words. Large initial builds and updates run in bounded, yielded chunks outside input transitions. Snippet and LSP results remain available while word suggestions load, and word results cannot alter a candidate list already being cycled. Small buffers can finish in one bounded input step. The combined list is limited to 100 candidates. Typed-prefix scanning is limited to 4096 bytes, and buffer identifiers longer than 4096 bytes are omitted.

LSP requests synchronize the document first and discard obsolete replies. Insert/replace edits use the replace range; supported completion-list defaults are inherited by items. Selected candidates can lazily resolve documentation, details, and additional edits. Known additional edits apply at acceptance. If resolution is still pending, acceptance keeps the primary text and allows up to one second for extras to arrive while the accepted buffer/cursor remain unchanged. Any subsequent key or paste cancels this deferred action; typing never waits. Completion commands, indentation adjustment, commit-character acceptance, and dynamic capability registration remain unsupported.

Snippet placeholders

Language-server completions can contain snippet fields. Cycling with Tab inserts the expanded text but does not activate those fields. Enter accepts the candidate and activates its first numbered field, highlighting its default text and linked occurrences.

Key While snippet fields are active
Typing Replace the selected default, then edit the field; linked occurrences update together
Tab Select the next numbered field; after the last, move to the final cursor position and finish
Shift-Tab Select the previous field; at the first, reselect it
Ctrl-e / Ctrl-y Cycle the active field's choices forward/backward, with wraparound
Left / Right Move within a field without losing linked updates; leaving it ends the snippet
Home / End Move to the current line's start/end; retain the snippet only when still within an active occurrence
Escape Retain expanded text, end the snippet, and return to Normal mode
Ctrl-n End the snippet and explicitly request completion

For example, a server snippet assign ${1:signal} = $1;$0 expands to assign signal = signal;. Enter selects the first signal; typing ready updates both occurrences, and Tab moves to the position after the semicolon.

Supported syntax includes $1, ${1}, ${1:default}, linked occurrences, $0 for the final cursor, and escaped backslashes, dollar signs, and closing braces. When $0 is absent, the final cursor is at the end of the expansion. Choice fields such as ${1|posedge,negedge|} initially select the first option and retain linked occurrences. Within choices, escape comma, pipe, and backslash as \,, \|, and \\; options can be empty or multiline.

A compact hint shows available choices while the field is active. Cycling keeps the chosen value selected, so typing replaces it with custom text. After custom text, Ctrl-e chooses the first option and Ctrl-y the last. For a quick hands-on test in a SystemVerilog file, accept the bundled aff snippet with Enter, press Ctrl-e to change posedge to negedge, then Tab to edit clk.

Filename variables work in local and language-server snippets: TM_FILENAME, TM_FILENAME_BASE (only the final extension removed), TM_DIRECTORY, and TM_FILEPATH. Use $TM_FILENAME, ${TM_FILENAME}, or a literal fallback such as ${TM_FILENAME_BASE:untitled}. Paths are the current document's lexical editor paths; relative paths stay relative and a bare filename has directory .. Missing or unnamed paths use the fallback or empty text. Variables and defaults are not recursively expanded. Unknown variables, transformations, nested numbered fields, and conflicting linked defaults/choices are rejected; malformed completions are skipped. Templates can come from the language server or the independent local catalog described below.

For example, module ${TM_FILENAME_BASE:untitled};\n $0\nendmodule uses the current filename without its final extension as the module name. A standalone variable inserts literal text. For an editable filename-backed field, use ${1:${TM_FILENAME_BASE:untitled}}: its resolved value is selected and edits mirror to $1. Numbered defaults may mix literal text and supported variables, for example ${1:prefix_${TM_FILENAME_BASE}}. Nested numbered fields, nested choices, transforms, and recursive variable fallbacks remain unsupported.

For a server-independent hands-on test, open the command palette from a file's Normal mode (Space c c) and select Insert demo snippet. This development utility inserts at the current cursor and activates signal immediately:

assign signal = value;
// mirror: signal

Type a name to update both signal occurrences, press Tab to edit value, then Tab again to finish on the final empty line. Escape followed by u undoes the expansion and field edits together. The action is included in the regular build, needs no LSP, and works with automatic completion disabled. It is available in file Normal mode, not directory/read-only views or block insertion.

Automatic completion is suppressed while editing snippet fields. Safe Left/Right/ Home/End movement clears the default selection and retains mirroring within the active field's occurrences, including their endpoints. Movement outside those ranges, paste, newline, buffer/focus changes, and edits crossing a field boundary end the snippet before normal handling. Expansion, internal movement and linked edits retain the Insert undo group; undo/redo does not reactivate a cancelled session.

Snippet acceptance uses additional edits already known at Enter and cancels pending resolve before activating fields. Late-resolved imports are therefore omitted for that acceptance, rather than shifting fields after editing has begun. Plain completions retain the deferred-resolution behavior described above.

Independent and user-defined snippets

Insert snippet in the command palette (Space c c) opens a searchable picker from an editable file's Normal mode. It includes global templates and templates matching that file's scope, independently of LSP or automatic completion settings. Search by prefix, description, ID, or collection. Tab/Ctrl-n and Shift-Tab/Ctrl-p select the next/previous result; Enter inserts and activates placeholders; Escape/Ctrl-c cancels without changing the document. At sufficient height, the preview shows the raw body, scope, collection, ID, and effective origin (bundled, legacy JSON, or OCaml).

Picker insertion is at the captured cursor, like i, and does not consume a preceding identifier. Filename variables and indentation use that insertion context. Editing fields and undo follow the same rules as accepted completion snippets. Stale buffers or catalog reloads cannot insert an outdated selection.

Choose Open configuration to edit config.ml in Ches, save, then choose Reload configuration to apply your changes. Existing unsaved config buffers are reused; a missing file opens as an unsaved buffer without automatically creating directories or files.

Local templates work without a language server, including with --no-lsp. They appear as [snippet] candidates alongside LSP and buffer suggestions, with local templates ranked first. Tab cycles expanded candidates; Enter activates fields. Automatic matching starts after one character; Ctrl-n also works with automatic completion disabled or an empty prefix.

The original starters remain available in .sv and .svh files:

Prefix ID Template
aff sv.aff Clocked always_ff block with a posedge/negedge choice
acomb sv.acomb always_comb block
mod sv.mod Module declaration with an editable filename-backed name
inst sv.inst Module instance with a linked port/signal field
genfor sv.genfor Generate loop with linked loop-variable occurrences

The full catalog has 93 templates in seven collections: SV design and verification; core OCaml, testing, and Jane Street conventions; and Hardcaml design and verification. Hardcaml uses the same file types as OCaml. All collections are enabled by default and can be toggled in config.ml, for example Snippets.set_collection_enabled ~collection:"hardcaml.verification" false. See snippet collections for triggers, configuration, timing/reset semantics, and library dependencies. Collection names are searchable in the picker.

To customize, define templates with Snippets.add and Snippets.disable in config.ml, then choose Reload configuration. Settings and declarations are validated and applied together; any failure retains the last good state. See the OCaml snippet API and editable examples. Builtins remain available unless overridden or disabled by ID.

Legacy JSON snippet collection

The earlier JSON configuration remains supported as an optional base layer beneath OCaml declarations. To use it, create ~/.config/ches/snippets.json. If XDG_CONFIG_HOME is an absolute nonempty path, Ches instead reads $XDG_CONFIG_HOME/ches/snippets.json. Ches does not create or overwrite this file. The editable example collection contains all five starters.

For example, this replaces the bundled aff with a falling-edge variant and adds a global template:

{
  "version": 1,
  "snippets": [
    {
      "id": "sv.aff",
      "prefix": "aff",
      "scope": ["systemverilog"],
      "description": "Falling-edge always block",
      "body": [
        "always_ff @(negedge ${1:clk}) begin",
        "    $0",
        "end"
      ]
    },
    {
      "id": "personal.todo",
      "prefix": "todo",
      "description": "TODO comment",
      "body": "// TODO: ${1:description}$0"
    }
  ]
}
  • id identifies a template. A user entry overrides a bundled entry with the same ID; other bundled entries remain available.
  • prefix is the case-sensitive completion trigger; description is optional.
  • scope is an array: systemverilog (.sv, .svh), verilog (.v, .vh), ocaml (.ml, .mli), or explicit extensions such as .py. Omitted or empty scope makes the snippet global.
  • body accepts a string or an array of lines, using the supported placeholder syntax above. JSON string escaping applies in addition to snippet escaping.
  • Subsequent lines inherit the insertion line's leading whitespace, while keeping the template's relative indentation. Placeholders and mirrors are relocated accordingly. Only the typed prefix is replaced.
  • To disable a starter, use an entry such as {"id":"sv.aff","disabled":true}. Do not include body/prefix fields on a disabled entry.

The legacy file loads asynchronously at startup. After editing it, choose Reload snippets from the command palette. A malformed file or failed read reports an error and preserves the last good collection. A missing file uses the bundled starters as its base. Current OCaml declarations are reapplied after every legacy load, taking precedence. Reload replaces the base rather than accumulating entries; deleting an override restores its starter on the next successful reload. Files are limited to 1 MiB and 1000 user entries, and duplicate IDs/unknown fields are errors.

Synthetic checker (live diagnostic source)

dune exec ches -- --synthetic-checker PATH

This runs a synthetic checker through the same asynchronous source boundary as the language servers, so freshness, crash, and restart behaviour can be tested without an external server. It starts with the document, rooted at the nearest directory with a dune-project (else PATH's directory). Like ocamllsp it is one source, synthetic, running two checks and merging them into one list per file:

  • an edit check, like merlin: about 0.4 s after an edit it checks the newest text: a line containing ERROR is an error, one containing TODO a warning.
  • a build check, like dune: about 0.8 s after a save (and at start) it checks the saved text's ERROR lines (synthetic build error) and adds a warning in synthetic_other.ml, a file you have not opened.

The open file's list describes the revision of the newest edit check, so its findings dim while you type ahead of it. As with dune, a build finding stays until you save.

Space v K crashes the checker. As in Neovim, that is a one-off warning (synthetic stopped: … (Space v R to restart)), gone at the next command but kept in history; nothing takes attention. Its last findings stay listed, dimmed and marked stopped. Space v R restarts it; kept findings stay dimmed until the restarted checker replaces them. There is no automatic restart. Without this flag, Space v R restarts all managed language servers, if present; Space v K is available only for the synthetic checker.

Demo report (tile-system fixture)

dune exec ches -- --demo-report PATH

This installs a static, error-free report of ten labelled DEMO REPORT rows. It exercises the shared tile host without the problems system. Space v d shows it in the bottom band (beside problems when both are shown); Space v D focuses it. j/k, gg/G, and Ctrl-d/u select, e or Enter toggles wrapped details (the last row's details scroll), and Escape/Tab/Space v … behave as in problems. Space v o and Space v D move focus between the two views. The report never posts feedback, touches problems, or edits the file. Without the flag, Space v d and Space v D only report that it is unavailable.

Notification history

Space v m shows the history in the bottom band (beside problems and the report); Space v M focuses it, like :messages in Vim. It lists past feedback oldest first, numbered #N: editor messages and keymap notices, and each problem's failures (problem, problem again when it was still active) and resolutions. Layout feedback and a view's own notices (such as a rejected paste) are not kept. An event repeated back to back is counted on one entry (×3). The newest 200 entries are kept in memory; the title counts any older ones dropped. Nothing persists across launches.

History is a record, not current state: problems live in the problems pane. Resolving a problem adds a resolved entry and keeps the earlier failure. Clearing the history leaves active problems alone. The focused list follows the newest entry until you move. j/k, gg/G, Ctrl-d/u select, yy copies an entry, e/Enter opens it as read-only text (below), and X clears the history. Escape, Tab, and Space v … behave as in problems.

VCS view

Space g g opens a git view of the repository around the startup file (or the directory opened), in the spirit of lazygit and Magit. It stages, unstages and discards files, hunks and selected lines, commits, amends and extends HEAD, fetches, pulls and pushes, checks out, creates and merges branches, carries a merge or rebase that stopped on conflicts through to its end (see Resolving conflicts), and browses the history of HEAD, a branch, all branches or a file (see Browsing history). The view is a tab the first time (labelled VCS: <branch>, or VCS: <revision> on a detached HEAD); Space g s moves it into the split beside the editor, Space g t back into the tab strip, and Space g h closes it (its state is simply re-read when it opens again; the chosen log is kept). It occupies one place at a time. Space g g and Space g f are the same command: they open the view, activate its tab, or move focus between it and the editor. The palette lists them as VCS: open or focus (vcs.open), VCS: move to a tab, VCS: move to the split and VCS: close (vcs.to-tab, vcs.to-split, vcs.close). Space s t/s/h also move it while it has focus.

The left column holds a head summary (branch, upstream and ahead/behind, and any merge or rebase in progress) above three list panels: Files (Conflicted, Untracked, Unstaged and Staged sections), Branches and Commits (the log chosen with l, at first HEAD's latest 200 commits, with a graph). The diff panel beside them follows the selection: a file's unstaged or staged diff, a section's combined diff, or a commit's git show, which starts with the commit's file list. In a narrow placement, such as the split, the lists stack above the diff; when even that does not fit, only the focused part shows. @ shows the command log at the bottom: each git command with its exit status and, on failure, its output (a fetch, pull or push also keeps its last lines of output, and shows its progress while it runs).

VCS keys Action
1 / 2 / 3 (list) Focus the Files / Branches / Commits panel
0 (list), Tab Focus the diff; Tab again returns to the list it follows
j k, gg G, Ctrl-d Ctrl-u Move in a list (headers included); the diff follows
Enter (list) Fold or unfold a section header; on a file or commit, focus the diff; on a branch, check it out
y (list) Copy the selected path, branch name or abbreviated commit hash
s / u / x (Files) Stage / unstage / discard the selected file, or every file of the selected section
x (a conflicted file, or its diff's header lines) Resolve it whole: take ours or theirs (marking it resolved), or restore its conflict markers; asks first
s / u / x (diff) Stage / unstage / discard the hunk at the cursor; on a file's header lines, the whole file
s / u / x (diff, Visual) Stage / unstage / discard the lines the selection touches (one file, any of its hunks)
S / U (Files, diff) Stage all changes (not conflicts) / unstage all changes; also in Visual
] / [ (diff) Next / previous hunk; with a count, 3] moves three, stopping at the last
} / { (diff) Next / previous file; counts as for ] [
Read-only text keys (diff) Move, select and copy, as in Read-only text, with counts: 10j, 5k, 12G
e, Enter (diff) Open the file at the cursor's line; Enter on a line of a commit's file list jumps to that file's diff instead
l (list) Log popup: HEAD, a branch, all branches or a file's history, with switches
+ (Commits) Read twice as many commits (up to 12800)
c Commit popup: commit, amend or extend HEAD, with switches
f Fetch from the default remote (git fetch --prune)
p / P Pull popup / push popup
m Merge popup for the branch selected in Branches; while merging, its popup: m commits the merge, a aborts it
r While rebasing, its popup: r continues, s skips the commit being applied, a aborts
n (Branches) New branch at HEAD, checked out: prompts for the name
- (Branches) Check out the previous branch (git switch -)
g r Refresh (or look for a repository again)
@ Show or hide the command log
? List the keys that work where the cursor is (also in the palette, first)
q Leave: show the file tab, or return focus to the editor beside the split
Escape In the diff: end a selection, then back to the list; in a list: return

In the diff, digits belong to the text: 10j scrolls ten rows and 0 is the line start, so 1/2/3 do not switch panels there. Tab or Escape returns to the lists, where they do.

With hotkey hints on (Space v ?), the footer names only the keys that act where the cursor is, after ? help, which lists them all: for example Files 1/4 | ? help, s x S, Enter fold, Tab diff, c commit, p P pull/push, 2 3 panels, q on the Untracked header, u x in Staged, s resolved on the Conflicted header, no staging keys in a commit's diff and no line keys in Visual on a conflict. Each footer fits a 100-column view; a narrower one cuts the end first.

A popup (such as c's) floats over the view, listing its switches and actions:

Popup keys Action
- then a switch's key Toggle the switch (* marks an enabled one; one per group); in a popup without switches (Resolve, Merging, Rebasing) - is unbound and leaves nothing pending
An action's key Run it with the enabled switches; the popup closes
Escape Clear a pending -; otherwise close, running nothing
q, Tab, Ctrl-c Close, running nothing
? List the popup's keys; closing the list returns to the popup
Space ... Workspace keys still work

Switches start off at every opening, except in the log popup (l), which opens with the current log's.

Staging and discarding. Each action runs as one git command (two for a hunk: git apply --check, then the apply, with the patch on stdin), shown in the command log, then the view refreshes. The selection stays on its row when the row is still listed; a file that left its section (staged, discarded) gives way to the next file of that section, else the previous one, else the section's header. After a hunk action the diff cursor goes to the hunk that took its place in the same file (or the file's last hunk). Specifics:

  • A section header acts on every file of the section; S stages every unstaged and untracked file. What an action cannot apply to (a nested repository, a submodule's discard, ...) is left out and named in the title or question.
  • s on a conflicted file (or the Conflicted header) runs git add, marking it resolved, without checking for leftover markers. x on a conflicted file resolves it instead of discarding (see Resolving conflicts); u, x on the Conflicted header ("Resolve conflicted files one at a time (x on a file); nothing ran") and hunk and line actions on conflicts ("Resolve conflicts in the editor: Enter opens the file at the conflict, Space x u, l, a or b keeps a side; nothing ran") are refused.
  • x always asks first; the default answer is No and only y confirms. Discarding unstaged changes restores the file from the index; discarding an untracked file deletes it (git clean); discarding staged changes returns the file to HEAD in the index and the work tree, and is refused while the file also has unstaged changes.
  • While any file buffer inside the repository has unsaved changes, a discard is refused before the question, naming the buffers ("... refused: unsaved changes in a.txt; save or undo them first; nothing ran"), and checked again on y. Staging a file whose buffer has unsaved changes stages the saved file and says so.
  • After a discard (even a failed one), open buffers inside the repository are compared with disk: unchanged buffers whose file changed are reloaded (cursor and scroll kept), those whose file is gone are marked missing. Staging and unstaging never touch the work tree.
  • While an action runs and until the refresh after it arrives, further actions say "Busy: ; nothing ran". A failed command is reported with git's message and its full output is in the command log (@).
  • In a commit's diff there is nothing to stage. ] and [ do not move in Visual.

Selected lines. In the diff of the work tree or the index, start a selection with v or V and press s, u or x: the action takes every added or removed line the selection touches (a line counts when any of its characters is selected; context, @@ and header lines are ignored). Unselected removed lines stay, and unselected added lines are left out. A selection across several hunks of one file is one patch, checked with git apply --check and then applied, so either all of it applies or nothing does. The title says how much: "Stage 2 lines of a.txt", "Unstage 1 line of a.txt"; x asks "Discard 3 lines of a.txt? Their unstaged changes are lost." (in the staged diff: "Discard 3 staged lines of a.txt? Their changes are removed from the index and the work tree and lost."). Confirmations, the dirty-buffer refusal, the staging warning, reconciliation and busy work as for hunks, and the diff cursor goes afterwards to the hunk that took the place of the first touched one. Refusals leave the selection in place so it can be adjusted:

  • "Select lines within one file; nothing ran" when the selection reaches a second file (its header lines included).
  • "No changes selected; nothing ran" when it holds no added or removed line.
  • An untracked file: "Stage the whole untracked file first (s on its row); nothing ran" (u: " is not staged; nothing ran"). A binary, mode-only, rename-only, submodule or conflicted file has no line actions ("Line actions do not apply to : ...", or the conflict refusal).
  • A selection made before the files changed fails at the check and changes nothing.

Running an action, or asking about it, ends the selection whatever the answer.

Committing. c (in any panel, and in the diff outside a selection) opens the commit popup. Its switches are -n (--no-verify: skip the pre-commit and commit-msg hooks), -s (--signoff: add a Signed-off-by line) and -e (--allow-empty); they start off at every opening. Its actions:

  • c commits the staged changes and a amends HEAD with them (HEAD's message pre-filled; with nothing staged, a just rewords HEAD). Both open the message file, .git/CHES_COMMIT_EDITMSG, as an ordinary file tab with the cursor on the first line, below which a # comment block names the branch, the switches and the staged files. At 80 columns or wider (and at least eight rows), the message editor occupies the right side while the VCS's files, branches and recent commits stay visible on the left. Space g g focuses those lists without leaving the draft; Tab there returns to the message. The diff preview returns when you finish, abort, or switch away from the message tab. Smaller terminals show the full-width message editor, and widening restores the lists. The VCS's tab, split or band placement is preserved. Write the message with the usual editing keys, then Space g c (palette VCS: finish commit) saves the buffer and runs git commit --cleanup=strip -F on it (with --amend for an amend, and the switches chosen in the popup): comment lines and surrounding blank lines are removed. On success the message tab closes (unsaved edits and all), the file is deleted, you are back in the VCS view where it is placed (if it was closed meanwhile, the editor shows the next tab), the view refreshes and git's summary line ([main 1a2b3c4] Subject) is reported. Space g a (VCS: abort commit) closes the message and deletes the file without committing ("Commit aborted", "Amend aborted"). A message tab closed by hand is simply forgotten; the next c c writes a fresh one.
  • e extends HEAD at once: git commit --amend --no-edit adds the staged changes and keeps HEAD's message.

Refusals and failures:

  • Nothing staged: "Nothing staged; stage changes first (s), or allow an empty commit (-e); nothing ran" for c and e (checked again on Space g c). Conflicted files refuse every commit ("Resolve the conflicted files first ..."), and on a branch with no commits there is nothing to amend or extend.
  • Space g c and Space g a work only in the pending message's buffer; elsewhere they say "No pending commit message here; nothing ran". c c or c a while a message is pending shows that buffer again: "A commit message is already open: Space g c commits it, Space g a aborts".
  • If git refuses (a pre-commit or commit-msg hook rejects the commit, or the message is empty once comments are stripped), the message stays open and pending with the failure reported ("Commit failed: <git's first line> (exit 1)"); the full output is in the command log (@). Fix the message and press Space g c again, or abort and reopen with -n to bypass the hooks.
  • If the buffer cannot be saved, nothing runs and the message stays pending.
  • While an action or a commit runs, commit keys say "Busy: ; nothing ran" (also Space g a while its commit runs).

Commits never rewrite the work tree themselves, so unsaved buffers do not block them, but hooks may: after every commit, amend or extend, open buffers inside the repository are compared with disk as after a discard.

Remotes and branches. f, p, P, r and m work in any panel and in the diff outside a selection; Enter, n and - in Branches. Every one goes through the same steps as staging: refusals say why and run nothing, one command runs in the background and is logged, and the view refreshes after it.

  • f fetches at once: git fetch --prune from the default remote, so an upstream deleted on the remote shows as gone.
  • p opens the pull popup: p pulls from the branch's upstream, fast-forward only (git pull --ff-only --no-rebase, whatever pull.rebase says); with -r it rebases the local commits onto the upstream (git pull --rebase). A pull is refused on a detached HEAD, without an upstream ("push it with P u first"), with a gone upstream, with conflicted files, and while another operation is in progress.
  • P opens the push popup, titled with the branch: p pushes to its upstream (named exactly, e.g. Push to origin/main, so push.default never matters), u pushes to origin/<branch> and makes that its upstream. -n skips the pre-push hook; -f force-pushes with lease and always asks first ("Force-push main to origin/main? Commits on origin/main that main does not contain are lost. git refuses if origin/main moved since the last fetch."). Without an upstream, p says to use P u.
  • Enter on a branch checks it out (git switch); on the current branch it says "Already on ; nothing ran". - checks out the previous branch. If uncommitted changes would be overwritten, git refuses and nothing changes.
  • n asks for a new branch's name in a prompt that checks it as you type, with git check-ref-format --branch's rules ("Not a valid branch name: it contains '..'", "A branch named main already exists"); Enter creates the branch at HEAD and checks it out, keeping uncommitted changes. Escape cancels. On a branch with no commits it is refused.
  • Checkout, the previous branch, pull and abort rewrite the work tree, so like a discard they are refused while a file in the repository has unsaved changes, and open buffers are compared with disk afterwards.

A fetch, pull or push may take a while; the view stays usable meanwhile (moving, diffs, g r, the log), other actions say "Busy: ; nothing ran", and the head summary shows <code>Fetch...</code> (or the pull's or push's title) with git's latest progress line. When it ends, the result is reported even if you have moved on: "Fetch: done", "Push main to origin/main: done", or "<title> failed: <reason>", where the reason explains common failures: no key loaded in ssh-agent, an unknown host key, credentials Ches cannot ask for, an unresolvable host, a diverged branch for a fast-forward-only pull ("pull with rebase (p -r p)"), a rejected push ("pull first (p p)"), a stale lease, a missing remote. git's own output is in the command log. Git and ssh never prompt: Ches cannot ask for a passphrase or accept a host key, so use ssh-agent or a credential helper, and connect once with ssh in a terminal to accept a new host.</p> <p><strong>Merges and rebases.</strong> <code>m</code> and <code>r</code> work where <code>f</code> does. While a merge or rebase is in progress (started by Ches or outside it), the head summary shows it and the key whose popup goes on: "Merging 1a2b3c4 (press m)", "Rebasing main onto 1a2b3c4 (press r)".</p> <ul> <li><code>m</code> with no merge in progress opens the merge popup for the branch under the Branches cursor, whichever panel has focus (<code>2</code> to choose one): <code>m</code> runs <code>git merge --no-edit <branch></code> ("Merge feature"). <code>-n</code> (<code>--no-ff</code>) always creates a merge commit and <code>-f</code> (<code>--ff-only</code>) merges only by fast-forward; at most one is on. Only local branches are listed (pull covers remote ones). With the cursor on a header: "Select the branch to merge in Branches (2) first; nothing ran"; on the current branch: "Cannot merge main into itself; nothing ran". Like a pull it is refused on a branch with no commits, while another operation is in progress, and with conflicted files.</li> <li>While merging, <code>m</code> opens the <code>Merging</code> popup: <code>m</code> commits the merge with git's prepared message (<code>git commit --no-edit --cleanup=strip</code>, which drops its <code># Conflicts:</code> comment lines), <code>a</code> asks before <code>git merge --abort</code>.</li> <li>While rebasing, <code>r</code> opens the <code>Rebasing</code> popup: <code>r</code> continues (<code>git rebase --continue</code>, keeping each commit's message), <code>s</code> skips the commit being applied ("Skip the commit being applied? Its changes are left out of the rebased branch."), <code>a</code> asks before <code>git rebase --abort</code>; the branch returns to where it was. Without a rebase, <code>r</code> says "No rebase in progress; nothing ran". Starting a rebase other than by pulling (<code>p -r p</code>) is not offered.</li> <li>Committing the merge and continuing are refused while a file is still conflicted ("Resolve the conflicted files first (s marks one resolved); nothing ran"). A merge, pull, continue or skip that stops on (new) conflicts fails with "<title> failed: Stopped on conflicts: resolve each file (x, or Space x in the editor), mark it resolved with s, then continue".</li> <li>Every one of these, and every resolution, rewrites the work tree: refused while a file in the repository has unsaved changes ("Continue rebase refused: unsaved changes in a.txt; save or undo them first; nothing ran"), and followed by comparing open buffers with disk.</li> </ul> <p><strong>Logs and history.</strong> <code>l</code> in a list panel opens the <code>Log</code> popup (in the diff <code>l</code> stays a motion). Its actions choose what Commits lists: <code>l</code> HEAD; <code>b</code> the branch under the Branches cursor, whichever panel has focus; <code>a</code> HEAD and every local and remote-tracking branch; <code>f</code> a file's history, following renames: in Files the selected file, in Branches and Commits the file of the diff line at the cursor. Switches: <code>-g</code> draws the graph (on at first), <code>-m</code> (<code>--no-merges</code>) omits merge commits, <code>-p</code> (<code>--first-parent</code>) follows only the first parent of merges. The choice, switches included, holds until the next one, also while the view is hidden, and the popup opens with its switches; <code>l l</code> returns to HEAD. Choosing focuses Commits with its cursor on the section title (<code>j</code> reaches the first commit). Without a branch or file to log: "Select a branch in Branches first", "Select a file first: a Files item, or a file in the diff".</p> <ul> <li>The Commits section's title names the log: <code>Recent commits</code>, <code>Commits on feature</code>, <code>All branches</code>, <code>History of src/a.ml</code>, with any qualifiers after it, as in <code>Commits on main (no merges, first parent, first 200)</code>. <code>first <n></code> means the log filled its limit, so there may be more: <code>+</code> in Commits doubles the limit, keeping the cursor, up to 12800 ("Showing the most commits already (12800)").</li> <li>Each row is the graph, the short hash, git's ref decorations, then the subject: <code>● a1b2c3d (HEAD -> main, origin/main, tag: v1) Subject</code>. The graph is drawn from the commits' parents, one row per commit as in lazygit, over commits in topological order: <code>●</code> is the commit, <code>│</code> a lane waiting for an older commit, a merge reads <code>●─╮</code> (a lane opens for its second parent) and a fork point <code>●─╯</code> (a lane joins). It is cut at 24 columns (<code>…</code>). There is no graph for a file's history or with <code>-m</code>; with <code>-p</code> it follows first parents only.</li> <li>A commit's diff starts with its file list, between the message and the first file, one line per file: the change letter (<code>A</code> added, <code>D</code> deleted, <code>M</code> modified, <code>R</code> renamed, <code>C</code> copied, <code>T</code> type changed, <code>U</code> unmerged), the path (the new one for a rename), <code>+added -removed</code> over the lines the diff shows (none for binary, mode-only and rename-only files), and <code>(truncated)</code> when the file's diff was cut short:</li> </ul> <div class="highlight"><pre><span></span><code>M src/view.ml +12 -3 R docs/new_name.md +1 -1 A logo.png </code></pre></div> <p><code>Enter</code> on a listed file jumps to its diff (<code>e</code> opens the file). <code>}</code> / <code>{</code> move between the files' first header lines, with counts (<code>3}</code>); at the ends they say "No next file" / "No previous file". - In a file's history a commit's diff is still the whole commit, but the cursor starts at that file (under the name it had in that commit). - <code>Space g l</code> in the editor shows the history of the file being edited (see <a href="#browsing-history">Browsing history</a>).</p> <p><code>e</code> in the diff opens the work-tree file at the line the cursor is on (for a removed line, the next line that survives; for a hunk header, its first line). From a tab, the file's tab replaces the view's; beside the split, the file shows in the editor pane, which gets focus. A commit's diff opens today's file at the commit's line numbers.</p> <p>The view refreshes when it opens, on <code>g r</code>, and after a save of a file inside the repository (at most once per save; saves inside <code>.git</code>, such as the commit message, do not count); it never polls or watches files. Its git commands run in the background, so the editor never waits for them; while one runs, the last state stays drawn. Git never prompts on the terminal (<code>GIT_TERMINAL_PROMPT=0</code>) nor starts an editor (<code>GIT_EDITOR=true</code>, so a continued rebase keeps each commit's message), and git's lock files are released on quit: Ches waits up to three seconds after the terminal closes for its git children to end. Outside a repository the view says <code>VCS: not a repository</code>; <code>g r</code> looks again. Paths, subjects and output from git are shown with control bytes escaped.</p> <h3 id="resolving-conflicts">Resolving conflicts<a class="headerlink" href="#resolving-conflicts" title="Permanent link">¶</a></h3> <p>A merge (<code>m m</code>) or a rebase pull (<code>p -r p</code>) that cannot apply every change stops with the conflicted files in the Files panel's <strong>Conflicted</strong> section, each with its kind (<code>both modified</code>, <code>deleted by them</code>, ...), and the head summary saying how to go on. Then, for each file:</p> <ul> <li>Take a whole side: <code>x</code> on the file opens <code>Resolve <path></code>: <code>o</code> takes ours, <code>t</code> theirs, and, for <code>both modified</code> and <code>both added</code>, <code>m</code> writes the conflict markers again, dropping edits made to the file (to start it over; the file stays conflicted). Taking a side checks that version out and stages it, which marks the file resolved; when that side has no file (<code>Take ours: delete the file (HEAD)</code>), the file is removed instead. Each asks first: "Take theirs (1a2b3c4) for a.txt? The other side's changes and any edits to the file are lost; it is marked resolved.", "Resolve a.txt by deleting it, as ours (HEAD) did? Any edits to the file are lost.", "Restore the conflict markers in a.txt? Edits to the file are lost." The popup names the sides:</li> </ul> <table> <thead> <tr> <th>Stopped in</th> <th>Ours (<code>o</code>)</th> <th>Theirs (<code>t</code>)</th> </tr> </thead> <tbody> <tr> <td>A merge</td> <td><code>HEAD</code>, the branch you are on</td> <td>The merged branch, by its abbreviated commit</td> </tr> <tr> <td>A rebase</td> <td><code>the upstream</code> being rebased onto</td> <td><code>your commit</code> being applied</td> </tr> </tbody> </table> <ul> <li>Or resolve it hunk by hunk: <code>Enter</code> on the file focuses its diff, which shows the conflict markers, and <code>Enter</code> (or <code>e</code>) on a line opens the file there. In the editor, <code>]n</code> / <code>[n</code> go to the next / previous conflict and <code>Space x u</code> / <code>l</code> / <code>a</code> / <code>b</code> keep its upper / lower / both / base side (see <a href="#conflict-markers">Conflict markers</a>; upper is ours, lower theirs, with the same swap while rebasing). Edit freely, <code>Space w</code> to save, return to the view and press <code>s</code> on the file to mark it resolved. <code>s</code> does not look for leftover markers: <code>G</code> then <code>[n</code> finds any.</li> </ul> <p>When the Conflicted section is empty, <code>m m</code> commits the merge, or <code>r r</code> continues the rebase. A rebase may stop again on a later commit's conflicts (resolve them the same way, or <code>r s</code> to leave that commit out); <code>m a</code> / <code>r a</code> abandon the whole operation. Unsaved buffers in the repository refuse continuing, committing, taking a side and aborting: save the resolutions first (or undo them).</p> <h3 id="browsing-history">Browsing history<a class="headerlink" href="#browsing-history" title="Permanent link">¶</a></h3> <p>Commits lists HEAD's latest 200 commits, with the graph and each commit's branches and tags. <code>3</code> focuses it; <code>j</code> / <code>k</code> move, and the diff follows, starting with the commit's file list. <code>Enter</code> (or <code>Tab</code>) focuses the diff: <code>}</code> jumps to the next file, or move to a listed file and press <code>Enter</code>; <code>e</code> opens the file at the cursor's line. <code>Tab</code> returns to Commits.</p> <p><code>l</code> changes the log. With a branch selected in Branches (<code>2</code>), <code>l b</code> lists it; <code>l a</code> lists every branch together, the graph showing where they fork and merge; <code>l - m l</code> reads HEAD without merges (and without the graph). The popup opens with the switches last chosen, so <code>l - m l</code> again brings merges back. When the title ends in <code>first 200</code>, <code>+</code> reads 400, then 800.</p> <p>For one file's history, press <code>Space g l</code> (palette <code>VCS: history of this file</code>) in its buffer: the view opens where it opens, or is shown, focused on Commits listing the commits that changed the file, across renames. Each commit's diff starts at that file. In the view, <code>l f</code> does the same for the selected Files item or the file of the diff line at the cursor. From a directory buffer or a view, <code>Space g l</code> says "No file buffer here: Space g l shows the history of the file you are in"; for a file outside the view's repository, "<file> is not in the repository at <root>". If the view has not found its repository yet, it shows the history once it has.</p> <h3 id="read-only-text-in-supporting-views">Read-only text in supporting views<a class="headerlink" href="#read-only-text-in-supporting-views" title="Permanent link">¶</a></h3> <p>Open details (problems, the demo report, and history) are read-only text, like a read-only buffer in a Neovim split, with the terminal cursor on the text cursor:</p> <table> <thead> <tr> <th>Details keys</th> <th>Action</th> </tr> </thead> <tbody> <tr> <td><code>h/l</code>, <code>0</code> <code>^</code> <code>$</code>, <code>w/b</code></td> <td>Move within the text (<code>0</code>/<code>$</code> and <code>^</code> use the whole logical line, not the wrapped row)</td> </tr> <tr> <td><code>j/k</code>, <code>gg/G</code>, <code>Ctrl-d/u</code></td> <td>Move by wrapped row, to the first/last row, or by half the view</td> </tr> <tr> <td>Count, e.g. <code>10j</code></td> <td>Repeat <code>h</code> <code>j</code> <code>k</code> <code>l</code> <code>w</code> <code>b</code> <code>Ctrl-d</code> <code>Ctrl-u</code> (<code>10j</code>, <code>3w</code>, <code>2 Ctrl-d</code>), stopping at the ends; <code>12G</code> or <code>12gg</code> goes to line 12</td> </tr> <tr> <td><code>v</code> / <code>V</code></td> <td>Characterwise / linewise Visual selection; again to end it, <code>o</code> swaps ends</td> </tr> <tr> <td><code>y</code> (Visual), <code>yy</code> / <code>Y</code></td> <td>Copy the selection, or the cursor's whole line</td> </tr> <tr> <td><code>e</code></td> <td>Close details (<code>Enter</code> also jumps in problems, <code>a</code> acknowledges)</td> </tr> <tr> <td><code>Escape</code></td> <td>End a selection, then close details, then return</td> </tr> </tbody> </table> <p>A copy goes where an editor yank goes: the unnamed register, so <code>p</code> in the editor pastes it, and the system clipboard. It copies the text itself, never the wrapping, padding, border, or markers, and shows <code>Copied …</code> in the view's footer. Copying and selecting never acknowledge, resolve, or jump. Edit keys (<code>i</code>, <code>x</code>, <code>d</code>, <code>p</code>, <code>u</code>, …) and pastes are rejected with a notice. If a problem's text changes while its details are open, the view takes the new text and ends any selection, saying so.</p> <h3 id="words-and-lines">Words and lines<a class="headerlink" href="#words-and-lines" title="Permanent link">¶</a></h3> <p><code>w</code>, <code>b</code>, and <code>e</code> treat a run of identifier characters (ASCII letters, digits, <code>_</code>, and every non-ASCII character) as a word, and a run of other non-blank characters (punctuation, such as <code>+=</code> or <code>(</code>) as another. <code>W</code>, <code>B</code>, and <code>E</code> treat any run of non-blank characters as one word. Blanks are space, TAB, and line breaks. As in Vim, <code>w</code> and <code>b</code> stop on empty lines and <code>e</code> skips them.</p> <ul> <li><code>w</code> goes to the start of the next word; after the last word it goes to the end of the text. <code>b</code> goes to the start of the current or previous word. <code>e</code> goes to the end of the current or next word, and stays put when there is none.</li> <li><code>^</code> goes to the first character that is not a space or TAB (the last character of an all-blank line). <code>_</code> does the same, but takes a count like <code>$</code>: <code>3_</code> is the first non-blank two lines down. (Later, under operators, <code>_</code> is linewise.)</li> <li><code>g_</code> goes to the last character that is not a space or TAB (the start of an all-blank line), with the same count rule. Without trailing blanks it lands where <code>$</code> does.</li> <li><code>G</code> goes to the last line, and <code>gg</code> to the first, at its first non-blank. With a count, both go to that line: <code>20G</code> and <code>20gg</code> are line 20, and <code>999G</code> stops at the last line. A file ending in a line break has an empty last line after it, so <code>G</code> (and <code>w</code> after the last word) goes there.</li> </ul> <h3 id="matching-delimiters">Matching delimiters<a class="headerlink" href="#matching-delimiters" title="Permanent link">¶</a></h3> <p><code>%</code> finds the first <code>(</code>, <code>)</code>, <code>[</code>, <code>]</code>, <code>{</code>, or <code>}</code> at or after the cursor on its line and jumps to its mate: forward from an opening delimiter, backward from a closing one, across lines, skipping properly nested pairs of all three kinds.</p> <ul> <li>Matching is lexical: delimiters in strings and comments count too.</li> <li>Mixed kinds nest on one stack, so in <code>( ] )</code> the <code>(</code> has no match. A misnested or missing mate shows <code>No match for (</code> and the cursor stays.</li> <li>With no delimiter from the cursor to the line end, it shows <code>No delimiter on this line</code> and the cursor stays.</li> <li>It takes no count: <code>50%</code> (Vim's jump to a percentage of the file) is rejected.</li> </ul> <h3 id="conflict-markers">Conflict markers<a class="headerlink" href="#conflict-markers" title="Permanent link">¶</a></h3> <p>When git cannot merge a file it writes both versions into it between marker lines. The editor finds these regions in any buffer, whatever wrote them, and resolves one at a time, as Emacs's smerge does:</p> <div class="highlight"><pre><span></span><code> <<<<<<< HEAD the upper side follows ours ||||||| merged ancestors the base part (only with merge.conflictStyle=diff3 or zdiff3) base ======= the lower side follows theirs >>>>>>> feature the end of the region </code></pre></div> <p>(Indented here so that this file is not itself conflicted: real markers start their lines.)</p> <table> <thead> <tr> <th>Keys</th> <th>Action</th> </tr> </thead> <tbody> <tr> <td><code>]n</code> / <code>[n</code></td> <td>Go to the start line (<code><<<<<<<</code>) of the next / previous region; <code>3]n</code> goes three on</td> </tr> <tr> <td><code>Space x u</code></td> <td>Keep the upper side</td> </tr> <tr> <td><code>Space x l</code></td> <td>Keep the lower side</td> </tr> <tr> <td><code>Space x a</code></td> <td>Keep both: the upper side, then the lower</td> </tr> <tr> <td><code>Space x b</code></td> <td>Keep the base part</td> </tr> </tbody> </table> <p>The palette lists them as <code>Conflict: keep upper (ours)</code>, <code>Conflict: keep lower (theirs)</code>, <code>Conflict: keep both</code>, <code>Conflict: keep base</code>, <code>Conflict: next</code> and <code>Conflict: previous</code> (<code>conflict.keep-upper</code>, ..., <code>conflict.next</code>, <code>conflict.previous</code>).</p> <p>What the sides are depends on what stopped:</p> <table> <thead> <tr> <th>Stopped in</th> <th>Upper (<code><<<<<<<</code>)</th> <th>Lower (<code>>>>>>>></code>)</th> </tr> </thead> <tbody> <tr> <td>A merge (<code>m m</code> in the VCS view, <code>git merge</code>)</td> <td>Ours: <code>HEAD</code>, the branch you are on</td> <td>Theirs: the branch being merged</td> </tr> <tr> <td>A rebase (<code>p -r p</code> in the VCS view, <code>git pull --rebase</code>)</td> <td>The upstream you are rebasing onto</td> <td>Your commit being replayed</td> </tr> </tbody> </table> <p>The labels after the markers say which is which (<code>HEAD</code>, a branch name, or a commit and its subject while rebasing; markers written again by the VCS view's <code>x</code> then <code>m</code> say <code>ours</code> and <code>theirs</code>), and the feedback repeats them.</p> <ul> <li><code>Space x</code> acts on the region containing the cursor's line, markers included: the whole region is replaced by the side's lines, and the cursor goes to the first of them (or, when that side is empty, to the line now where the region was). The feedback says what was kept, e.g. <code>Kept upper (HEAD)</code> or <code>Kept both (HEAD, feature)</code>.</li> <li>It is one undo step: <code>u</code> brings the markers back. The buffer is marked modified and nothing is saved until <code>Space w</code>; marking the file resolved in git is a separate step (<code>s</code> in the VCS view, see <a href="#resolving-conflicts">Resolving conflicts</a>).</li> <li>Outside a region it shows <code>No conflict at the cursor</code>; <code>Space x b</code> on a region without a base part shows <code>This conflict has no base part (merge.conflictStyle=diff3 shows one)</code>. Neither changes anything.</li> <li><code>]n</code> and <code>[n</code> count only complete regions. From inside a region, <code>[n</code> goes to its start line. A count beyond the last region stops at the last; with none in that direction they show <code>No more conflicts</code> and the cursor stays. They extend a Visual selection, and after <code>d</code> or <code>y</code> they are linewise (<code>d]n</code> deletes through the next start line).</li> <li><code>Space x</code> works in Normal mode only, and, like other edits, not from a supporting view's read-only text.</li> <li>A region is recognised only in git's default form: start, base and end lines begin with exactly seven <code><</code>, <code>|</code> or <code>></code> followed by a space or the line end, and the separator is exactly seven <code>=</code>. Other marker sizes (<code>conflict-marker-size</code>), indented markers, and regions that are unterminated or out of order (an end before the separator, a second base or separator) are left alone as ordinary text; a new start line before the end starts over. Markers are not highlighted.</li> </ul> <h3 id="counts">Counts<a class="headerlink" href="#counts" title="Permanent link">¶</a></h3> <p>In Normal mode, digits before a movement key repeat it: <code>20j</code> moves down 20 lines, <code>5l</code> moves right 5 characters, and <code>3w</code> moves 3 words. A count stops at the edge rather than failing: <code>999j</code> near the end goes to the last line, and <code>20l</code> on a short line goes to its last character. The status line shows a count while you type it, with any keys of the sequence after it (<code>20 g</code>, <code>3 Space v</code>).</p> <ul> <li><code>1</code>–<code>9</code> start a count, and any digit, including <code>0</code>, extends it. A bare <code>0</code> is the line-start motion: <code>10j</code> moves 10 lines, and <code>0</code> then goes to the line start.</li> <li>Counts go up to 999999. Typing a larger one cancels it with a message.</li> <li><code>$</code>, <code>_</code>, and <code>g_</code> with a count N go to the Nth line, counting the current line as the first. <code>G</code> and <code>gg</code> with a count go to that line.</li> <li><code>0</code>, <code>^</code>, <code>%</code>, and <code>zz</code>/<code>zt</code>/<code>zb</code> take no count. <code>x</code>, <code>X</code>, <code>p</code>, and <code>P</code> take a count; operator and motion counts multiply (<code>2d3w</code> deletes and <code>2y3w</code> yanks six words). A count repeats a resize step as that many presses would: <code>3 Space v +</code> widens the text by 30 cells, and <code>Space v h</code>/<code>l</code>/<code>H</code>/<code>L</code>, <code>Space s +</code>/<code>-</code>, <code>Space v p +</code>/<code>-</code>, and <code>Space d +</code>/<code>-</code> work the same way, stopping at their usual limits. A count before an unsupported command, such as <code>3^</code>, <code>2 Space w</code>, or <code>2 Space v c</code>, is rejected with a message.</li> <li><code>Escape</code> cancels a pending count silently. A key that is not bound after a count, <code>Ctrl-c</code>, or a paste also cancels it. Nothing typed before a cancellation carries over to the next key.</li> </ul> <h3 id="delete-yank-and-paste">Delete, yank, and paste<a class="headerlink" href="#delete-yank-and-paste" title="Permanent link">¶</a></h3> <p><code>d</code> waits for a supported motion: <code>dw</code>, <code>db</code>, <code>de</code>, <code>d$</code>, <code>dj</code>, <code>dgg</code>, <code>dG</code>, <code>d_</code>, <code>dg_</code>, <code>d%</code>, and <code>diw</code> are available. <code>dd</code> deletes the current line, <code>D</code> is <code>d$</code>, and <code>x</code>/<code>X</code> delete forward/backward without crossing a line break. A successful delete replaces the unnamed internal register (characterwise, linewise, or blockwise). Escape cancels a pending <code>d</code> sequence without changing text or that register. Every complete delete, including a counted one, is one undo step.</p> <p><code>y</code> accepts the same supported motions (apart from the deliberately narrow <code>diw</code> text object); <code>yy</code> yanks logical lines. Yanking changes neither text, cursor, history, nor dirty state. <code>p</code> inserts characterwise text after the cursor and <code>P</code> before it; linewise text goes below/above the current line. A paste count repeats the register in one undo step. Characterwise paste leaves the cursor on its last inserted code point; linewise paste puts it at the first non-blank of its first inserted line. An unset register reports feedback. Undo and redo do not restore the register.</p> <p>Whenever a delete or yank replaces the register, ches also copies its text to the system clipboard, like Vim's <code>clipboard=unnamedplus</code>. Linewise text ends with a newline, and a block's rows are joined by newlines. The copy is an OSC 52 escape sequence sent to the terminal, so it reaches the clipboard of the machine running the terminal, including over SSH. The terminal must allow it: Ghostty, kitty and WezTerm do by default; under tmux, set <code>set-clipboard on</code>. <code>p</code> still pastes the internal register; paste from the system clipboard with the terminal's own paste.</p> <p><code>dw</code> stops at a line end rather than consuming its newline and the next line's indentation. <code>d%</code> includes both matching delimiters; an unmatched <code>%</code> does nothing. Linewise deletes at EOF preserve the editor's invariant that an empty document has one logical empty line.</p> <h3 id="visual-selection">Visual selection<a class="headerlink" href="#visual-selection" title="Permanent link">¶</a></h3> <p><code>v</code> anchors a characterwise selection at the cursor and <code>V</code> anchors a linewise selection. Ordinary motions (including counted motions and <code>%</code>) move the active end; reversing direction is supported. <code>v</code> and <code>V</code> switch its kind without losing the anchor. Selection highlighting takes precedence over search and current-line highlighting while the terminal cursor remains visible. <code>d</code>, <code>c</code>, and <code>y</code> use the same typed unnamed register and range behavior as their Normal mode counterparts. Delete and change are each one undo step; yank returns to Normal mode at the selected range's start without changing history. Visual paste, text objects, and search prompts in Visual mode are not supported.</p> <p>As in Vim, <code>l</code>, <code>j</code>, <code>k</code>, and <code>$</code> in Visual mode can put the cursor on the line break after the last character, so <code>v$</code> selects through the end of the line including its newline (<code>v$d</code> on <code>abc</code> / <code>def</code> leaves <code>def</code>). Leaving Visual mode steps back off the line break.</p> <p><code>Ctrl-v</code> selects a rectangle of screen columns, as in Vim. Each corner covers the whole character it is on, so a corner on a TAB or wide character covers all of its cells; reversed and upward selections give the same rectangle. After <code>$</code> the block reaches each line's own end until another horizontal move. TAB cells are highlighted only where they fall inside the block, a wide character cut by an edge is highlighted whole, and lines shorter than the block show no highlight. Selecting changes nothing.</p> <p><code>d</code> and <code>y</code> on a block put it in the register as one row per line, as Vim does: a line too short to reach the block contributes a row of spaces (one that ends at the block's first column, nothing), a line ending inside it only its text, and a TAB or wide character cut by an edge spaces for its cells inside the block. <code>d</code> removes the selected cells, leaving spaces for the outside cells of a cut TAB or wide character, in one undo step; both leave the cursor at the block's top-left. <code>p</code>/<code>P</code> with a block register put each row after/before the cursor's column on successive lines: short lines are padded up to the column, a TAB under it is split into spaces, a wide character under it moves right, and rows past the last line add lines (keeping a final newline final). Rows are padded to the block's width when text follows them, so it stays lined up; a count repeats each row along its line. A paste is one undo step with the cursor at its top-left. Unlike Vim, padding measures a TAB inside a row where it lands rather than as a full tab stop.</p> <p><code>I</code> and <code>A</code> on a block start a block insert: Insert mode with an insertion point on every line of the block, before its left edge for <code>I</code> and after its right edge for <code>A</code> (after <code>$</code>, at each line's own end). <code>c</code> deletes the block and inserts at its left edge. Unlike Vim, which copies the text to the other lines when you leave Insert mode, typing appears on every line as you type. Every insertion point is drawn as a colored cell: the cursor itself, on the top line, in blue, and its copies on the other lines in light grey (the terminal's own cursor is hidden meanwhile; change the palette's <code>Block_cursor</code> and <code>Block_copy</code> roles in <code>theme/theme.ml</code>). As in Vim, <code>I</code> and <code>c</code> skip lines too short to reach the left edge, <code>A</code> pads short lines with spaces, a TAB under the insertion column is split into spaces, and a wide character there moves right. Backspace (and soft-tab Backspace) removes only what was typed in this insert. Enter, a paste containing a newline, and Delete are refused with a message, because they would make the lines differ. A count (<code>2I</code>) repeats the typed text when you leave. The whole insert, including <code>c</code>'s deletion, is one undo step, and none if nothing was typed. After <code>I</code> or <code>A</code> the cursor goes to the block's top-left, as in Vim. <code>I</code> and <code>A</code> on a characterwise or linewise selection are not supported (they report so).</p> <p><code>f{character}</code>/<code>F{character}</code> find a literal code point strictly forward or backward on the current line; <code>t</code>/<code>T</code> stop just before/after it. Counts repeat the find, <code>;</code> repeats the last successful find, and <code>,</code> repeats it in the opposite direction without changing what <code>;</code> means. They work as operator motions too (<code>df)</code> and <code>dt,</code>); Escape cancels while waiting for the literal argument, and a failed find retains the previous successful one.</p> <p>Search results are highlighted while a query is active; the current result uses a distinct highlight. Searches use smart ASCII case by default: a query with an upper-case ASCII letter is case-sensitive, while an all-lowercase query matches ASCII letter case-insensitively. The core's <code>Editor.create</code> also accepts a <code>search_case</code> preference (<code>Smart</code>, <code>Sensitive</code>, or <code>Insensitive</code>) for alternate frontends. <code>*</code> and <code>#</code> search the small word under the cursor as a whole word (so <code>cat</code> does not match <code>scatter</code>); on whitespace they report that there is no word. The query and highlighting are derived from the current text, so edits cannot retain stale match positions. In Normal mode, <code>Escape</code> clears the highlighting while retaining the query for <code>n</code>/<code>N</code>. While typing <code>/</code> or <code>?</code>, its nonempty query highlights matches immediately but does not move the cursor; cursor-following incremental search is deferred as a future setting.</p> <h3 id="reloading-a-file">Reloading a file<a class="headerlink" href="#reloading-a-file" title="Permanent link">¶</a></h3> <p>In Normal mode, type <code>:e!</code> then <code>Enter</code> to discard all unsaved buffer changes and replace the buffer with the current contents of its associated file. It also clears undo/redo history. Escape cancels the small command prompt. This is deliberately the only <code>:</code> command currently supported; an unknown command reports feedback without changing the buffer.</p> <p>Soft tabs work like Vim's <code>softtabstop</code>: <code>Tab</code> inserts spaces up to the next multiple of 2 screen columns (a TAB before the cursor counts for its width), and in Insert mode <code>Backspace</code> deletes spaces back to the previous multiple, or one character if there is no space before the cursor. <code>Backspace</code> at the start of a line joins it to the line above, and <code>Delete</code> at the end of a line joins the line below. <code>x</code> never deletes a line break.</p> <p><code>j</code> is inserted when you type it; a <code>k</code> straight after it deletes the <code>j</code> and returns to Normal mode. No timeout is involved, and typed text is never held back, but you cannot type <code>jk</code> itself (paste it instead). Tab width, the <code>j k</code> escape, and the Normal-mode bindings are settings in <code>Keymap.Config</code>, chosen in code; there is no configuration file. The bindings are a table (<code>input/bindings.ml</code>) checked when it is built: a key sequence bound twice, a sequence that is a prefix of another (which could never run, since there is no timeout), a sequence starting with <code>1</code>–<code>9</code> (which starts a count), or one using <code>Escape</code> or <code>Ctrl-c</code> is an error.</p> <h3 id="entering-insert-mode-and-autoindent">Entering Insert mode and autoindent<a class="headerlink" href="#entering-insert-mode-and-autoindent" title="Permanent link">¶</a></h3> <p><code>a</code> on an empty line inserts at the cursor, and <code>I</code> on an all-blank line inserts at its end. <code>o</code> and <code>O</code> work on the last line with or without a final line break and in an empty file. Opening a line and the typing that follows are one undo step, which restores the cursor to where it was before <code>o</code>/<code>O</code>. These commands take no count (<code>3o</code> is rejected with a message); Vim's repeated insertion is not supported.</p> <p>Autoindent is literal and knows nothing about the language: <code>o</code> and <code>O</code> copy the current line's leading spaces and TABs, and <code>Enter</code> copies the part of them that is before the cursor (so <code>Enter</code> inside the indentation copies only what is to its left). Text after the cursor moves to the new line unchanged, leading blanks included. Unlike Vim, the copied indentation stays when you leave Insert mode without typing anything. A paste is inserted literally, without indentation.</p> <h3 id="shifting-indentation">Shifting indentation<a class="headerlink" href="#shifting-indentation" title="Permanent link">¶</a></h3> <p><code>>></code> and <code><<</code> shift the current line right or left by one indentation step. A Normal-mode count chooses how many lines to shift, clamped at the end of the buffer: <code>3>></code> shifts three lines once. In every Visual selection kind, <code>></code> and <code><</code> shift the full touched lines and return to Normal mode; here a count chooses the number of steps, so <code>3></code> shifts the selection by six columns with the defaults. A characterwise selection whose later endpoint is exactly at the next line's start excludes that final line. Linewise and blockwise selections include both endpoint lines. Shifting a block affects whole lines, not just its rectangle.</p> <p>The default step is two display columns, added or subtracted without rounding to a multiple; left shifts clamp at zero. TABs in existing indentation use eight-column display stops. Rewritten indentation uses spaces by default, preserving all text after the leading whitespace and the file's final-newline state. Normal/Visual right shifts skip empty and whitespace-only lines; left shifts can remove their indentation. Each Normal/Visual operation is one undo step, leaves the unnamed register alone, and places the cursor at the first shifted line's first nonblank. A shift that changes no bytes creates no undo entry or text revision.</p> <p>Insert <code>Ctrl-t</code> / <code>Ctrl-d</code> shift the current line while keeping Insert mode and tracking the insertion point relative to its text. They can build indentation on an empty line and join the current Insert undo transaction. During a block insert, they finish multi-line replication and shift only the current line; prior replicated typing stays in the same transaction. A cursor inside rewritten indentation tracks its display column, clamped to the new prefix; a column inside a TAB lands before it.</p> <p>The core accepts <code>Editor.create ~indentation</code> with an <code>Indentation.Policy.t</code> (<code>shift_width</code>, positive, and <code>use_tabs</code>). A tabs policy emits whole TABs followed by remainder spaces. This policy is separate from <code>Keymap.Config.tab</code>, which controls Insert Tab/Backspace soft tabs. Defaults are chosen in code; there is no runtime settings prompt. Motion-based shifts such as <code>>j</code>, counts between the two keys such as <code>2>3></code>, <code>=</code> reindent, and language-aware indentation are not yet implemented.</p> <p><code>Space</code> starts a sequence only in Normal mode. While a sequence is pending, the status line shows its keys. An unbound continuation such as <code>Space z</code> does nothing except report <code>Space z is not bound</code>. Sequences have no timeout.</p> <p>Pasting (with a terminal that supports bracketed paste) inserts the text literally in Insert mode and is ignored in Normal mode. Arrow keys and the mouse are not used. SIGTERM or SIGHUP ends the editor, discarding unsaved changes, after restoring the terminal.</p> <h2 id="syntax-highlighting">Syntax highlighting<a class="headerlink" href="#syntax-highlighting" title="Permanent link">¶</a></h2> <p>Ches highlights OCaml implementation (<code>.ml</code>) and interface (<code>.mli</code>) files, plus SystemVerilog (<code>.sv</code>, <code>.svh</code>), Verilog (<code>.v</code>, <code>.vh</code>), and AT&T/GAS assembly (<code>.s</code>, <code>.S</code>), locally with Tree-sitter. <code>.asm</code> is unsupported, not Intel syntax. Verilog uses the SystemVerilog grammar. Suffix detection is case-sensitive: <code>.ML</code>, <code>.SV</code>, extensionless files, unsupported languages, and buffers without a path stay plain text. No language server, network access, external query files, or Neovim installation is needed at runtime. Syntax highlighting does not change editing, <code>%</code>, saved bytes, registers, dirty state, or undo/redo.</p> <p>Keywords, strings/escapes, numbers, nested comments and structural type/function/ module/constructor constructs receive colors. This is grammatical highlighting, not semantic name resolution; it does not know a symbol's meaning across files. Incomplete and malformed code is normal input and can still receive useful colors. Assembly directives, mnemonics and prefixes are keywords; registers are constants; labels and numeric local references are functions; symbols are variables; relocation modifiers and directive types such as <code>@function</code> are properties. Numbers, strings and comments retain their usual categories. The grammar supports numeric local labels, immediate/displacement arithmetic and simple assignments, but is not an assembler validator. x87 <code>%st(0)</code>, AVX-512 decorators, relocation modifiers in directive arguments, multiple same-line labels and <code>rep; ret</code> are not fully supported. <code>.S</code> preprocessor lines are treated as comments, not C-preprocessor syntax. If provider initialization or parsing fails, the current document renders as plain text rather than keeping stale colors. This does not block editing or saving or replace editor feedback; a later text change or successful reload retries it.</p> <p>The controller caches highlights by document identity, revision, language and query version. Text changes use incremental parsing with a private copied/edited prior tree; <code>:e!</code> resets it. Movement, search, selection, scrolling, resizing, animation and saving unchanged text do not parse. Synchronous highlighting is limited to <strong>65,536 bytes, 2,000 lines and 16,000 query captures</strong> (inclusive). Lines include the empty final line after a trailing LF. Byte/line checks happen before provider creation or parsing; capture collection stops at the first excess result, including duplicate/ignored captures. Outside this policy the entire current revision renders plain, with no stale or partial syntax spans and no repeated warning notifications. <code>Controller.highlight_status</code> records <code>Source_byte_limit</code>, <code>Source_line_limit</code> or <code>Capture_limit</code> with the limit. Search/selection and other overlays still work.</p> <p>Byte/line fallback recovers automatically when the text fits both limits. Capture fallback remains plain across small edits and retries after at least a <strong>25% byte or line-count shrink</strong> relative to the failing revision, a successful <code>:e!</code> reload, or language-association reset. A same-size syntax simplification may therefore stay plain until reload. The limits are fixed implementation policy, not user settings.</p> <p>Within policy, the full tree is still queried and ranges normalized on each edit. A local 205 KB generated fixture fell from 83.079 to <strong>0.643 ms/edit</strong> with plain fallback; a highlighted 50,707-byte <code>core/editor.ml</code> fell from 15.544 to <strong>8.761 ms/edit</strong> after capture/normalization improvements. These are measurements, not guarantees. There is no parser/query timeout in the binding: a dense source's first parse and up to 16,001 capture calls can still delay input before fallback is latched. Whole-string editing remains size-dependent. Native memory release relies on binding GC finalizers, with limited external-memory accounting. See the <a href="https://github.com/bopurtell/cobalt/blob/6c0a8080aa5479916d893e5778ca55bc704e3b59/docs/syntax_highlighting_latency_plan.md">latency handoff</a>.</p> <p>Syntax colors come from the active semantic palette in <code>theme/theme.ml</code>, mapped to terminal attributes by <code>ui/theme.ml</code>. Variables/operators/punctuation use ordinary text color. Special-display escapes/clip markers take precedence over syntax; interaction overlays on complete glyphs take precedence over both. Clipped wide/escape fragments keep their special treatment, and combining marks retain their base text style. Block-insert points override selection, which overrides search; syntax returns when the overlay clears. Current-line background is independent, and blank padding is not syntax-colored. Theme changes recolor the existing semantic spans without reparsing the document or adding font styles.</p> <p>The pinned <strong><code>tree-sitter.0.1.0</code></strong> opam package supplies the compiled-in runtime and the OCaml grammars (<code>tree-sitter</code> and <code>tree-sitter.ocaml</code> Dune libraries). The SystemVerilog grammar is pinned and bundled in <code>highlight_tree_sitter/grammar</code>; its generated C parser is stored compressed and expanded by <code>gzip</code> during the build. The locally patched GAS grammar is bundled similarly in <code>highlight_tree_sitter/gas_grammar</code>; its upstream license is GPLv3, not the license of Ches-authored code. See its <a href="https://github.com/bopurtell/cobalt/blob/6c0a8080aa5479916d893e5778ca55bc704e3b59/highlight_tree_sitter/gas_grammar/ASSETS.md">asset record</a> for notices, regeneration and distribution implications. The GAS grammar handles compiler debug <code>.file</code>/<code>.loc</code> whitespace-separated arguments and their following instructions; other directive argument lists remain comma-separated. Building needs a C compiler and gzip, not Node, a Tree-sitter CLI or grammar regeneration. Queries are Ches-owned, predicate-free strings in <code>highlight_tree_sitter/ocaml_queries.ml</code>, <code>systemverilog_queries.ml</code> and <code>gas_queries.ml</code>. Packaging, ownership and unresolved bundled-asset provenance/license-notice findings are recorded in <a href="https://github.com/bopurtell/cobalt/blob/6c0a8080aa5479916d893e5778ca55bc704e3b59/highlight_tree_sitter/ASSETS.md"><code>highlight_tree_sitter/ASSETS.md</code></a>; technical verification is not a license-compliance finding.</p> <p>Regression tests run with <code>dune runtest</code>; explicit performance probes are separate:</p> <div class="highlight"><pre><span></span><code>opam<span class="w"> </span><span class="nb">exec</span><span class="w"> </span>--switch<span class="o">=</span><span class="m">5</span>.2.0+ox<span class="w"> </span>--<span class="w"> </span>dune<span class="w"> </span><span class="nb">exec</span><span class="w"> </span>-j<span class="w"> </span><span class="m">10</span><span class="w"> </span>./scripts/syntax_incremental_probe/probe.exe opam<span class="w"> </span><span class="nb">exec</span><span class="w"> </span>--switch<span class="o">=</span><span class="m">5</span>.2.0+ox<span class="w"> </span>--<span class="w"> </span>dune<span class="w"> </span><span class="nb">exec</span><span class="w"> </span>-j<span class="w"> </span><span class="m">10</span><span class="w"> </span>./scripts/syntax_live_probe/probe.exe </code></pre></div> <p>The terminal checklist below covers visual review. See <a href="https://github.com/bopurtell/cobalt/blob/6c0a8080aa5479916d893e5778ca55bc704e3b59/docs/archive/syntax_highlighting_plan.md"><code>docs/archive/syntax_highlighting_plan.md</code></a> for measurements, check outcomes and the acceptance handoff.</p> <h2 id="text">Text<a class="headerlink" href="#text" title="Permanent link">¶</a></h2> <p>Ches edits UTF-8 text with LF line endings. Opening a file fails with a clear error, instead of silently converting it, if the file has invalid UTF-8, a CR byte (CRLF or bare CR line endings), or a NUL byte. Typed and pasted text follows the same rules: text that breaks them is rejected with a <code>Rejected text: ...</code> message. Saving writes the text back exactly as it is, including whether it ends with a newline.</p> <p>Cursor movement and deletion work on Unicode code points, and the status-line column counts code points; <code>j</code>/<code>k</code> and soft tabs use screen columns. On screen, characters take their terminal width (CJK characters take two cells), a TAB expands to the next multiple of 8 cells, and control characters are drawn as escape forms (see <a href="#screen">Screen</a>).</p> <h2 id="undo">Undo<a class="headerlink" href="#undo" title="Permanent link">¶</a></h2> <p><code>u</code> and <code>Ctrl-r</code> work in Normal mode, and they restore both the text and the cursor.</p> <ul> <li>Everything typed in one visit to Insert mode, including Backspace, Delete, Enter, and pastes, is one undo step. Leaving Insert mode ends the step.</li> <li>Each Normal-mode edit (<code>x</code>) is its own step.</li> <li>Moving and switching modes add no steps.</li> <li>A new edit after an undo discards the redo history.</li> <li><code>[+]</code> means the text differs from what was last saved. Undoing back to the saved text clears it, so a plain <code>Space q</code> then works.</li> </ul> <p>History is kept for the session only, as whole-text snapshots (see <a href="#storage">Storage</a>). Each buffer defaults to at most <strong>1,000 complete transactions</strong> and <strong>64 MiB of estimated retained bytes</strong>, across undo and redo together. Older steps are evicted only when a changed transaction closes. The newest complete step always survives even if it exceeds the soft byte budget, so large files still have at least one undo step. A no-net-change transaction preserves redo and retention.</p> <h2 id="screen">Screen<a class="headerlink" href="#screen" title="Permanent link">¶</a></h2> <p>The text sits in a tile centered on the screen, 100 cells wide when there is room, with the filename in its top border. The status line at the bottom shows the mode, filename, <code>[+]</code> when there are unsaved changes, pending keys, the line and column (one-based; the column counts code points), and the latest message. Between the left border and the gutter (or the text, with no gutter) are 2 blank cells of padding, outside the text width. On a small screen the border goes first, then the padding and gutter together; status fields are dropped from the least important up.</p> <p>Line numbers are off by default. <code>Space v n</code> and <code>Space v N</code> toggle Vim's <code>number</code> and <code>relativenumber</code> switches independently, giving four styles: off (neither, with no gutter), absolute (<code>n</code> only), relative (<code>N</code> only; the cursor line shows <code>0</code>), and hybrid (both: the cursor line shows its own number, left-aligned, and every other line its distance from the cursor). The gutter is <code>max(3, digits in the line count)</code> cells plus a separator in every numbered style, so switching between them or moving the cursor never shifts the text. With numbers off, a centered tile with room keeps its text width and narrows, so the text moves left by about half a gutter; at full width, or when the screen limits the width, the text gets the gutter's cells instead. Numbers off also lets the border fit on a slightly narrower screen.</p> <p>The view scrolls only as far as it must to keep the cursor visible: there is no scroll margin, and long lines scroll sideways rather than wrap. When the terminal is resized, the tile, gutter, and scroll are fitted to the new size at once, without waiting for a key. Any size works, down to 1×1; when no text cell fits, the cursor is hidden until there is room again.</p> <p>The cursor is a steady block in Normal mode and a steady bar in Insert mode, where the terminal supports cursor shapes. Quitting restores the terminal's own cursor.</p> <h3 id="scrolling-the-view">Scrolling the view<a class="headerlink" href="#scrolling-the-view" title="Permanent link">¶</a></h3> <p><code>Ctrl-e</code> and <code>Ctrl-y</code> scroll the view down and up by a line, or by N with a count, as in Vim. The cursor stays on its line while that line is visible; when it would scroll out of view, the cursor moves to the nearest visible line, keeping its column as <code>j</code> and <code>k</code> do. <code>Ctrl-d</code> and <code>Ctrl-u</code> move both the view and the cursor by half the text rows (at least 1), or by N lines with a count (for that use only; Vim's <code>scroll</code> setting is not supported). <code>zz</code>, <code>zt</code>, and <code>zb</code> put the cursor line at the middle, top, or bottom of the view without moving the cursor; they take no count.</p> <ul> <li>At the end, <code>Ctrl-e</code> can scroll until the last line is at the top, and <code>zt</code> can put the last line there. Moving the cursor within the view then leaves it as it is. <code>Ctrl-d</code> stops scrolling once the last line is at the bottom but keeps moving the cursor, so repeating it reaches the last line.</li> <li>At the start, scrolling stops at line 1, and <code>Ctrl-u</code> then moves only the cursor. Nothing happens at either end once there is nowhere to go, and there is no message.</li> <li>A resize fills a view scrolled past the end, so it is not partly empty while earlier lines are hidden; so does the first key typed after a resize. Ordinary movement does not.</li> <li>These keys are Normal-mode only; in Insert mode they do nothing. They never edit: no undo step, no dirty marker.</li> </ul> <h3 id="layout-controls">Layout controls<a class="headerlink" href="#layout-controls" title="Permanent link">¶</a></h3> <p>The default layout is a centered tile with a text width of 100 cells, an offset of 0, and no line numbers. The text width counts only text cells, not the padding, gutter, or border. The left padding has no key; it is <code>left_padding</code> in <code>Geometry.Prefs.default</code> (<code>screen/geometry.ml</code>). <code>Space v r</code> returns to this default.</p> <p>The <code>Space v</code> commands change the layout, never the document: they make no edits, move no cursor, and leave undo history and the dirty state alone. Moving the tile or changing its width also switches back from full width to centered. The requested text width is kept within 20–500 cells and the offset within ±500. When the screen is too small for a request, the tile is clamped to fit, and the request is kept, so the layout comes back when the screen grows. The status line shows the request and, when it differs, what fits: <code>Width 110 (74 fit)</code>, <code>Offset +40 (+12 fit)</code>. Toggling and resetting report <code>Centered</code>, <code>Full width</code>, or <code>Layout reset</code>; the line-number toggles report the new style, noting when the screen is too small for a gutter: <code>Line numbers: relative (no room)</code>. They take no count. Layout preferences last for the session only: every run starts with the default layout.</p> <h3 id="colors-and-safe-display">Colors and safe display<a class="headerlink" href="#colors-and-safe-display" title="Permanent link">¶</a></h3> <p>Ches includes <strong>52 themes: 34 dark and 18 light</strong>. Vim Classic is the default; Midnight, Crimson, Ember, and Glacier retain their original colors. Other palettes are curated designs or adaptations rather than exact ports of upstream themes. Examples include Abyss, Moss, Orchid, Cobalt Room, Paper, Porcelain, Terminal Amber, Terminal Green, and neutral monochrome Graphite, Newsprint, Silver Night, and Ivory Ink.</p> <p>The metallic family includes Copper and eight additional palettes:</p> <table> <thead> <tr> <th>Theme ID</th> <th>Kind</th> <th>Character</th> </tr> </thead> <tbody> <tr> <td><code>silver</code></td> <td>Dark</td> <td>Cool slate with luminous silver-blue accents</td> </tr> <tr> <td><code>silver-frost</code></td> <td>Light</td> <td>Icy silver with crisp, deeper syntax colors</td> </tr> <tr> <td><code>silver-tarnish</code></td> <td>Dark</td> <td>Aged silver with a subtle green cast</td> </tr> <tr> <td><code>gold</code></td> <td>Dark</td> <td>Rich gold on a warm, dark ground</td> </tr> <tr> <td><code>gold-antique</code></td> <td>Dark</td> <td>Muted bronze and olive-gold</td> </tr> <tr> <td><code>gold-champagne</code></td> <td>Light</td> <td>Warm champagne with ochre accents</td> </tr> <tr> <td><code>platinum</code></td> <td>Light</td> <td>Refined cool neutrals with a faint lavender cast</td> </tr> <tr> <td><code>iron</code></td> <td>Dark</td> <td>Industrial charcoal with rust and steel-blue accents</td> </tr> </tbody> </table> <p>For nostalgic Vim colors, <strong>Vim Classic</strong> (<code>vim-classic</code>) uses a pure-black document, backdrop, and current line with yellow keywords, pink strings/numbers, electric-blue comments, green types, and cyan functions. It is a Vim-inspired approximation rather than an exact reproduction of a particular Vim version. <strong>Solarized Light</strong> (<code>solarized-light</code>) adapts Solarized's cream ground and slate text, green keywords, cyan strings, blue functions, and magenta literals. <strong>Linen Solar</strong> (<code>linen-solar</code>) has lighter warm paper with stronger teal/blue/green syntax; <strong>Sandstone Solar</strong> (<code>sandstone-solar</code>) has golden paper and deeper ink and accents. The original Linen and Sandstone palettes remain available unchanged.</p> <p><code>Space v T</code> or <strong>Choose theme</strong> in the command palette opens a framed floating chooser in workspace, zen, or bare. It starts on the current theme; <code>*</code> marks the original selection. Type a fuzzy title query to filter; Tab/Shift-Tab or Ctrl-n/p select the next/previous result. Filtering and selection preview the entire interface immediately, including the chooser, document, gutters, and other views. Enter applies the selected theme and closes; Escape restores the theme active before opening. With no matches, the last preview stays visible and Enter applies nothing. Closing due to an undersized terminal, focus loss, or replacement by another float also cancels the preview. Paste belongs to the query, not the file.</p> <p>Use <code>ches --theme glacier PATH</code> (or <code>ches --bare --theme paper PATH</code>) to select at startup. <code>ches --list-themes</code> prints stable IDs, titles, and dark/light kinds without a terminal or PATH. IDs are case-insensitive; surrounding whitespace is ignored and spaces/underscores normalize to hyphens. Unknown themes report an error pointing to the list. The active theme is shared by all presentations and lasts for this session; there is no automatic on-disk preference persistence.</p> <p>The pure <code>Ches_theme.Theme</code> library owns immutable RGB palettes. Screen state owns the effective choice, while <code>Theme.attrs ~theme</code> in <code>ui/theme.ml</code> maps semantic styles to terminal attributes. Selection, search, and diff colors have dedicated roles. Render caches include the effective theme so accepting, previewing, and cancelling redraw correctly without editing or reparsing text. <code>Theme.of_base16</code> adapts 16 RGB palette slots into a complete role palette; built-in additions are data in <code>theme/theme.ml</code>. External theme-file discovery/loading is not implemented. The renderer requests truecolor; actual display depends on the terminal's color capabilities.</p> <p>Font styles (bold, italic, underline) are set per part of the screen by <code>Theme.Font.default</code> and can be replaced in code with <code>Editor_view.run ~font</code>; the terminal still chooses the typeface, and a terminal without italics may ignore them. Document styles are composable records under <code>Ches_screen.Style.Document</code>: syntax category (or plain), current-line background, special-display treatment, and interaction overlay. The <code>~font</code> callback still takes <code>Style.t</code>; custom callbacks that previously matched flat document variants must now inspect the record, e.g. <code>Document { special = true; _ }</code> instead of <code>Special | Special_cursor_line</code>. Chrome variants such as <code>Title</code> and <code>Status</code> are unchanged. Everything is also readable without color: the mode, <code>[+]</code>, and messages are text, and escape forms are bracketed.</p> <p>Text is shown safely: a TAB expands to the next multiple of 8 cells, and control characters, C1 controls, and bidi controls appear as visible escape forms (<code>^[</code>, <code><85></code>, <code><202e></code>) instead of reaching the terminal.</p> <h2 id="architecture">Architecture<a class="headerlink" href="#architecture" title="Permanent link">¶</a></h2> <p>One key press goes through these steps:</p> <ol> <li><strong><code>ui/</code></strong> (Bonsai_term) receives a terminal event. <code>Terminal_input</code> turns it into a terminal-independent <code>Key.t</code>, or into the start or end of a paste.</li> <li><strong><code>screen/Ui_state</code></strong> collects any paste and passes the input to the session's focused file/directory controller, retaining buffer/context paste ownership.</li> <li><strong><code>app/Controller</code></strong> feeds it to <strong><code>input/Keymap</code></strong>. The keymap tracks pending counts, <code>Space</code> sequences, and the <code>j k</code> escape, looks Normal-mode sequences up in its <strong><code>input/Bindings</code></strong> table, and returns <em>actions</em>. An action is either an editor command, such as a counted move, or a view command.</li> <li>Editor commands go to <strong><code>core/Editor.dispatch</code></strong>, a pure function from state and command to a new state plus a list of <em>effects</em>, such as "write this exact text to this path" or "exit". The controller runs the effects synchronously and reports each outcome back to the editor. A save marks the text it wrote as saved, not whatever is current when it finishes. After the final text revision change, <code>app/Highlighting</code> updates the immutable highlight snapshot using its privately owned provider; no parsing happens in frame drawing or Bonsai rendering.</li> <li><strong><code>app/Session</code></strong> coordinates buffer lifetime, navigation, shared registers, guarded quit and filesystem apply. Directory Save uses its validated planner and executor, never a listing-text write. Layout view commands come back to <code>Ui_state</code>; buffer/directory commands are session-owned.</li> <li><strong><code>screen/Frame</code></strong> draws the editor, keymap, and UI state as rows of styled spans plus a cursor, as plain data. <code>ui/</code> turns the spans into Bonsai_term views with <code>ui/theme.ml</code>'s colors.</li> </ol> <p>Only <code>ui/</code> uses Bonsai, so everything from <code>Ui_state</code> down to the finished frame is tested headlessly with key sequences. <code>ui/</code> contains only event conversion, colors, and the Bonsai_term app.</p> <div class="highlight"><pre><span></span><code>dune-project project and package metadata (generates ches.opam) error/ ches_error: pure shared notification, active-problem lifecycle, and bounded history core/ ches_core: pure editing library; depends only on `core` input/ ches_input: terminal-independent keys and modal keymap tile/ shared tile host, focus, and input routing source/ asynchronous diagnostic sources and language-server client palette/ command catalog and fuzzy matching theme/ ches_theme: pure semantic RGB palettes, registry, and Base16 adapter app/ ches_app: file loading/saving, input controller and highlight cache highlight/ ches_highlight: provider-independent byte ranges, categories, snapshot keys, normalization/lookup and incremental edit descriptions highlight_tree_sitter/ ches_highlight_tree_sitter: privately owned Tree-sitter provider and queries screen/ ches_screen: Bonsai-free screen model: cell mapping, geometry, scrolling, UI state and transition, status fields and their layouts, rendered frames ui/ ches_ui: Bonsai_term frontend (event adapter, theme, app) test/ core, input, and app tests (expect tests, Quickcheck, temp-dir file tests) highlight/test/, highlight_tree_sitter/test/ range/edit and fresh/incremental provider tests screen/test/ headless screen-model tests, including live syntax/overlay geometry ui/test/ event adapter tests and Bonsai_term_test tests of the app scripts/ smoke.sh plus explicitly invoked syntax feasibility/performance probes bin/ches.ml command-line entry point </code></pre></div> <p><code>ches_core</code>, <code>ches_input</code>, and <code>ches_app</code> must never depend on Bonsai, Bonsai_term, Async, Notty, or any other terminal library. You can build them on their own with <code>dune build ./core/ches_core.cmxa ./input/ches_input.cmxa ./app/ches_app.cmxa</code>. Editor file loading and saving live in <code>ches_app</code>; <code>ches_source</code> owns diagnostic processes and language-server sessions. <code>ches_screen</code> must not depend on Bonsai or Bonsai_term; it uses Notty only for its code-point width table, so that its cell counts agree with what Notty draws. The cell layout itself lives in <code>ches_core</code> (<code>Cell_layout</code>) with the width function passed in: the frontend creates the editor with the same <code>Cell_map.width</code> it draws with, so screen columns in editing semantics and on screen cannot disagree.</p> <h2 id="terminal-smoke-test">Terminal smoke test<a class="headerlink" href="#terminal-smoke-test" title="Permanent link">¶</a></h2> <p><code>scripts/smoke.sh</code> drives the built binary in a private per-run tmux server (<code>tmux -S "$work/tmux.sock"</code>), on copies of fixtures in a temporary directory, and checks the screen text, cursor position and visibility, the alternate screen, saved file bytes, exit statuses, and that <code>stty</code> settings and the cursor are restored after every exit. It exercises the file-editing and layout bindings in the <a href="#keys">Keys</a> table, including the Insert-mode editing keys, soft tabs, <code>j k</code>, and an unbound <code>Space</code> key. It also covers:</p> <ul> <li>saving, reopening, and undo/redo, including undoing a whole Insert session</li> <li>a plain quit refused while there are unsaved changes, and a forced quit</li> <li>a save error</li> <li>empty and new files</li> <li>scrolling tall and wide files, and resizing down to 1x1</li> <li>counted movement: the pending count on the status line, clamping at the ends of the document and of lines, the column kept across short lines, and counts cancelled by overflow, <code>Escape</code>, an unbound key, or a command that takes none</li> <li>word, line, and document motions (<code>w b e W B E 0 ^ $ _ g_ gg G</code>) with counts, including a pending and cancelled <code>g</code>, and <code>G</code> with and without a count</li> <li><code>%</code> across 150 lines and back, from before a delimiter, on a line without one, and with a rejected count</li> <li>Insert entry (<code>a A I o O</code>): indentation copied by <code>o</code>, <code>O</code>, and <code>Enter</code> and kept when nothing more is typed, undoing an opened line, and <code>3o</code> rejected</li> <li>tabs, wide characters, and control characters</li> <li>a fast burst of keys with a paste in it, and a paste in Normal mode</li> <li>every <code>Space v</code> command, with clamping and restoring on resize</li> <li>workspace status on all four sides, separate width/height requests, scrolling and cursor alignment, hide/show, zen and saved-layout changes, compact fallback and restoration, edit/undo/redo/save, and error visibility across layout transitions</li> <li>floating command palette placement and cursor ownership, typed queries and pasted text, acceptance/cancellation and exact colored workspace restoration, no-match Enter, coexistence with all installed tiles, zen, clamped/minimum-size resizing, selected-command retention, too-small refusal/closure, and interrupted paste dropping after a resize and growth</li> <li>line-number styles: both toggles from the default (none), a rejected count, <code>Space v r</code>, renumbering as the cursor moves, and a toggle while too small</li> <li>view scrolling: <code>Ctrl-e</code>/<code>Ctrl-y</code> with counts and a pushed cursor, <code>Ctrl-d</code>/ <code>Ctrl-u</code>, <code>zt</code>/<code>zb</code>/<code>zz</code> and a rejected count, scrolling past the end, resizing after scrolling, tiny terminals, and Insert mode</li> <li>exits by SIGTERM and SIGHUP, a file that cannot be opened, and standard input that is not a terminal</li> </ul> <p>It needs tmux (tested with 3.4), bash, and a UTF-8 locale. It is not run by <code>dune runtest</code>. It waits for screen/cursor updates rather than assuming a fixed runtime:</p> <div class="highlight"><pre><span></span><code>dune<span class="w"> </span>build<span class="w"> </span><span class="o">&&</span><span class="w"> </span>scripts/smoke.sh<span class="w"> </span><span class="c1"># tests _build/default/bin/ches.exe</span> scripts/smoke.sh<span class="w"> </span>path/to/ches<span class="w"> </span><span class="c1"># or another binary</span> scripts/smoke.sh<span class="w"> </span>--bare-only<span class="w"> </span><span class="c1"># bare startup/toggle, --superzen alias, indentation, palette, terminal restoration</span> scripts/smoke.sh<span class="w"> </span>--palette-only<span class="w"> </span><span class="c1"># only floating-palette scenarios</span> scripts/smoke.sh<span class="w"> </span>--line-picker-only<span class="w"> </span><span class="c1"># live line binding/jump/zen/paste/resize</span> scripts/smoke.sh<span class="w"> </span>--palette-only<span class="w"> </span>path/to/ches python3<span class="w"> </span>scripts/directory_workspace_smoke.py<span class="w"> </span><span class="c1"># directory/tab integration PTY scenarios</span> python3<span class="w"> </span>scripts/picker_smoke.py<span class="w"> </span><span class="c1"># real file/content opening and stale/dirty navigation</span> </code></pre></div> <p><code>scripts/dune</code> also runs every suite (<code>smoke.sh</code>, theme, VCS, picker and directory) through one dune alias, building <code>ches.exe</code> and the fake language server first. Each Python suite also takes an optional binary path as its first argument.</p> <div class="highlight"><pre><span></span><code>dune<span class="w"> </span>build<span class="w"> </span>@smoke<span class="w"> </span>-j<span class="w"> </span><span class="m">4</span><span class="w"> </span><span class="c1"># every suite, one at a time, every time it is asked</span> dune<span class="w"> </span>build<span class="w"> </span>@scripts/smoke-vcs<span class="w"> </span><span class="c1"># one suite: smoke-terminal, smoke-theme, smoke-vcs,</span> <span class="w"> </span><span class="c1"># smoke-picker or smoke-directory</span> dune<span class="w"> </span>build<span class="w"> </span>@test-all<span class="w"> </span>-j<span class="w"> </span><span class="m">4</span><span class="w"> </span><span class="c1"># everything: the OCaml tests (@runtest) plus @smoke</span> </code></pre></div> <p>The rules declare <code>(universe)</code>, so dune reruns them on every request instead of caching a pass, and share a lock, so suites never run concurrently whatever <code>-j</code> is. <code>dune runtest</code> still does not run them. Dune points <code>TMPDIR</code> at a private directory it deletes afterwards, so captures a suite keeps under <code>TMPDIR</code> (theme, picker and <code>smoke.sh</code> review screens) are gone after a dune run; run the script directly to keep them.</p> <p>It prints <code>ok</code> or <code>FAIL</code> for each check, with a screen dump after each failure, and exits nonzero if any check failed. It never touches your own tmux sessions, and it deletes its temporary directory on exit. It also saves colored captures of review screens (Normal, Insert and dirty, pending <code>Space</code> and <code>Space v</code>, a moved tile, relative and no line numbers, and a save error at 80x24 and 160x48, plus tiny sizes and floating-palette open/close/resize/zen screens) and prints their directory (<code>cat</code> a file to view it).</p> <p><code>picker_smoke.py</code> uses its own tmux socket and a temporary fixture, retaining text/colored captures under the printed fixture's hidden <code>.captures</code> directory. It covers file/content binding and palette activation, query/select/cancel/accept, dirty retained text/undo, missing/stale failures, Unicode/TAB location reveal, zen restoration, minimum/tiny/resize and interrupted paste, disk bytes and tty modes. It also checks native Tab/Shift-Tab file/palette selected acceptance, dirty/missing/ large/empty/binary previews, safe controls, narrow/wide resize and close/reopen. These are automated checks, not human visual or ranking/performance acceptance.</p> <p>Cursor assertions poll for a visible cursor at the expected position within five seconds, rather than sampling hidden cursor coordinates during smear. This fixed the five timing failures recorded in the syntax-highlighting handoffs; three consecutive isolated runs passed all checks. Each run owns its own socket, so it cannot interfere with another smoke run. Automated checks still cannot replace the manual checks below.</p> <h3 id="checks-to-do-by-hand">Checks to do by hand<a class="headerlink" href="#checks-to-do-by-hand" title="Permanent link">¶</a></h3> <p>The smoke script cannot check these, so check them in a real terminal:</p> <ul> <li>The cursor is a block in Normal mode and a bar in Insert mode, and the shell's own cursor shape comes back after quitting from Insert mode and after an error exit. tmux does not report cursor shape.</li> <li>The colors look right: the review screens, and a live session at about 80×24 and 160×48.</li> <li>During a block insert (<code>Ctrl-v</code>, <code>2j</code>, <code>I</code>, then type), the cursor's cell is blue, the other lines' insertion points are grey cells, and none of them flicker while you type, including while the smear animation runs.</li> <li>Nothing flickers while typing fast, scrolling, or resizing.</li> <li>Floating palette acceptance: open <code>Space c c</code> with all docked tiles visible, and again in zen, at about 80×24 and 120×40. Check its centering, preferred/clamped size, readable title/query/results/footer, and a single bar cursor with no document smear. Filter until results scroll; navigate with Tab/Shift-Tab, accept with Enter or cancel with Escape, and confirm the covered workspace returns without a viewport jump. Resize through 14×4 and below the minimum, then grow again; review the saved <code>palette-*.ansi</code> captures. Record a human visual review separately from automated smoke/headless results.</li> <li>File-preview acceptance: review the results/preview split at 104, 140 and 160 columns, then hide it at narrow widths. Check readable labels, numbered dirty text, safe control/wide-character clipping, selection visibility, Enter behavior, close/reopen and rapid navigation. Judge flicker and responsiveness separately; automated captures are not visual or measured-performance acceptance.</li> <li>Pasting from the terminal's own clipboard inserts text literally in Insert mode. This depends on the terminal; the script pastes through tmux.</li> <li>Syntax acceptance: open <code>highlight_tree_sitter/provider.ml</code>, <code>core/text_buffer.mli</code> and <code>README.md</code> to compare <code>.ml</code>, <code>.mli</code> and plain-text fallback. Check readability under <code>/</code> search/current matches, character/line/block selections and block-insert points, then clear overlays and confirm syntax returns. Insert a multiline comment above the viewport and undo/redo it; try unfinished strings/comments and malformed code. Include TABs, controls, wide/combining characters and tiny dimensions while typing, pasting, scrolling, resizing and running smear. Record observed flicker or palette problems rather than treating headless tests as visual sign-off.</li> </ul> <h2 id="storage">Storage<a class="headerlink" href="#storage" title="Permanent link">¶</a></h2> <p>The document is an immutable OCaml string behind the abstract <code>Text_buffer.t</code>. Nonempty edits use one exact-size destination and prefix/insert/suffix blits, without temporary prefix/suffix strings. The unified replacement path also avoids the former delete-then-insert double copy in block editor actions. This remains O(document bytes) copying, deliberately not a rope/piece-table implementation.</p> <p>Line starts update using binary searches at the edited range's endpoints: remove covered starts, scan only inserted text for new LFs, and shift later offsets. Changed arrays still cost O(line count) allocation/copying; equal-length edits that remove and insert no LFs reuse the immutable array. No unchanged document bytes are rescanned for newlines. Inserted UTF-8 validation, CRLF/CR/NUL rejection, trailing-LF empty lines and protected directory anchor affinities remain intact. New text invalidates its layout cache; empty edits retain the original snapshot (except linewise identity removal). Line lookup uses binary search; bounded snapshot-owned sparse layouts support warm column/viewport queries, though first access can still scan a long line. Only <code>Text_buffer</code> knows how text is stored. Its interface works in byte offsets at UTF-8 code-point boundaries and in line numbers, so it can later become a rope or piece tree without changing the editor, keymap, or screen code.</p> <p>Editing time and each undo step's memory still grow with file size. Limits are code configuration: <code>History.Limits.default</code> and optional <code>Editor.create ~history_limits</code>; reload/directory rebase preserve the chosen limits. 1,000 transactions permit substantial small-file work, while the 64 MiB budget prevents long sessions retaining unlimited full-document copies. Larger documents therefore keep fewer steps. There is no eviction notification or disk-persistent undo.</p> <p>Each complete step charges 128 bytes for snapshots/step/map storage plus both <code>Text_buffer.retained_bytes</code> estimates: text length, eight bytes per line-start entry, fixed snapshot/string overhead, and protected directory scope/anchor/token storage. Shared snapshots, including adjacent after/before texts, are charged in full per step, deliberately overestimating shared storage without hashing or byte scans. Identity charge is cached when metadata is normalized; history reads it in O(1). Undo/redo moves the existing charge, never adding another copy.</p> <p>After commit, complete-step charge is <strong>at most max(byte budget, newest complete step charge)</strong>, with count at most the configured positive transaction limit. Undo/redo preserves that bound ("newest" means chronologically newest retained transaction, including redo). The active transaction's before snapshot is protected and outside this budget until commit; current text, saved text, registers, other application ownership and externally retained old editor/history states are also outside it. The bounded layout cache is uncharged: up to 64 line/width indexes and 16,384 checkpoint slots per snapshot, plus index/list overhead (see <a href="https://github.com/bopurtell/cobalt/blob/6c0a8080aa5479916d893e5778ca55bc704e3b59/docs/long_line_rendering.md">long-line rendering</a>). These are retention estimates, <strong>not total RSS or peak-allocation guarantees</strong>; garbage collection releases dropped ownership on its own schedule.</p> <p>History uses persistent ordered maps and incremental byte totals. Undo/redo and a commit without eviction cost O(log n); starting an active transaction and reading stats cost O(1). Removing k oldest steps costs O(k log n), bounded by the configured count; an oversized newest step replaces old roots directly, as does clearing redo on a branch. There are no recurring history-length scans or list-reversal spikes. Bounded undo retention is complete. Shared snapshots and line arrays remain charged in full, so the accounting contract is unchanged by array reuse. Equality now has safe physical snapshot/string/list identity guards; distinct snapshots still use content-and-identity equality. Dirty state therefore clears on undo-to-saved or a separately reconstructed equal saved state, rather than depending on revision equality. Comparisons of distinct equal large strings can still be O(document bytes), as can transaction no-net-change checks. Whole-string copies, line-array updates and first layout access remain architectural costs. See the slice 7b entry in <a href="https://github.com/bopurtell/cobalt/blob/6c0a8080aa5479916d893e5778ca55bc704e3b59/docs/plans/performance_tests.md">the performance test plan</a> for bounded probe results.</p> <h2 id="saving-current-limitations">Saving: current limitations<a class="headerlink" href="#saving-current-limitations" title="Permanent link">¶</a></h2> <p>Saving is synchronous and writes the file in place (truncate, then write). It is not crash-safe: a crash or full disk mid-save can leave the file truncated. It does not <code>fsync</code>. Symlinks are followed and kept, existing permissions are kept, and changes made to the file by other programs are not detected.</p> <h2 id="known-limitations">Known limitations<a class="headerlink" href="#known-limitations" title="Permanent link">¶</a></h2> <ul> <li>Grapheme clusters are not handled: cursor movement and deletion work on code points, and widths are per code point. A complex cluster such as an emoji ZWJ sequence may look wrong, but the layout around it stays aligned.</li> <li>A combining mark is drawn with the character before it only when that character is drawn as itself; after a TAB, an escape form, or the left edge of the view it is not drawn.</li> <li>No soft wrapping: long lines scroll horizontally.</li> <li>One editor group and one directory presentation. The only <code>:</code> command is <code>:e!</code>; there is no general Ex prompt. Search and local OCaml/Verilog/SystemVerilog syntax highlighting are supported; semantic tokens, other languages and language-server features beyond diagnostics are not. Word motions use the simple character classes above, not Unicode word properties.</li> <li>Large files are slow to edit and bounded whole-text undo can retain fewer steps; see <a href="#storage">Storage</a> and <a href="#syntax-highlighting">Syntax highlighting</a>. Incremental parsing still runs a full-document query and normalization after each text change.</li> <li>No configuration file: tab width, the <code>j k</code> escape, and key bindings are set in code, and layout preferences are not saved between runs.</li> <li>Directory buffers have no eviction or background watcher. Filesystem operations have no rollback/undo or persisted recovery journal; see the directory reference.</li> </ul> <h2 id="known-toolchain-quirk-ppx_expect-source-path">Known toolchain quirk: ppx_expect source path<a class="headerlink" href="#known-toolchain-quirk-ppx_expect-source-path" title="Permanent link">¶</a></h2> <p><code>ppx_expect v0.18~preview</code> drops the directory when it registers an expect test's file, then rebuilds the path from the bare filename plus the <code>-source-tree-root</code> that Dune passes (the project root). As a result, <code>dune runtest</code> fails with <code>Sys_error "./../<file>.ml: No such file or directory"</code> even when every expectation passes. Each library that has inline tests works around this in its <code>dune</code> file:</p> <div class="highlight"><pre><span></span><code>(inline_tests (flags (:standard -source-tree-root .))) </code></pre></div> <p>The trailing flag wins and points at the runner's working directory, where Dune has copied the sources. Real expectation failures still produce a diff and a nonzero exit. Remove the workaround once a fixed <code>ppx_expect</code> is installed.</p> </article> </div> <script>var target=document.getElementById(location.hash.slice(1));target&&target.name&&(target.checked=target.name.startsWith("__tabbed_"))</script> </div> <button type="button" class="md-top md-icon" data-md-component="top" hidden> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M13 20h-2V8l-5.5 5.5-1.42-1.42L12 4.16l7.92 7.92-1.42 1.42L13 8z"/></svg> Back to top </button> </main> <footer class="md-footer"> <div class="md-footer-meta md-typeset"> <div class="md-footer-meta__inner md-grid"> <div class="md-copyright"> Made with <a href="https://squidfunk.github.io/mkdocs-material/" target="_blank" rel="noopener"> Material for MkDocs </a> </div> <div class="md-social"> <a href="https://clockmakerincarteret.com/" target="_blank" rel="noopener" title="clockmakerincarteret.com" class="md-social__link"> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M16.36 14c.08-.66.14-1.32.14-2s-.06-1.34-.14-2h3.38c.16.64.26 1.31.26 2s-.1 1.36-.26 2m-5.15 5.56c.6-1.11 1.06-2.31 1.38-3.56h2.95a8.03 8.03 0 0 1-4.33 3.56M14.34 14H9.66c-.1-.66-.16-1.32-.16-2s.06-1.35.16-2h4.68c.09.65.16 1.32.16 2s-.07 1.34-.16 2M12 19.96c-.83-1.2-1.5-2.53-1.91-3.96h3.82c-.41 1.43-1.08 2.76-1.91 3.96M8 8H5.08A7.92 7.92 0 0 1 9.4 4.44C8.8 5.55 8.35 6.75 8 8m-2.92 8H8c.35 1.25.8 2.45 1.4 3.56A8 8 0 0 1 5.08 16m-.82-2C4.1 13.36 4 12.69 4 12s.1-1.36.26-2h3.38c-.08.66-.14 1.32-.14 2s.06 1.34.14 2M12 4.03c.83 1.2 1.5 2.54 1.91 3.97h-3.82c.41-1.43 1.08-2.77 1.91-3.97M18.92 8h-2.95a15.7 15.7 0 0 0-1.38-3.56c1.84.63 3.37 1.9 4.33 3.56M12 2C6.47 2 2 6.5 2 12a10 10 0 0 0 10 10 10 10 0 0 0 10-10A10 10 0 0 0 12 2"/></svg> </a> </div> </div> </div> </footer> </div> <div class="md-dialog" data-md-component="dialog"> <div class="md-dialog__inner md-typeset"></div> </div> <script id="__config" type="application/json">{"annotate": null, "base": "../../../..", "features": ["navigation.tabs", "navigation.sections", "navigation.top", "content.code.copy", "search.suggest"], "search": "../../../../assets/javascripts/workers/search.2c215733.min.js", "tags": null, "translations": {"clipboard.copied": "Copied to clipboard", "clipboard.copy": "Copy to clipboard", "search.result.more.one": "1 more on this page", "search.result.more.other": "# more on this page", "search.result.none": "No matching documents", "search.result.one": "1 matching document", "search.result.other": "# matching documents", "search.result.placeholder": "Type to start searching", "search.result.term.missing": "Missing", "select.version": "Select version"}, "version": null}</script> <script src="../../../../assets/javascripts/bundle.79ae519e.min.js"></script> </body> </html>