lattice_host/lib.rs
1//! `lattice-host` -- the renderer-agnostic editor substrate.
2//!
3//! This crate is the home of the editor's logic: `App` state,
4//! dispatch, picker sources, mode lifecycle, LSP coordination,
5//! options cascade, keymap registry, buffer registry, folds,
6//! search, completion engine, file ops, oil + file-tree state.
7//!
8//! It depends on `lattice-core`, `lattice-grammar`,
9//! `lattice-config`, `lattice-mode`, `lattice-picker`,
10//! `lattice-completion`, `lattice-lsp`, `lattice-runtime`,
11//! `lattice-syntax`, and the other domain crates. It does **not**
12//! depend on any renderer crate -- `lattice-ui-tui` and the
13//! future `lattice-ui-gpui` both depend on this, never the other
14//! way around.
15//!
16//! The public entry point (Phase 5.6+) will be:
17//!
18//! ```ignore
19//! pub fn run(app: App, renderer: impl lattice_render::Renderer) -> Result<()>
20//! ```
21//!
22//! ## Phase 5 status
23//!
24//! Phase 5.1 (this slice): the crate is empty. The seam exists;
25//! the workspace builds with the new crate declared; downstream
26//! consumers can depend on it. Phase 5.2 begins the actual
27//! migration of renderer-agnostic modules out of
28//! `lattice-ui-tui`.
29//!
30//! See `docs/dev/architecture/phase-5-extraction.md` for the
31//! slice plan and module classification.
32
33pub mod action;
34pub mod actions;
35pub mod activator;
36pub(crate) mod events;
37// Autoread (AR.*): external-change detection + refresh for file-backed
38// buffers. AR.0 lands the on-disk fingerprint seam only; the `notify`
39// watcher lands in AR.2. See `docs/dev/architecture/autoread.md`.
40pub mod autoread;
41// Boot-composition BC.1: the `BootContext` skeleton — the host's
42// generic-primitive surface (the typed bundle a subsystem's future
43// `install(boot)` receives). Additive this slice; `editor_boot` migrates onto
44// it at BC.3. See `docs/dev/architecture/boot-composition.md`.
45pub mod boot_context;
46pub mod buffer_registry;
47pub mod buffers;
48pub mod chord;
49pub mod command_line_expand_mode;
50pub mod command_line_mode;
51pub mod prompt_line_mode;
52pub mod search_line_mode;
53// CB.4: native `arboard` clipboard backend shared by both renderer peers.
54// Only compiled with the `system-clipboard` feature (pulls X11/Wayland
55// libs); host's default build stays headless-friendly.
56#[cfg(feature = "system-clipboard")]
57pub mod clipboard;
58pub mod cursor_shape;
59pub mod dashboard;
60// AP.0.2: the layer peel behind `Effect::Declined`. One walk, called by the
61// host dispatcher and by both renderer peers — it was three loops, and the
62// one that did not exist is why every auto-pair key was dead in GPUI.
63pub mod decline;
64pub mod diagnostics_query;
65pub mod dispatch;
66pub mod editor;
67// BC.5: `emacs-keys-mode` moved to `lattice-mode` (a builtin). The host keeps
68// only its keymap-layer push (editor_boot keymap block + dispatch `:set`).
69pub mod visual;
70// Phase 5.7.B.1: Editor::boot extraction from
71// `lattice-ui-tui::app::boot::App::new`.
72mod editor_boot;
73pub mod excommand;
74pub mod file_tree;
75pub mod folds;
76// D.3.f.0 (2026-05-29): FoldProvider trait + registry. See
77// `docs/dev/architecture/fold-architecture.md`. Substrate-only
78// slice; the five existing fold methods become Primary
79// providers wrapping today's `compute_*_folds` helpers.
80// Overlays are mode-owned (DX.3-C7): `diff-mode` registers a
81// `HunkFoldSource` via the `FoldOverlayService`.
82pub mod fold_provider;
83// Diff subsystem (D.1–D.5+) lives under `crate::diff::*` as
84// a submodule group; see `diff/mod.rs` for the per-submodule
85// breakdown and `docs/dev/architecture/diff-system.md` for
86// the design fragment. The pure algorithm layer (`Hunk`,
87// `HunkIndex`, `compute_diff`) stays
88// in the `lattice-diff` crate per design §3 so it remains
89// reusable by non-editor consumers.
90pub mod diff;
91// M.2.b.1 (2026-05-31): all multibuffer concerns extracted into
92// the dedicated `lattice-multibuffer` crate. Host has no
93// multibuffer-specific code beyond a one-line `register(...)`
94// call at boot once M.2.b.2 lands the major mode.
95// D.4.a (2026-05-29): pane-group substrate. `PaneGroup` is
96// a set of `(pane, buffer)` pairs that scroll together
97// under a pluggable `RowMapper`. The trait + registry
98// land in this slice; the `HunkRowMapper` consumer is
99// D.4.b. See `docs/dev/architecture/pane-groups.md`.
100pub mod help;
101pub mod help_topics;
102pub mod highlights;
103// display-line B4.2 (gut + rename): formerly `highlights_worker`.
104// The dead span/row prepaint cache was deleted; only the live
105// static-overlay bucketing remains, so the module was renamed to
106// reflect that it no longer produces highlights.
107pub mod overlay_worker;
108pub mod pane_group;
109// CM.2 (2026-07-22): the error list — core/host navigation
110// substrate shaped like `position_history`. See
111// `docs/dev/architecture/compilation-mode.md` §3.
112pub mod error_list;
113// S2.2 (2026-05-26): cell-grid renderer's cell-builder worker.
114// Sibling of `overlay_worker`; consumes `RenderState.cells`
115// inputs, builds a whole-doc `CellMatrix`, publishes via
116// `Editor::cells_matrix_cell`. See
117// `docs/dev/architecture/cell-grid-renderer.md`.
118pub mod cells_worker;
119// B1 (2026-06-04): per-line display cache — the substrate that
120// retires the per-character `CellMatrix`. See
121// docs/dev/architecture/display-line.md.
122pub mod display_matrix;
123// IG.2 (2026-08-16): the per-pane indentation-guide layer, built beside
124// the display matrix and consumed by both renderer peers. See
125// `docs/dev/architecture/indent-guides.md`.
126pub mod indent_guides;
127// D.0a.1 (2026-05-29): virtual-rows worker. Sibling of
128// `cells_worker`; owns the `VirtualRowMatrix` rebuild path,
129// polls registered `VirtualRowProvider`s on wake, publishes
130// via `Editor::virtual_rows_matrix_cell`. See
131// `docs/dev/architecture/virtual-rows.md`.
132pub mod grep_highlight;
133pub mod host_generators;
134pub mod input;
135pub mod keymap;
136// CG.1 (2026-08-07): the `<C-g>` foreground-cancel binding. One chord,
137// registered in one loop so "which modes have cancel?" has a single
138// answer — and so the deliberate absence of Visual/Select is visible.
139pub mod keymap_cancel;
140pub mod virtual_rows_worker;
141// K.3.2 (2026-06-02): emacs-style <C-h> help-prefix bindings
142// (Normal-mode, Builtin layer). See module doc for the design
143// rationale incl. Option 2 (no bare <C-h> leaf).
144pub mod keymap_help;
145pub mod keymap_insert;
146// K.2.4 (2026-06-01): host translation pass that walks
147// `ModeRegistry`, calls `Mode::keymap()` on each mode, and
148// pushes each non-empty contribution as a `MinorMode(mode_id)`
149// layer on the host's `KeymapHandle`. The K.2 substrate
150// (K.2.1 chord primitives, K.2.2 BindingMode, K.2.3 real
151// Keymap) is in place; this is the plumbing.
152pub mod keymap_mode_contributions;
153pub mod keymap_normal;
154pub mod keymap_registry;
155pub mod keymap_replace;
156pub mod operator_chord_wirer;
157// Terminal-mode T2.a (2026-05-25): keystroke → ANSI byte
158// encoder consumed by the Terminal-Insert translate branch.
159pub mod keymap_select;
160pub mod keymap_terminal;
161pub mod keymap_trie;
162pub mod keymap_visual;
163// K.2.5 (2026-06-02): `multibuffer_keymap` retired. Multibuffer +
164// project-search keymap bindings and ex-commands moved to
165// `lattice-multibuffer` (`MultibufferMode::keymap()`,
166// `ProjectSearchMode::keymap()`,
167// `lattice_multibuffer::register_multibuffer_ex_commands`,
168// `lattice_multibuffer::providers::search::register_search_ex_command`).
169// Boot wiring in `editor_boot.rs` calls into the new home directly;
170// the K.2.4 translation pass picks up the `Mode::keymap()`
171// contributions and inserts them into the matcher trie.
172pub mod lsp_helpers;
173pub mod lsp_watcher;
174pub mod mode_action_handlers;
175pub mod modeline;
176pub mod modes;
177pub mod mouse;
178pub mod oil;
179pub mod pane;
180// PBH.1: per-pane buffer history (`<C-6>` / `<C-7>`). Design:
181// docs/dev/architecture/pane-buffer-history.md
182pub mod pane_history;
183pub mod pane_render;
184pub mod popup;
185pub mod preview;
186// Phase 5.8.AF.5 / Slice 3b: per-buffer cache primitive for the
187// LSP feature drains migrating off the renderer thread. See
188// `per_buffer_cache` module docs.
189pub mod per_buffer_cache;
190// Phase 5.8.AF.5 / Slice 3c: editor-actor scaffolding. Dormant
191// in 3c.0; wired by later sub-slices once render-side reads
192// migrate to RenderState.
193pub mod editor_actor;
194// Phase 5.8.AF.5 / Slice 3a: renderer's wait-free read contract
195// with the host. See `render_state` module docs.
196pub mod render_state;
197pub mod renderer;
198pub mod state;
199// TC.3a — WASM sticky-context wiring: producer -> per-buffer scope cache.
200// Sibling of `wasm_decorations`, keyed on the PARSE version rather than the
201// document version, because a scope is a function of the tree.
202// TC.3b — the pinned context strip both renderers paint from. Built in the
203// same worker pass as the DisplayMatrix, keyed by PANE (not buffer).
204pub mod sticky_context;
205pub mod wasm_context;
206pub mod wasm_decorations;
207pub mod wasm_media;
208// Phase 5.7.B.9: synthetic-buffer + messages helpers migrate
209// from `impl App` (TUI) to `impl Editor` (host) so both
210// renderer peers seed `*lsp*` + `*messages*` eagerly.
211pub mod messages;
212pub mod synthetic_buffers;
213pub mod tutor;
214pub mod ui;
215// VCS.2 (magit Layer 2): auto-inline-diff against git HEAD.
216// See `docs/dev/architecture/magit.md` §3 and
217// `docs/dev/operations/slice-plans/magit.md` VCS.2.
218pub mod vcs;
219
220// Perf plan B.4: tiny newtype wrapper that bumps a `u64` version
221// on every `DerefMut` access. Drives the identity-preserving Arc
222// publish in `render_state` so unchanged sub-states reuse their
223// prior Arc across publishes.
224pub mod versioned;
225
226// Re-export the host-side Renderer trait at the crate root for
227// the conventional `lattice_host::Renderer` path renderer
228// crates use when implementing.
229pub use renderer::{MinimalRenderer, Renderer};
230
231// K.2.4.A.0.1 (2026-06-02): re-export the `keymap_entry!` macro
232// at the host crate root so the `lattice_host::keymap_entry!`
233// path used by `lattice-ui-tui/src/lib.rs:51` keeps resolving
234// after the macro's `#[macro_export]` origin moved to
235// `lattice-mode`. The macro's canonical home is
236// `lattice_mode::keymap_entry!`; this re-export retires once
237// downstream call sites flip to the canonical path.
238pub use lattice_mode::keymap_entry;
239
240// Re-exported so downstream crates (and their tests) can suppress boot-time
241// plugin auto-discovery without depending on `lattice-plugin-loader` directly —
242// e.g. a ui-tui test that must not async-load the developer's real
243// `~/.config/lattice`. See `lattice_plugin_loader::disable_autoload`.
244pub use lattice_plugin_loader::{disable_autoload, flush_plugin_stores};