Flesh out helix bindings (#28103)

This brings in a bunch of helix bindings (many of them from
infogulch/zed-helix-keymap) and implements helix-style delete.

Release Notes:

- vim: Expanded default helix-style keybindings in HelixNormal mode
This commit is contained in:
jneem 2025-04-05 01:21:15 +07:00 committed by GitHub
parent 558d61b907
commit 435fff94bd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 111 additions and 12 deletions

View file

@ -48,6 +48,7 @@ actions!(
JoinLinesNoWhitespace,
DeleteLeft,
DeleteRight,
HelixDelete,
ChangeToEndOfLine,
DeleteToEndOfLine,
Yank,
@ -92,6 +93,21 @@ pub(crate) fn register(editor: &mut Editor, cx: &mut Context<Vim>) {
let times = Vim::take_count(cx);
vim.delete_motion(Motion::Right, times, window, cx);
});
Vim::action(editor, cx, |vim, _: &HelixDelete, window, cx| {
vim.record_current_action(cx);
vim.update_editor(window, cx, |_, editor, window, cx| {
editor.change_selections(None, window, cx, |s| {
s.move_with(|map, selection| {
if selection.is_empty() {
selection.end = movement::right(map, selection.end)
}
})
})
});
vim.visual_delete(false, window, cx);
});
Vim::action(editor, cx, |vim, _: &ChangeToEndOfLine, window, cx| {
vim.start_recording(cx);
let times = Vim::take_count(cx);

View file

@ -438,7 +438,7 @@ impl Vim {
vim.update(cx, |_, cx| {
Vim::action(editor, cx, |vim, _: &SwitchToNormalMode, window, cx| {
vim.switch_mode(Mode::Normal, false, window, cx)
vim.switch_mode(vim.default_mode(cx), false, window, cx)
});
Vim::action(editor, cx, |vim, _: &SwitchToInsertMode, window, cx| {
@ -739,6 +739,10 @@ impl Vim {
cx.on_release(|_, _| drop(subscription)).detach();
}
pub fn default_mode(&self, cx: &App) -> Mode {
VimSettings::get_global(cx).default_mode
}
pub fn editor(&self) -> Option<Entity<Editor>> {
self.editor.upgrade()
}
@ -1105,7 +1109,7 @@ impl Vim {
}
}
if mode == "normal" || mode == "visual" || mode == "operator" {
if mode == "normal" || mode == "visual" || mode == "operator" || mode == "helix_normal" {
context.add("VimControl");
}
context.set("vim_mode", mode);