Expand description
Layered option overrides (M.2.1).
Modes (and other layer producers — buffer-local sets,
modal-state hooks) contribute typed overrides via
OptionOverride. The resolver in lattice-config walks
the layers in priority order (mode-architecture.md §6.1)
and picks the first non-empty value per option for scalars;
collection-shaped options concatenate.
§Why this lives in lattice-config
Mode::options() (in lattice-mode) returns an
OptionOverrideSet. These types once lived in lattice-mode
to break a lattice-mode → lattice-config → lattice-core → lattice-mode cycle; the M.4 dependency inversion removed
Document::modes from lattice-core, retiring the cycle, so the
layer inputs now sit beside the crate::Resolver and
crate::ResolvedOptions they feed. lattice-mode re-exports
them.
§Type-safe construction via lattice-config’s overrides!
Modes don’t construct OptionOverride directly with the
erased OptionOverride::new API. Instead they use the
overrides! macro from lattice-config, which has access
to OptionDecl and emits compile-time-typed wrappers around
OptionOverride::new:
use lattice_config::{OptionOverrideSet, OverridePriority, Tabstop, Wrap};
fn options() -> OptionOverrideSet {
lattice_config::overrides! {
Tabstop = 4,
#[priority(High)]
Wrap = false,
}
}
let set = options();
assert_eq!(set.len(), 2);
let wrap = set.iter().nth(1).unwrap();
assert_eq!(wrap.downcast_value::<bool>(), Some(&false));
assert_eq!(wrap.priority, OverridePriority::High);The macro asserts at compile time that each value matches its
declaration’s Value type. Direct OptionOverride::new
is reserved for the WIT plugin adapter (M.10), where
declarations are runtime data and TypeId is the only handle.
Structs§
- Option
Override - One option-value override from a single layer producer (a mode, a buffer-local set, a modal-state hook).
- Option
Override Set - A set of
OptionOverrides contributed by one layer producer (typically the return value ofMode::options()).
Enums§
- Override
Priority - Tie-break priority for two layer entries that target the same option.