ship the Vim keymap preset

T-65 — the capstone of the Vim epic. assets/keymaps/vim.yaml binds the
muscle-memory set guarded on vim.normal/insert/visual: hjkl/w/b/e/0/$/^/
gg/G motions, x/dd/dw/D/yy/p/P/cc/cw edits, i/a/I/A/o/O insert entries,
v + d/y/c in visual, Esc back to normal, and counts via the matcher. App
shortcuts (palette, find, zoom) are carried in the preset so they survive
under Vim.

The editor now feeds Shift chords to the matcher (Vim's capitals: G, D,
A, P, $) while still bubbling Ctrl/Alt/Meta to the global handler. The
keybindings-ui stub gains palette commands (`Keymap: Vim` / `Keymap:
Default`) to switch presets — the user-facing way to turn Vim on.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-01 21:32:40 +02:00
co-authored by Claude Opus 4.8
parent caca816233
commit bcb57bc75f
8 changed files with 355 additions and 9 deletions
@@ -0,0 +1,35 @@
/// T-65: the keybindings UI contributes palette commands that switch the
/// active keymap preset.
library;
import 'package:clide/builtin/keybindings_ui/keybindings_ui.dart';
import 'package:clide/kernel/kernel.dart';
import 'package:flutter_test/flutter_test.dart';
import '../../helpers/kernel_fixture.dart';
void main() {
late KernelFixture f;
setUp(() async {
f = await KernelFixture.create();
f.services.extensions.register(KeybindingsUiExtension());
await f.services.extensions.activate('builtin.keybindings-ui');
});
tearDown(() => f.dispose());
test('contributes a switch command per shipped preset', () {
expect(f.services.commands.get('keymap.preset.vim'), isNotNull);
expect(f.services.commands.get('keymap.preset.default'), isNotNull);
});
test('running the vim command switches the active preset', () async {
await f.services.commands.execute('keymap.preset.vim');
expect(f.services.settings.get<String>(kKeymapPresetSetting), 'vim');
});
test('switching back to default works', () async {
await f.services.commands.execute('keymap.preset.vim');
await f.services.commands.execute('keymap.preset.default');
expect(f.services.settings.get<String>(kKeymapPresetSetting), 'default');
});
}