Expand description
Major modes for buffer kinds owned by the TUI layer.
Three majors corresponding to the existing BufferKind
variants beyond Document:
help-mode–:describe-*/:apropos/:keymapviews. Read-only; markdown-mode-style content with link navigation (<CR>follows a link).file-tree-mode– the file-tree navigation buffer. Tree expansion / collapse, open-on-<CR>.oil-mode– editable directory listing (oil.nvim-style). Writable;:wdiffs the rope and applies filesystem ops.
Pure declarations in M.3.0. The actual behavior currently
lives in scattered call sites in app.rs / render.rs /
input.rs; M.3.1 routes those through the mode-id queries
and M.4 unifies rendering through ResolvedOptions.
Per mode-architecture.md §4.1 the TUI also hosts
command-line-mode and search-line-mode for the rich
minibuffer (DESIGN.md §5.9.10), but the rich minibuffer
refactor isn’t landed yet – those modes are deferred to
the slice that ships them.
Structs§
- Center
Content Width - DB.4: the content block width (widest line, in cells) for a buffer that
should be horizontally centred by widening its gutter. Set by the dashboard;
the renderer computes
left_pad = (viewport_width - width) / 2and adds it to the gutter, so content + cursor shift right (centred) with no text mutation — markdown / links stay intact. Absent = not centred. - Document
Folds - Per-document fold list. Empty means “not yet computed for this buffer.” First-activation seeds from the active foldmethod; subsequent re-activations restore the user’s open / closed state. Universal across language majors – the foundational text-mode owns the data shape; per-language fold queries are a presentation-layer concern read through the syntax local.
- Document
Last Parsed Text Version - Document version (the rope’s monotonic edit counter) of the
most recent successful parse. The renderer’s syntax walk
short-circuits when
text_version == last_parsed_text_version; the reparse seam treats inequality as “edits to drain into the worker” and fires an incremental reparse. - Document
Last Synced Syntax Version - Document version that was the baseline for the last syntax-
worker request fired for this buffer. Sent as
from_versionon each request so the worker can verify edits apply to the expected tree baseline before running the incrementaltree.edit(). Independent oflast_parsed_text_versionbecause the worker may still be in flight when the next request fires. - Document
Syntax - Per-document tree-sitter syntax handle.
Someonce a language has been detected for the buffer and a parse has been requested;NoneforLang::Plaindocuments and for buffers that haven’t been activated yet. - Extra
Highlights - PU.1b-2a: generic per-buffer static highlight spans, merged into
the cells-worker
DisplayMatrixON TOP OF (overriding, by first-match precedence) the live grammar spans on their byte ranges. Indexed by source line. UnlikeDocumentSyntax(the live grammar handle, dynamic per edit) these are fixed for the buffer’s content — the home for styling the grammar can’t derive because the source text was transformed before parsing (help-link labels, whose[label](target)markup is stripped before the markdown grammar runs, so the grammar never emits a link capture). Property-derived, NOT kind-specific: any buffer carrying this local gets the merge; empty/absent is the universal default and renders byte-identically. - Extra
Inlays - DL.3b: generic per-buffer inline virtual text, merged beside the LSP inlay hints when the pane’s cells inputs are built.
- Extra
Refinement - DR.3 (2026-08-12): per-buffer intra-line diff refinement — the byte ranges whose BACKGROUND differs from their row’s diff tint.
- File
Tree Entries - Flat tree-of-entries backing the file-tree buffer.
Each entry carries its depth + expansion state. The rendered
rope is derived from this list – App-side toggle handlers
mutate the entries through the
[
crate::toggle_entries_at] helper and re-write this local - File
Tree Mode - Major mode for file-tree buffers. Read-only contribution
(
ReadOnly = true); any buffer whose major isfile-tree-moderejects mutating operators. - File
Tree Nerd Fonts - Whether the file-tree renders nerd-font icon glyphs inline.
- File
Tree Root - Filesystem path the file-tree buffer is rooted at. Single source of truth (M.3.2.c.5).
- Help
Anchors - Help buffer’s named anchors (heading slugs + introspection-recorded anchors).
- Help
Links - Help buffer’s parsed
[label](url)markdown links. - Help
Mode help-mode— the minor that makes a (markdown-major) buffer a help buffer: read-only, gutterless, no-file,<Esc>dismisses it, and its motions run through the read-only help invocation runner. Activated by the host on:help/:describe-*/:apropos/:keymap/ … views; see the module docs.- Hover
Mode hover-mode— marker minor on the hover popup buffer (activated alongsidemarkdown-mode). Wraps long lines and borrows help-mode’s read-only invocation runner; see the module docs.- OilDir
BufferLocalcarrying the filesystem path the oil buffer’s listing represents (M.3.2.c.3 mirror ofOilBuffer::dir). Renderers / writers read through this rather than pokingOilBuffer::dirdirectly so the canonical “what directory does this oil buffer represent” lookup is uniform with the rest of the mode-owned per-buffer state.- OilMode
- Major mode for oil-style directory-listing buffers. Any
buffer whose major is
oil-modeis anOilBuffer; the renderer dispatches accordingly.
Functions§
- auto_
activated_ minors_ for_ buffer_ kind - CSM.K1 (insert-completion.md §12): additional minor modes
the App activates alongside the buffer’s major + the kind’s
default_minor. Today:completion-modeon writable kinds (Document) so<C-Space>opens the popup; read-only kinds (Help, FileTree, Oil) don’t activate it, so the trigger chord is a silent no-op there. - default_
minor_ mode_ id_ for_ buffer_ kind - M.4 (Option B): minor modes the App activates alongside the
major resolved by
major_mode_id_for_buffer_kind. Returns the per-kind minor that gives the buffer its full identity. Help buffers gethelp-mode(read-only + link/anchor follow); other kinds currently get nothing – their majors already carry their full contribution set. - major_
mode_ id_ for_ buffer_ kind - Resolve the default major-mode id for a
BufferKindvia the registry’s kind index (H.2). - register_
buffer_ kind_ modes - M.4 follow-up: the per-kind modes (HelpMode, HoverMode,
FileTreeMode, OilMode) moved to
lattice_mode::modesand register throughlattice_mode::modes::register_foundation_modesalongsideTextMode. This shim is kept as a no-op so existingregister_buffer_kind_modescallers don’t break; the App’s boot path now callsregister_foundation_modesdirectly and drops this helper in a follow-up. - resolve_
major_ mode - Resolve the major-mode id a buffer should activate based on
its kind + (for
Documentkinds) detected language.