Skip to main content

Module modes

Module modes 

Source
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 / :keymap views. 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; :w diffs 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§

CenterContentWidth
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) / 2 and adds it to the gutter, so content + cursor shift right (centred) with no text mutation — markdown / links stay intact. Absent = not centred.
DocumentFolds
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.
DocumentLastParsedTextVersion
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.
DocumentLastSyncedSyntaxVersion
Document version that was the baseline for the last syntax- worker request fired for this buffer. Sent as from_version on each request so the worker can verify edits apply to the expected tree baseline before running the incremental tree.edit(). Independent of last_parsed_text_version because the worker may still be in flight when the next request fires.
DocumentSyntax
Per-document tree-sitter syntax handle. Some once a language has been detected for the buffer and a parse has been requested; None for Lang::Plain documents and for buffers that haven’t been activated yet.
ExtraHighlights
PU.1b-2a: generic per-buffer static highlight spans, merged into the cells-worker DisplayMatrix ON TOP OF (overriding, by first-match precedence) the live grammar spans on their byte ranges. Indexed by source line. Unlike DocumentSyntax (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.
ExtraInlays
DL.3b: generic per-buffer inline virtual text, merged beside the LSP inlay hints when the pane’s cells inputs are built.
ExtraRefinement
DR.3 (2026-08-12): per-buffer intra-line diff refinement — the byte ranges whose BACKGROUND differs from their row’s diff tint.
FileTreeEntries
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
FileTreeMode
Major mode for file-tree buffers. Read-only contribution (ReadOnly = true); any buffer whose major is file-tree-mode rejects mutating operators.
FileTreeNerdFonts
Whether the file-tree renders nerd-font icon glyphs inline.
FileTreeRoot
Filesystem path the file-tree buffer is rooted at. Single source of truth (M.3.2.c.5).
HelpAnchors
Help buffer’s named anchors (heading slugs + introspection-recorded anchors).
HelpLinks
Help buffer’s parsed [label](url) markdown links.
HelpMode
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.
HoverMode
hover-mode — marker minor on the hover popup buffer (activated alongside markdown-mode). Wraps long lines and borrows help-mode’s read-only invocation runner; see the module docs.
OilDir
BufferLocal carrying the filesystem path the oil buffer’s listing represents (M.3.2.c.3 mirror of OilBuffer::dir). Renderers / writers read through this rather than poking OilBuffer::dir directly 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-mode is an OilBuffer; 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-mode on 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 get help-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 BufferKind via 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::modes and register through lattice_mode::modes::register_foundation_modes alongside TextMode. This shim is kept as a no-op so existing register_buffer_kind_modes callers don’t break; the App’s boot path now calls register_foundation_modes directly 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 Document kinds) detected language.