Move pickers under my leader key mode (space).

This commit is contained in:
Blaž Hrastnik 2021-03-30 18:38:26 +09:00
parent e166da2ab0
commit dfc17becd5
2 changed files with 22 additions and 2 deletions

View File

@ -1853,3 +1853,23 @@ pub fn jump_backward(cx: &mut Context) {
doc.set_selection(selection); 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),
_ => (),
}
}
})
}

View File

@ -244,8 +244,6 @@ pub fn default() -> Keymaps {
ctrl!('u') => commands::half_page_up, ctrl!('u') => commands::half_page_up,
ctrl!('d') => commands::half_page_down, ctrl!('d') => commands::half_page_down,
ctrl!('p') => commands::file_picker,
ctrl!('b') => commands::buffer_picker,
KeyEvent { KeyEvent {
code: KeyCode::Tab, code: KeyCode::Tab,
modifiers: KeyModifiers::NONE modifiers: KeyModifiers::NONE
@ -260,6 +258,8 @@ pub fn default() -> Keymaps {
ctrl!('i') => commands::jump_forward, // TODO: ctrl-i conflicts tab ctrl!('i') => commands::jump_forward, // TODO: ctrl-i conflicts tab
ctrl!('o') => commands::jump_backward, ctrl!('o') => commands::jump_backward,
// ctrl!('s') => commands::save_selection, // 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 // 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 // we keep this separate select mode. More keys can fit into normal mode then, but it's weird