Expand description
Completion-mode pair (insert-completion.md §12).
The completion machinery surfaces through two minors with different lifecycles:
-
completion-mode– “this buffer participates in insert-mode completion.” Auto-activates on writable buffer kinds (Document) at buffer creation; stays active for the buffer’s lifetime. Acts as the gatedo_completion_triggerchecks before opening the popup – read-only kinds (Help, FileTree, Oil) never activate it, so<C-Space>in those buffers is a silent no-op. -
completion-popup-mode– transient. Active iff the candidate popup is live. Owns the popup-internal keymap (<C-n>/<C-p>/<C-y>/<Tab>/<CR>/<Esc>/<C-e>/<C-d>/<C-Space>/<C-f>/<C-b>plus the per-source filter chords from CSM.K2). Replaces the imperativeApp.insert_completion.is_some()flag the v1 wiring gated on (CSM.2’s originalcompletion-mode).
Both modes own no contributed options today. The pairing
mirrors lsp-mode (umbrella, persistent) + the LSP sub-modes
(per-feature, persistent) – here the lifecycle distinction
is “persistent on writable buffers” vs “transient with the
popup.”
Placement: in lattice-mode::modes (not lattice-completion)
to avoid a dep cycle – lattice-mode already depends on
lattice-completion for the CompletionSourceContribution
return type on Mode::completion_sources() (CSM.1), so
reversing direction would require Mode itself to live in
completion.
Structs§
- Active
Completion Sources - Cached active completion-
source set for a buffer. The host
(
App::recompute_active_completion_sources_for) recomputes this on every mode-activation / -deactivation transition by walkingactive_modesand callingmode.completion_sources()on each. The aggregator reads the cache on the popup-open / refilter path – O(1) buffer- local lookup, never a walk over every active mode per keystroke (CSM.3, insert-completion.md §12.4). - Buffer
Words Mode - CSM.4 (insert-completion.md §12 first source migration):
buffer-words-mode– contributes the buffer-words completion source. Auto-activates on writable buffer kinds (Document) so the popup’s all-sources view shows words scraped from the active buffer’s text.popup_filter_chord = Some('b')⇒<C-b>insidecompletion-popup-modenarrows the popup to buffer-words only. - Completion
Mode - The “buffer participates in insert-mode completion” marker. Auto-activates on writable kinds at buffer creation. See module docs.
- Completion
Popup Mode - The popup-is-live transient minor. See module docs.
- Path
Completion Mode - CSM.7 (insert-completion.md §12 fourth source migration):
path-completion-mode– contributes the path-completion source. Auto-activates on writable buffer kinds; the source self-suppresses outside string scopes (gated byctx.path_contextwhich the host sets from its tree-sitter scope detection).popup_filter_chord = Some('f')⇒<C-f>insidecompletion-popup-modenarrows the popup to filesystem entries only.