Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Vix: Simple Terminal Rust IDE

Goal: Create a Simple Terminal Rust Integrated Development Environment. It opens text files, edits them, saves them.

Nerd Font icons, monospace.

Specification-driven development

The specification is the single source of truth. Vix is built specification-first: each behavior is described in a spec, and the code implements the spec. When code and spec disagree, decide which is correct and make them match — edit the spec when intent changes, edit the code when it drifted.

Specs are per crate. Vix is a Cargo workspace: a thin App shell (package vix-tui, tui/src/, building the vix command) over 147 vix-* member crates under crates/. Each member crate owns its spec at crates/<crate>/spec/index.md (multi-topic crates add spec/<topic>/index.md sub-specs), so a crate and its specification travel together. This repo-root spec/ holds only the cross-cutting / app-level and build/meta specs that no single crate owns — this overview, navigation, comparisons, emacs-menus, tools, license, licenses, trademarks, rust-clippy-pedantic, rust-cargo-fmt, test, ci, debian, brew, and the like. A spec that describes one crate’s behavior belongs with that crate; scripts/check-docs enforces that every crate owns a spec/index.md. See AGENTS.md and agents/workflow.md for the workflow, and agents/share/crate-map.md for the full map.

Crates

Vix is built on a deliberately small, version-compatible crate set. The whole ratatui widget ecosystem must agree on one ratatui version (0.30); the editor widget pins that.

NamePurposeURLDebian equivalent?Debian unstable versionDebian 14 Forky version
serdeSettings + theme (de)serializationhttps://crates.io/crates/serdelibrust-serde-dev??
serde-jsonSerialize/Deserialize JSON (and Vix config files)https://crates.io/crate/serde_jsonlibrust-serde-json-dev??
serde-yamlSerialize/Deserialize YAMLhttps://crates.io/crate/serde-yamllibrust-serde-yaml-dev??
ratatuiTerminal UI (layout, widgets)https://crates.io/crates/ratatuilibrust-ratatui-dev??
ratatui-imageIn-terminal image viewing (png/jpg/…)https://crates.io/crates/ratatui-image??
imageImage decoding for the viewerhttps://crates.io/crates/imagelibrust-image-dev, librust-image+default-dev0.25.x
crosstermCross-platform terminal backend / events / mousehttps://crates.io/crates/crosstermlibrust-crossterm-dev??
regexRegular expressions for find/replace; Unicode featurehttps://crates.io/crates/regexlibrust-regex-dev, librust-regex+unicode-dev??
jiffDate & time (local, UTC, ISO week)https://crates.io/crates/jifflibrust-jiff-dev??
rust-i18nInternationalization YAML fileshttps://crates.io/crates/rust-i18nlibrust-regex-dev??
confyConfigurationhttps://crates.io/crates/confylibrust-confy-dev??
clapCommand Line Argument Parsinghttps://crates.io/crates/claplibrust-clap-dev, librust-clap-complete-dev, librust-clap-derive-dev, librust-clap-builder-dev4.6.1
mimallocMiMalloc custom memory allocator for MUSLhttps://crates.io/crates/mimalloc??
include_dirEmbed bundled theme JSON files into the binaryhttps://crates.io/crates/include_dir??
tree-sitterRust bindings to the Tree-sitter parsing libraryhttps://crates.io/crates/tree-sitterlibrust-tree-sitter-dev??
sysinfoHost system snapshot (System Information panel)https://crates.io/crates/sysinfolibrust-sysinfo-dev??
spellbookPure-Rust Hunspell spell checkerhttps://crates.io/crates/spellbook??
similarText diffing (git diff gutter; word-level compare, inline feature)https://crates.io/crates/similarlibrust-similar-dev??
ureqHTTP client for the REST tool (pure-Rust rustls TLS)https://crates.io/crates/ureqlibrust-ureq-dev??
evalexprEvaluate expression (solely for calculator tool)https://crates.io/crates/evalexprlibrust-evalexpr-dev??
randRandomness functionality, number generatorshttps://crates.io/crates/randlibrust-rand-dev??
markdownMarkdown parser & converterhttps://crates.io/crate/markdownlibrust-markdown-dev
csvComma Separated Valueshttps://crates.io/crate/csvlibrust-csv-dev
tomlTom’s Obvious Minimal Languagehttps://crates.io/crate/tomllibrust-toml-dev

Cargo.toml is authoritative for the full dependency set; the table above lists the load-bearing ones. Also linked, grouped by why:

WhyCrates
Editor engineropey (rope buffer), unicode-segmentation, unicode-width, streaming-iterator, ratatui-core, rust-embed (Tree-sitter queries in langs/)
Clipboardarboard, behind vix-clipboard’s process-wide lock and opt-in
Database workbenchsqlx (Any driver: bundled SQLite, pure-Rust Postgres/MySQL), tokio, futures-util
Terminal panelportable-pty, vt100, nix (suspend/resume)
Hashes & idssha2, md-5, crc32fast, uuid, getrandom, base64, percent-encoding
Markuppulldown-cmark, htmd (HTML → Markdown), qrcode
Filesignore (gitignore-aware walking), anyhow

The center editing area uses editor_core — Vix’s fully-custom code-editor widget (Tree-sitter syntax highlighting, undo/redo history, selection, system clipboard, mouse handling, theme-aware styles, and soft wrap), which tracks ratatui 0.30. The file explorer, scrollbar, command palette, popups, menu bar, and calendar box are implemented in-house on ratatui primitives (List, Scrollbar, Clear, Tabs). The month grid is computed with jiff, so the workspace depends on one date library only.

Build and run

cargo run                 # open in the current directory
cargo run -- tui/src/main.rs  # open one or more files
cargo run -- file.rs:42:7 # open and jump to line 42, column 7
cargo test                # run the logic + doc tests
cargo build --release     # optimized binary (~4.9M, common grammars)
cargo build --release --no-default-features                  # ~3.0M, no syntax grammars
cargo build --release --no-default-features --features syntax-all  # ~18M, all grammars

Tree-sitter grammars are gated behind Cargo features (see the [features] table in Cargo.toml and the internal editor_core crate), so the binary only links the parsers selected at build time. The default set is Rust, Markdown, JSON, and TOML.

The application root is the current working directory; the explorer and the command-palette file finder operate within it.

  • Top menu (see menus.md)
  • Left drawer file browser (in-house tree; Ctrl+B toggle, Ctrl+E focus)
  • Center editing area using editor_core (Tree-sitter syntax highlighting, undo/redo, selection, system clipboard, block cursor)
    • Top tab bar: each tab is one text file; preview tabs render dimmed
    • Show/hide line numbers, whitespace, scroll bar, soft wrap (View ▸ Editor)
    • Editing comforts: select all (Ctrl+A), duplicate line (Ctrl+Shift+D), delete line (Ctrl+K), forward delete (Ctrl+D, the macOS binding), move line up/down (Alt+↑/Alt+↓), jump to the matching bracket (Ctrl+]), and auto-indent on Enter (see crates/vix-editor-core/spec/index.md)
    • Right-side scroll bar (ratatui::widgets::Scrollbar)
    • Opening an image file (png/jpg/gif/bmp/webp/…) shows it in a read-only image tab via ratatui-image (needs a graphics-capable terminal)
  • Right drawer message browser
    • List of advice and notifications; each item shows a close x (dismiss with x, Delete, or Enter while the drawer is focused)
  • Bottom dock (toggle with View ▸ Show/Hide Bottom Dock; see crates/vix-bottom-dock/spec/index.md) — a full-width, resizable, scrollable line panel pinned above the status bar for logs/output/data
    • Run Command (Tools ▸ Run Command…) streams a shell command’s output here; Cancel Command kills it
    • Search in Workspace → Dock (Edit ▸ Find) lists path:line:col hits here
    • Lines that name a path:line[:col] location are click-to-jump; the dock can be focused (click) and scrolled, and follows new output only at the bottom
  • Bottom status bar (toggle with View ▸ Show/Hide Bottom Status)
    • File path and dirty indicator, plus the latest status message
    • Language, line ending (LF/CRLF), encoding (UTF-8), and the selected character/line count when text is selected
    • Line number : Column number
    • Calendar icon; toggle the calendar box from Tools ▸ Calendar
  • Mouse: click to place the cursor or focus a pane, drag to select, wheel to scroll; click a tab to switch, click a message’s x to dismiss it, click a menu name to open it
  • Keyboard shortcut help: press F1 (or Help ▸ Keyboard Shortcuts) for an overlay of every binding

Architecture

The vix-tui package exposes a library (crate name vix) (tui/src/lib.rs) plus a thin binary (tui/src/main.rs). Splitting it this way keeps all editing logic terminal-independent and unit-testable: the binary owns the terminal, and nothing else does.

The App shell is deliberately small — everything that can be a crate is one:

Shell moduleResponsibility
main.rsCLI (clap), locale resolution, terminal setup/teardown, the event loop, suspend/resume
lib.rsCrate root: lint posture, i18n! catalog, and the pub use vix_* as … re-exports
app.rsApp state, on_key / on_mouse / on_paste, run_action, overlay routing, feature wiring — delegates most of this to tui/src/app/*.rs submodules (one per feature area: keymap.rs, git.rs, org.rs, …)
ui.rsAll rendering: frame layout — delegates most per-pane/overlay draw functions to tui/src/ui/*.rs submodules (choosers.rs, db.rs, edit_surfaces.rs, menu_bar.rs, …)
explorer.rsThe directory tree flattened into rows
messages.rsThe notification drawer model
search.rs, workspace_search.rsSearch bar helpers; workspace-wide search/replace state
edit_table.rs, edit_outline.rs, column_view.rsOverlay editors that live in the shell because they drive the active buffer directly

Everything else — the editor widget, menu, palette, find/replace, settings, themes, locales, keymaps, docks, panels, pickers, Git, LSP/DAP, Org, the database workbench, and every pure text tool — is a vix-* member crate. tui/src/lib.rs re-exports each under a short name (pub use vix_git as git;), so shell code says crate::git, crate::menu, crate::db. See agents/share/crate-map.md for the full map and docs/architecture/index.md for the narrative version.

Event flow

main runs the loop: draw, then poll one crossterm event. ui::draw(&mut app) records each pane’s rectangle so mouse events can be hit-tested. Keys go to App::on_key, mouse to App::on_mouse, and a bracketed paste to App::on_paste (see crates/vix-editor/spec/bracketed-paste/index.md). Focus reports go to App::on_focus_gained / App::on_focus_lost (see crates/vix-editor/spec/save-automation/index.md).

Terminal protocol (T628): each frame is drawn inside a synchronized update (DEC mode 2026, BeginSynchronizedUpdate / EndSynchronizedUpdate), so the terminal never shows a half-painted frame. App::terminal_caps (set once at startup from COLORTERM/TERM/TERM_PROGRAM, with no terminal query) decides the color depth every frame is downsampled to (see crates/vix-theme/spec/index.md) and whether URLs in the markdown preview and the messages dock get OSC 8 hyperlinks. Terminals without these features ignore the escapes.

on_key resolves, in strict priority order:

  1. Key-release events (dropped) and, on macOS, the Command → Control fold (crates/vix-editor/spec/command-key/index.md).
  2. Jump-label mode, the LSP completion popup, and a pending hover tooltip.
  3. Modal overlays — welcome, help, dialogs, tool dialogs, calendar/clock, then the panel layer (terminal, database, edit surfaces, choosers, query-replace, workspace search, confirm, prompt, palette, search, menu). App::overlay_capturing_keys mirrors this chain for callers that need to ask “is the editor reachable?” without dispatching; the two must be changed together.
  4. Org-table context keys, when the cursor is inside a pipe table.
  5. The active keymap (Apple, VSCode macOS/Windows, Emacs, Vi, Spacemacs, IntelliJ macOS/Windows, Eclipse, Sublime, Zed, Fresh, ttt, Helix — see crates/vix-keymap-model/spec/index.md), which translates keys into run_action ids and editor motions rather than duplicating behavior.
  6. The focused pane: editor, explorer, messages, or bottom dock.

Each loop iteration also drains background work — streamed command output, LSP and DAP messages, async database results, HTTP responses, file-change reloads, auto-save — into the state the next draw reads. Menu items, palette commands, and keymap chords all share one set of action ids dispatched by App::run_action.

Implementation status

Vix is shipped and in use; the feature set below is built, specified, and tested. Each crate’s own spec/index.md is authoritative for its area and marks anything still in design.

AreaState
Editing coreTabs, undo tree (branch-preserving, persisted per file), soft wrap, bracket matching, indent guides, rainbow brackets, sticky scroll, minimap, multiple cursors, column selection, structural selection, read-only lock
Text transformsCase, sort/dedupe/shuffle/reverse, squeeze blanks, line endings, ROT13, align, surround, transpose, delete-by-unit, wrap/fill, increment/toggle values, Emmet
Files & explorerTree, preview tabs, copy/cut/paste with conflict prompts, multi-select, delete, edit a directory as text, atomic saves that keep hard links and ownership, encoding detection, buffers that follow moves, File → Open browser, recent files, sessions and workspaces
SearchIncremental find, find/replace with regex + capture groups, smart case, workspace-wide search/replace, interactive query-replace, TODO finder
NavigationPosition history, go-to definition/symbol/line/percent/byte, jump labels, matching tag, breadcrumbs, outline panel
Language supportTree-sitter highlighting (feature-gated grammars), LSP (diagnostics incl. per-document pull diagnostics, hover, completion, inline ghost-text completion, references, call and type hierarchy, rename, code actions/lens, inlay hints), DAP debugging (breakpoint conditions, exception filters, attach, a thread/stack/variables panel, inline values)
Version controlGit status/diff/blame, per-hunk stage/unstage/revert, branch/stash/amend, stash list, worktrees, interactive rebase, cherry-pick, branch review with saved line comments, merge-conflict resolver, diff gutter with a selectable base, word-level diff
Data & toolsDatabase workbench (SQLite/Postgres/MySQL), HTTP client, test runner, task runner, integrated terminal (tabs, scrollback, open-from-output, send selection), a project’s direnv/mise/venv environment (trust-gated), converters, generators, pickers, info panels
Org modeHeadlines, TODO/checkbox cookies, agenda, capture, refile, footnotes, id links, tables (TBLFM), column view, Org-roam, dailies, backlinks, export
PresentationMonochrome bundled themes plus custom JSON themes, base16 palettes, Zen mode, split panes (up to 2×2), 27 UI languages, ten keymaps
Terminal integrationMouse (click/drag/wheel/hover), in-terminal images, bracketed paste, macOS Command folded to Control, suspend/resume, synchronized output, focus events, color-depth fallback, OSC 8 hyperlinks

Quality gates

  • cargo clippy --workspace --all-targets -- -D warnings, at clippy::pedantic, with unsafe_code = "forbid" and missing_docs = "deny" set once in the root [workspace.lints] and inherited by every crate (spec/rust-clippy-pedantic/index.md).
  • cargo test — unit, integration, and doc tests, none of which need a TTY.
  • cargo fuzz targets over the pure text/parse cores, and cargo bench (Criterion) over the hot paths (spec/test/index.md).
  • scripts/check runs the whole gate locally; scripts/check-docs checks that this documentation still matches the tree it describes.
  • CI runs the same gate on all three forges (spec/ci/index.md).