pub struct SnippetMode { /* private fields */ }Expand description
snippet-mode — the base “snippets enabled for this buffer”
minor mode (SN.3). The language-aware feature gate: its
[ActivationPolicy] decides which buffers get snippets, and it
implies SnippetCompletionMode so the completion source
rides the same gate (activating snippet-mode brings the
source with it — no separate activation).
Three-mode decomposition (confirmed with the user 2026-06-14):
snippet-mode(this) — the gate; owns<C-x><C-s>direct-expand (SN.3c; today still host-bound).snippet-completion-mode— provides thegen:snippetcompletion source only.active-snippet-mode— in-flight placeholder nav (<Tab>/<S-Tab>/<Esc>), lit by the session-backed reconciler when a snippet expands.
SN.3b makes the policy config-driven: the mode reads a shared
SnippetActivationPolicyHandle that the host folds
snippet.activation / snippet.languages into at boot and on
every :set of those keys. The cell defaults to
ActivationPolicy::Global (behavior-preserving — the pre-SN.3
language-blind activation on every Document), which is also the
folded value when snippet.activation = global (the default).
Implementations§
Source§impl SnippetMode
impl SnippetMode
pub fn mode_id() -> ModeId
Sourcepub fn with_policy(policy: SnippetActivationPolicyHandle) -> Self
pub fn with_policy(policy: SnippetActivationPolicyHandle) -> Self
Construct with a caller-owned shared policy cell. The host
(register_snippet_modes) creates the cell and keeps a clone
so boot + :set can re-fold config into it; this mode reads
the live value in activation_policy.
Trait Implementations§
Source§impl Default for SnippetMode
impl Default for SnippetMode
Source§impl Mode for SnippetMode
impl Mode for SnippetMode
Source§fn activation_policy(&self) -> ActivationPolicy
fn activation_policy(&self) -> ActivationPolicy
SN.3b: read the live, host-folded policy from the shared
cell. Defaults to Global (snippets on every document
buffer); the snippet source still self-filters by language,
so Global means “each buffer sees its own language’s
snippets”, not “all snippets everywhere”. The resolver calls
this on each MajorEntered, so a :set snippet.activation
takes effect for buffers opened afterward.
Source§fn implies(&self) -> &[ModeId]
fn implies(&self) -> &[ModeId]
Bring snippet-completion-mode (the source provider) along
whenever snippet-mode activates — the source is gated to
exactly the buffers where snippets are enabled.
Source§fn keymap(&self) -> Keymap
fn keymap(&self) -> Keymap
SN.3c.1: contribute the <C-x><C-s> direct-expand chord.
Registered at boot under KeymapLayer::MinorMode("snippet-mode")
(Insert mode); K.1.c gates it to snippet-mode-active buffers.
Source§fn action_handlers(&self) -> Vec<ActionHandlerContribution>
fn action_handlers(&self) -> Vec<ActionHandlerContribution>
SN.3c.1: the global (buffer-agnostic) expand handler. Bound to
action:snippet-expand, registered ONCE at boot by the host’s
register_mode_action_handlers walk (NOT per-on_activate —
snippet-mode is active on many buffers at once and the
ActionHandlerRegistry is keyed by CommandId alone, so a
per-activation registration would let one buffer closing evict
the handler for all the others; see
feedback_effect_vocabulary_is_host_boundary).
The handler does ONLY the word-prefix scan: read the active
buffer’s line at ctx.cursor via the BufferStoreHandle, walk
back over word bytes to the trigger token’s start, and emit
Effect::ExpandSnippet { replace_range: token-start..cursor }.
The host owns resolution + expansion (language + registry +
variables + splice). Returns None (no effect) when there is no
word prefix at the cursor.
Source§fn kind(&self) -> ModeKind
fn kind(&self) -> ModeKind
activate_major on a minor, or vice versa, is
[ModeActivationError::WrongKind]).Source§fn required_capabilities(&self) -> CapabilitySet
fn required_capabilities(&self) -> CapabilitySet
ModeActivationError::MissingCapability], never silent
skip.Source§fn on_activate(&self, _ctx: ModeContext) -> LifecycleFuture<'_, ()>
fn on_activate(&self, _ctx: ModeContext) -> LifecycleFuture<'_, ()>
Guard
carrying every resource the mode allocated. The
dispatcher stashes the Guard until deactivation, at which
point dropping it performs cleanup via the Guard’s Drop
impl. Read more§fn target_buffer_kind(&self) -> Option<BufferKind>
fn target_buffer_kind(&self) -> Option<BufferKind>
BufferKind] this mode is the default
major for (H.2, 2026-05-31). ModeRegistry::register
indexes this so
ModeRegistry::find_major_for_kind can
dispatch buffer-creation events to the right major without
host-side match BufferKind { ... } blocks. Read more§fn target_language(&self) -> Option<&str>
fn target_language(&self) -> Option<&str>
Lang::name() —
"rust", "org") (OM.1). The peer of
target_buffer_kind for the
dispatch path [BufferKind::Document] takes: language
detection rather than kind dispatch. Read more§fn options(&self) -> OptionOverrideSet
fn options(&self) -> OptionOverrideSet
lattice_config::overrides! { lattice_config::Wrap = true, … }.§fn decorations(&self) -> Vec<DecorationProvider>
fn decorations(&self) -> Vec<DecorationProvider>
§fn gutter_decorations(&self, _ctx: &DecorationCtx<'_>) -> Vec<GutterDecoration>
fn gutter_decorations(&self, _ctx: &DecorationCtx<'_>) -> Vec<GutterDecoration>
DecorationCtx]
carrying relevant render-state snapshots (diff sign map, LSP
diagnostics arc). Returns per-line GutterDecoration values;
the renderer partitions them by variant into the appropriate
gutter column. Default: empty (no contribution).§fn completion_sources(&self) -> Vec<CompletionSourceContribution>
fn completion_sources(&self) -> Vec<CompletionSourceContribution>
lsp-completion-mode,
snippet-completion-mode, buffer-words-mode,
tree-sitter-completion-mode, path-completion-mode,
plugin sources) override.§fn conflicts_with(&self) -> &[ModeId]
fn conflicts_with(&self) -> &[ModeId]
§fn presents_extensions(&self) -> &[&'static str]
fn presents_extensions(&self) -> &[&'static str]
§fn mirrors_option(&self) -> Option<&'static str>
fn mirrors_option(&self) -> Option<&'static str>
Some(canonical_name) ⇒ a host-driven cascade keeps the
mode’s active state and the option’s value in sync.§fn invocation_runner(&self) -> Option<ModeId>
fn invocation_runner(&self) -> Option<ModeId>
ModeId]; the host registers a
runner function under that id at boot, and
Editor::run_invocation looks it up by walking the
active modes on the active pane’s buffer (minors first,
then major) before falling back to the central grammar
Action gate. Read more§fn refresh_action(&self) -> Option<&'static str>
fn refresh_action(&self) -> Option<&'static str>
None (the default) when the mode backs nothing
refreshable (RV.1, 2026-08-10). Read more§fn fold_toggle_action(&self) -> Option<&'static str>
fn fold_toggle_action(&self) -> Option<&'static str>
<Tab> fires, and the declaration that
pulls in
foldable-view-mode —
the shared minor owning the chord. Read more§fn refresh_on_open(&self) -> bool
fn refresh_on_open(&self) -> bool
§fn editable_tail(&self) -> Option<EditableTail>
fn editable_tail(&self) -> Option<EditableTail>
None (the default) for a fully read-only / fully writable buffer
(AU‑3). Read moreAuto Trait Implementations§
impl Freeze for SnippetMode
impl RefUnwindSafe for SnippetMode
impl Send for SnippetMode
impl Sync for SnippetMode
impl Unpin for SnippetMode
impl UnsafeUnpin for SnippetMode
impl UnwindSafe for SnippetMode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<M> DynMode for Mwhere
M: Mode,
impl<M> DynMode for Mwhere
M: Mode,
§fn target_buffer_kind(&self) -> Option<BufferKind>
fn target_buffer_kind(&self) -> Option<BufferKind>
Mode::target_buffer_kind].§fn target_language(&self) -> Option<&str>
fn target_language(&self) -> Option<&str>
Mode::target_language].§fn decorations(&self) -> Vec<DecorationProvider>
fn decorations(&self) -> Vec<DecorationProvider>
Mode::decorations].§fn gutter_decorations(&self, ctx: &DecorationCtx<'_>) -> Vec<GutterDecoration>
fn gutter_decorations(&self, ctx: &DecorationCtx<'_>) -> Vec<GutterDecoration>
Mode::gutter_decorations].§fn completion_sources(&self) -> Vec<CompletionSourceContribution>
fn completion_sources(&self) -> Vec<CompletionSourceContribution>
Mode::completion_sources].§fn action_handlers(&self) -> Vec<ActionHandlerContribution>
fn action_handlers(&self) -> Vec<ActionHandlerContribution>
Mode::action_handlers].§fn required_capabilities(&self) -> CapabilitySet
fn required_capabilities(&self) -> CapabilitySet
Mode::required_capabilities].§fn conflicts_with(&self) -> &[ModeId]
fn conflicts_with(&self) -> &[ModeId]
Mode::conflicts_with].§fn presents_extensions(&self) -> &[&'static str]
fn presents_extensions(&self) -> &[&'static str]
Mode::presents_extensions].§fn mirrors_option(&self) -> Option<&'static str>
fn mirrors_option(&self) -> Option<&'static str>
Mode::mirrors_option].§fn invocation_runner(&self) -> Option<ModeId>
fn invocation_runner(&self) -> Option<ModeId>
Mode::invocation_runner].§fn refresh_action(&self) -> Option<&'static str>
fn refresh_action(&self) -> Option<&'static str>
Mode::refresh_action].§fn fold_toggle_action(&self) -> Option<&'static str>
fn fold_toggle_action(&self) -> Option<&'static str>
Mode::fold_toggle_action].§fn refresh_on_open(&self) -> bool
fn refresh_on_open(&self) -> bool
Mode::refresh_on_open].§fn activation_policy(&self) -> ActivationPolicy
fn activation_policy(&self) -> ActivationPolicy
Mode::activation_policy].§fn editable_tail(&self) -> Option<EditableTail>
fn editable_tail(&self) -> Option<EditableTail>
Mode::editable_tail].§fn on_activate_dyn<'a>(
&'a self,
ctx: ModeContext,
) -> Pin<Box<dyn Future<Output = Result<Box<dyn Any + Send>, ModeActivationError>> + Send + 'a>>
fn on_activate_dyn<'a>( &'a self, ctx: ModeContext, ) -> Pin<Box<dyn Future<Output = Result<Box<dyn Any + Send>, ModeActivationError>> + Send + 'a>>
Box<dyn Any + Send>.
The dispatcher stashes this box keyed by
(BufferId, ModeId); deactivation drops it.