-
Notifications
You must be signed in to change notification settings - Fork 0
Architecture
Tuim is a high-performance terminal workspace written in Zig that embeds and controls Neovim over MessagePack-RPC. It is designed to combine the rich editing power of Neovim with the speed, memory safety, and native widget capabilities of Zig.
Tuim employs a dual-process Neovim architecture:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Tuim Zig Frontend โ
โ - Terminal input & event reactor โ
โ - Layout, widgets & statusline โ
โ - Differential row-run renderer โ
โโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโ
โ MessagePack-RPC
โโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโ
โผ โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Neovim Editor Process โ โ Neovim Terminal Process โ
โ (tuim_init.lua) โ โ (terminal_init.lua) โ
โ - Code buffers & text โ โ - Lightweight PTY host โ
โ - Treesitter, LSP โ โ - Persistent user shell โ
โ - Plugins (lazy, mason) โ โ - No editor plugins โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโ
-
Editor Process (
tuim_init.lua): Started withNVIM_APPNAME=tuimand--clean. Owns editable buffers, window layouts, text history, undo stacks, Treesitter highlights, diagnostics, language servers, and the plugin ecosystem. -
Terminal Frontend Process (
terminal_init.lua): A separate lightweight Neovim process dedicated solely to hosting the integrated shell. It runs without the editor plugin stack, guaranteeing low memory overhead and zero latency impact on editing. - Tuim Zig Frontend: Owns keyboard/mouse input decoding, layout computation, native panels (Explorer, Git, AI, Extensions, Settings), focus management, and final terminal screen rendering.
Tuim uses an asynchronous event reactor that monitors readiness across:
- Host terminal input (
/dev/ttyorstdin) - Window resize signals (
SIGWINCH) - RPC pipes from both Neovim processes
- Background task completion notifications
Each reactor cycle progresses through:
- Transport Drain: Reads available MessagePack packets from Neovim.
- Normalized Dispatch: Translates raw ANSI escape codes into high-level Tuim input events.
- State Updates: Applies buffer, focus, and widget updates.
- Invalidation & Composition: Determines which coarse screen regions are dirty.
- Flush: Emits changed row runs to the terminal.
Generation Tracking: Registration generations ensure that stale events never target reused file descriptors or terminated tasks.
Heavy operationsโsuch as Git status scans, catalog indexing, and diff computationsโare offloaded to a dedicated background task runner:
- Workers execute tasks on bounded worker threads.
- Tasks have explicit ownership IDs and generations; completions from superseded tasks (e.g. an outdated Git status check) are discarded automatically.
- Workers never directly touch the live UI arena or Neovim RPC clients, ensuring lock-free rendering.
Communication with Neovim is implemented via custom MessagePack encoders and decoders:
- Asynchronous Transport: The interactive session communicates asynchronously so that typing and UI animations remain smooth even during large buffer loads.
-
Neovim Multigrid Protocol: Consumes Neovim's
ext_multigrid,ext_linegrid, and highlight events. -
Differential Row-Run Renderer: Rather than redrawing the whole screen every frame, Tuim's renderer (
src/tui/renderer.zig) compares cell buffers and emits only the exact contiguous horizontal runs of changed cells, minimizing terminal I/O.
The Extensions catalog search and marketplace parser is a standalone Python script embedded directly into the Tuim executable and extracted to the data directory at runtime:
- Exposes a clean JSON-over-stdout interface.
- Performs offline scans of installed plugins and local configurations.
- Queries the marketplace catalog, refreshing
db_minified.jsonfrom GitHub in the background whenever the local cache is missing or older than 24 hours.
Learn how to compile Tuim from source in Building from Source.
Tuim Repository ยท Releases ยท Issue Tracker ยท Website ยท Licensed under MIT
- Workspace Overview
- Editing Modes
- Keybindings & Shortcuts
- File & Buffer Management
- Integrated Terminal
- Git Integration
- Extensions & Plugins
- Language Tools & LSP
- AI Coding Assistants