Buffer types and named modes
Development reference · View source
Before 0.5, keys.scopes supplied a second table keyed by buffer type. Replace
it with named modes and keys.bind.<mode>; buffer-types assigns their editing
roles. The built-in directory mode, for example, is already assigned to the
directory buffer type:
# 0.4
keys:
scopes:
directory:
normal:
F6: save
# 0.5: override the preset's directory mode
keys:
bind:
directory:
F6: save
The diagnostic is keys.scopes was removed in 0.5; use keys.bind.<mode> and buffer-types role maps. For a new mode, declare its parent and role explicitly:
modes:
my-directory:
inherits: directory
buffer-types:
directory:
normal: my-directory
select: directory-select
insert: insert
replace: replace
keys:
bind:
my-directory:
F6: save
A role mapping replaces the whole map, so retain each role your inherited
bindings need. There is one inheritance chain, not a global binding followed by a buffer-type
lookup. A child can replace a parent’s exact key or remove it with null.
See modes and buffer types
.
A 0.4 keys.bind.normal assignment used to apply globally in Normal mode.
In 0.5 it belongs to the named normal mode and its descendants. To share a
binding across the preset’s modal text families, put it in modal-keys:
keys:
bind:
modal-keys:
F6: save
There is no migration diagnostic for keys.bind.normal: it remains valid,
but its reach has changed. Use Space h m (:describe-mode) to see the active
mode and ancestry. Terminal, media and list modes have their own bindings.
keys.defaults: false still removes assignable built-in defaults. Safety checks
now follow the text buffer type’s declared roles rather than requiring modes
literally named Normal, Select, Insert and Replace. The Normal role must reach
the command palette; every declared editing role needs an exit ending in Normal
on every reachable branch. A preset may omit Select after removing bindings
that require that role. See starting without defaults
.