From dfc17becd56efbc1f65de7c8d65cb32ad4690db1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Tue, 30 Mar 2021 18:38:26 +0900 Subject: [PATCH] Move pickers under my leader key mode (space). --- helix-term/src/commands.rs | 20 ++++++++++++++++++++ helix-term/src/keymap.rs | 4 ++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 7233f1daf..1b46aa62b 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -1853,3 +1853,23 @@ pub fn jump_backward(cx: &mut Context) { doc.set_selection(selection); }; } + +// + +pub fn space_mode(cx: &mut Context) { + cx.on_next_key(move |cx, event| { + if let KeyEvent { + code: KeyCode::Char(ch), + .. + } = event + { + // TODO: temporarily show SPC in the mode list + match ch { + 'f' => file_picker(cx), + 'b' => buffer_picker(cx), + // ' ' => toggle_alternate_buffer(cx), + _ => (), + } + } + }) +} diff --git a/helix-term/src/keymap.rs b/helix-term/src/keymap.rs index eed6ee54d..eeecd08e2 100644 --- a/helix-term/src/keymap.rs +++ b/helix-term/src/keymap.rs @@ -244,8 +244,6 @@ pub fn default() -> Keymaps { ctrl!('u') => commands::half_page_up, ctrl!('d') => commands::half_page_down, - ctrl!('p') => commands::file_picker, - ctrl!('b') => commands::buffer_picker, KeyEvent { code: KeyCode::Tab, modifiers: KeyModifiers::NONE @@ -260,6 +258,8 @@ pub fn default() -> Keymaps { ctrl!('i') => commands::jump_forward, // TODO: ctrl-i conflicts tab ctrl!('o') => commands::jump_backward, // ctrl!('s') => commands::save_selection, + + key!(' ') => commands::space_mode, ); // TODO: decide whether we want normal mode to also be select mode (kakoune-like), or whether // we keep this separate select mode. More keys can fit into normal mode then, but it's weird