Expand description
First-party picker source generators – renderer-neutral; live
in lattice-picker next to the PickerSourceGenerator trait
and the PickerRegistry they register against. Symmetric with
how feature crates already organise their sources
(lattice_snippet::picker_sources, future
lattice_lsp::picker_sources).
Each source’s state is reachable through PickerContext (the
snapshot passed to init / accept) or via an Arc-cloned
registry handle captured at construction (CommandsSource ->
CommandRegistry, GrepSource -> ConfigRegistry). The trait
surface stays state-handle-free.
Slice 5.7.B.0 migrated this module out of lattice-ui-tui. The
walk_files_for_picker helper (file-system walk for :picker files) lives here too – it has no renderer dependency, and the
only consumer today is FilesSource; the earlier ui-tui
location was an accident of where the picker first landed.
Structs§
- Buffers
Source :picker buffers. Walksctx.buffersand emits one row per registered buffer, with(current)marginalia on the active one. Active buffer floats to the bottom of the list so the alternate-buffer convention (<C-^>-style) keeps working: the initial selection lands on the alternate, not on the buffer the user already sees.- Command
History Source :picker history— also reached via theq:Normal chord and the:historyex-command (MB.3). Walksctx.command_history(the App’s command-line history ring, stored oldest-first) and emits one row per past command, newest first.<CR>loads the chosen command into the editable:line viaRoutingPayload::LoadCommandLine— it does not execute; the user tweaks (or<C-x><C-e>expands) then<CR>s. The modern replacement for vim’s command-line window: fuzzy-filter past commands instead of scrolling a scratch buffer (docs/dev/architecture/rich-minibuffer.md§4).- Commands
Source :picker commands. Walks the App’sCommandRegistryand emits one row per registered ex-command (motions, operators, etc. are not user-invocable through this surface and stay out). Captures anArc<CommandRegistry>at construction time – the registry doesn’t live onPickerContextbecause it’s static App-wide state, not per-invocation snapshot data.- DirPick
Source - PC.9:
dir-pick—FilePickSource’s directory peer. Browse to a directory and supply its path as a value. - File
Pick Source :picker file-pick [root]. MG.53.e — the same walk asFilesSource, accepting to a value instead of to an open buffer.- Files
Source - Grep
Source - Jumps
Source :picker jumps. Walksctx.position_history(unified jump-list + mark-ring per §5.1.1) and emits one row per entry, newest first. Accept emitsJumpInBufferso the host’s apply translator handles “activate buffer + position cursor” uniformly. MRU is correctly absent for these rows –routing_identityreturnsNoneforJumpInBufferbecause coordinates drift.- Lines
Source :picker lines. Walks the active buffer’s rope and emits one row per logical line, displayed as<lineno>: <text>. Accept jumps the cursor to that line viaRoutingPayload::JumpInBuffer. The buffer_id is captured at picker-open so a sibling hover-preview can’t accidentally redirect the jump.- Marks
Source :picker marks. Walksctx.marks(sorted by name inbuild_picker_context) and emits one row per set mark. Accept emitsJumpToMark { name }which the host resolves throughdo_jump_mark– same path the`motion uses, so cursor placement + position-history push match keyboard-driven behavior. MRU will key onmark:<name>automatically when slice 14 lands.- Outline
Source :picker outline. Tree-sitter-driven symbol outline for the active buffer. Readsctx.active_buffer.syntax_symbols(pre-collected by the host viaSyntax::collect_symbol_locations) and emits one row per symbol, sorted by source position. Accept jumps the cursor to the symbol viaJumpInBuffer.- Pane
Buffer History Source - PBH.5:
:picker pane-buffer-history— also reached via:history pane-buffers. Walks the ACTIVE pane’s buffer trail (ctx.pane_buffer_history, oldest-first as stored) and emits one row per stop, newest first, marking the entry the walk cursor currently sits on. - Recent
Files Source :picker recent. Walksctx.recent_files(MRU, newest first) and emits one row per path. Empty MRU returnsErr("no recent files")which the host echoes.- Registers
Source :picker registers. Walksctx.registers((name, preview)pairs already prepared by the host’sbuild_picker_context) and emits one row per register. Accept emitsPasteRegister { name }; the host routes throughdo_pastewith the chosen register pre-selected.- Search
History Source - MB.5:
:picker search-history— also reached via theq//q?Normal chords and:history search. Walksctx.search_history(the App’s search-line history ring, stored oldest-first) and emits one row per past search term, newest first.<CR>loads the chosen term into the editable/line viaRoutingPayload::LoadSearchLine— it does not execute. - Yank
Ring Source :picker yank-ring. YR.4 — the yank ring and the live named registers, in one list.
Constants§
- DIR_
PICK_ SOURCE - The source id, shared by the generator and every declaration that names it.
- FILE_
PICKER_ MAX_ ENTRIES - Hard cap on the file-picker walker’s emitted entry count.
At this scale the host’s fuzzy matcher stays well inside the
per-keystroke frame budget; larger trees fall back to ripgrep-
style live filtering via
:grep(P.10) or:Filetree’s per-directory lazy walk. - FILE_
PICK_ SOURCE - The source id, shared by the generator and every declaration that names it — one constant so a rename cannot leave a transient pointing at a source that no longer exists.
- PARENT_
ROW_ DISPLAY - What PP.1’s go-up row displays — and, since PP.3, how it is RECOGNISED.
- YANK_
RING_ SOURCE
Traits§
- Grep
Preview Highlighter :picker grep <pattern>. Shells out to a configurable backend (rg,ag,grep, orauto-detected at invocation time) and walks its output line-by-line.
Functions§
- first_
party_ generators - Convenience: build the first-party source generators as
Arc<dyn PickerSourceGenerator>ready to register against aPickerRegistry. Used byApp::new(and a future host- ownedEditor::boot) to boot the registry. Sources that need App-wide state captured at construction (e.g.CommandsSource->CommandRegistry,GrepSource->ConfigRegistry) take the relevantArchere so the trait surface stays state-handle-free. - walk_
files_ for_ picker - Walk
rootrecursively (BFS) and return the absolute paths of every regular file (with its metadata), capped atFILE_PICKER_MAX_ENTRIES. - warm_
files_ cache - Pre-walk
rootinto the session cache so the first:filesopen is instant. The host calls this from a background thread at boot (and on project change);FilesSource::initalso calls it to refresh a warm entry. Runs the samewalk_files_for_picker— off whatever thread the caller spawns it on, never the UI thread.
Type Aliases§
- Walked
File - One walked file: its absolute path plus the metadata gathered during the
walk (
Nonewhen the entry could not be stat’d). Returned bywalk_files_for_pickerso a source’sinitbuilds candidates + their marginalia without a second stat pass.