pub enum KeymapLayer {
Builtin,
MajorMode(ModeId),
MinorMode(ModeId),
User,
Buffer,
}Expand description
Where in the five-layer model (DESIGN.md §5.2.3) a binding originated. Higher value wins on cross-layer conflict; the trie itself doesn’t enforce this, the registry does at merge time.
The derived Ord is declaration order (Builtin < MajorMode(_) < MinorMode(_) < User < Buffer, same-kind mode layers by mode name),
and is the order the registry stores and reports layers in. At
lookup time, though, an active MajorMode / MinorMode layer is
overlaid above User and Buffer — see
KeymapHandle::lookup_with_context.
K.1.b (2026-05-30): MinorMode now carries a typed
ModeId instead of an opaque u32. The layer’s
identity = the mode’s identity; one layer per mode (not
per-push). A re-push for the same ModeId replaces the
layer’s bindings rather than minting a new layer.
OwnedLayer capability keys off ModeId so user /
plugin bindings targeting a specific mode’s keymap go
into that mode’s layer and live + die with the mode’s
activation lifecycle (matching emacs’s (:map foo-mode-map ...)).
Variants§
Builtin
Built-in vim default keymap. Lowest priority; user / plugin bindings shadow these.
MajorMode(ModeId)
Major-mode keymap (rust, markdown, …).
MinorMode(ModeId)
Active minor-mode keymap. The ModeId is the layer’s
identity — push for the same mode is idempotent on the
layer (bindings replaced, not appended as a sibling).
Cross-mode order at merge time comes from
active_modes[active_buffer] (K.1.c), not from the
ModeId ordering.
User
User config (init.rs).
Buffer
Per-buffer ad-hoc binding (:nmap <buffer>).
Trait Implementations§
Source§impl Clone for KeymapLayer
impl Clone for KeymapLayer
Source§fn clone(&self) -> KeymapLayer
fn clone(&self) -> KeymapLayer
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for KeymapLayer
Source§impl Debug for KeymapLayer
impl Debug for KeymapLayer
impl Eq for KeymapLayer
Source§impl Hash for KeymapLayer
impl Hash for KeymapLayer
Source§impl Ord for KeymapLayer
impl Ord for KeymapLayer
Source§fn cmp(&self, other: &KeymapLayer) -> Ordering
fn cmp(&self, other: &KeymapLayer) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for KeymapLayer
impl PartialEq for KeymapLayer
Source§impl PartialOrd for KeymapLayer
impl PartialOrd for KeymapLayer
impl StructuralPartialEq for KeymapLayer
Auto Trait Implementations§
impl Freeze for KeymapLayer
impl RefUnwindSafe for KeymapLayer
impl Send for KeymapLayer
impl Sync for KeymapLayer
impl Unpin for KeymapLayer
impl UnsafeUnpin for KeymapLayer
impl UnwindSafe for KeymapLayer
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.