Skip to main content

Module activation

Module activation 

Source
Expand description

SN.3b — config-driven snippet activation policy.

SnippetMode’s ActivationPolicy is folded from two user-facing options the mode owns ([[feedback_mode_owns_its_surface]]):

  • snippet.activation (global | supported-languages | off, default global) — the gate shape. A closed three-value set, so it’s a typed enum (SnippetActivationMode) with an OptionType impl, giving :set snippet.activation=<Tab> completion the same way foldmethod does.
  • snippet.languages (default empty) — a comma-separated language-id allowlist, consulted only when snippet.activation = supported-languages. It’s a plain String because the typed-option loader rejects TOML arrays for scalar options (lattice_config::loader::apply_scalar): snippet.languages = "rust,python" in TOML, or :set snippet.languages=rust,python.

The host folds both into a shared SnippetActivationPolicyHandle at boot and re-folds on the apply_option_cascade arm for either key (:set live). The resolver reads SnippetMode::activation_policy() — which loads the shared cell — on each MajorEntered, so new buffers pick up the live policy. (Already-open buffers are not retroactively re-resolved in SN.3b; the policy applies on their next major entry.)

Structs§

SnippetActivation
Which buffers get snippets. Default global — snippets on every document buffer, each buffer seeing only its own language’s snippets (the completion source self-filters by language). supported-languages restricts activation to the snippet.languages allowlist; off disables auto-activation entirely.
SnippetLanguages
Comma-separated language ids for which snippets activate when snippet.activation = supported-languages. Each id L maps to the major mode L-mode, so only registered majors match (today: rust / python / javascript / markdown). Ignored when snippet.activation is global or off. A list (not a scalar) in spirit, but stored as a string because the typed- option loader rejects TOML arrays: snippet.languages = "rust,python".

Enums§

SnippetActivationMode
snippet.activation — which buffers get snippets.

Functions§

fold_activation_policy
Fold snippet.activation + snippet.languages into the concrete [ActivationPolicy] the resolver consults.

Type Aliases§

SnippetActivationPolicyHandle
Shared, swappable snippet activation policy. SnippetMode reads it via activation_policy(); the host folds config into it at boot and on every snippet.activation / snippet.languages :set. Cloning the outer Arc shares the same cell — the host’s Editor keeps one clone to store() into and the mode keeps another to load() from.