Load all keybindings from JSON file
This commit is contained in:
parent
b4babbeeaa
commit
9a4b8e3d8c
9 changed files with 81 additions and 53 deletions
|
@ -1,18 +1,12 @@
|
|||
use crate::{mode::Mode, SwitchMode, VimState};
|
||||
use editor::Bias;
|
||||
use gpui::{actions, keymap::Binding, MutableAppContext, ViewContext};
|
||||
use gpui::{actions, MutableAppContext, ViewContext};
|
||||
use language::SelectionGoal;
|
||||
use workspace::Workspace;
|
||||
|
||||
actions!(vim, [NormalBefore]);
|
||||
|
||||
pub fn init(cx: &mut MutableAppContext) {
|
||||
let context = Some("Editor && vim_mode == insert");
|
||||
cx.add_bindings(vec![
|
||||
Binding::new("escape", NormalBefore, context),
|
||||
Binding::new("ctrl-c", NormalBefore, context),
|
||||
]);
|
||||
|
||||
cx.add_action(normal_before);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
mod g_prefix;
|
||||
|
||||
use crate::{mode::NormalState, Mode, SwitchMode, VimState};
|
||||
use crate::VimState;
|
||||
use editor::{char_kind, movement, Bias};
|
||||
use gpui::{actions, impl_actions, keymap::Binding, MutableAppContext, ViewContext};
|
||||
use gpui::{actions, impl_actions, MutableAppContext, ViewContext};
|
||||
use language::SelectionGoal;
|
||||
use serde::Deserialize;
|
||||
use workspace::Workspace;
|
||||
|
@ -40,26 +40,7 @@ actions!(
|
|||
);
|
||||
|
||||
pub fn init(cx: &mut MutableAppContext) {
|
||||
let context = Some("Editor && vim_mode == normal");
|
||||
cx.add_bindings(vec![
|
||||
Binding::new("i", SwitchMode(Mode::Insert), context),
|
||||
Binding::new("g", SwitchMode(Mode::Normal(NormalState::GPrefix)), context),
|
||||
Binding::new("h", MoveLeft, context),
|
||||
Binding::new("j", MoveDown, context),
|
||||
Binding::new("k", MoveUp, context),
|
||||
Binding::new("l", MoveRight, context),
|
||||
Binding::new("0", MoveToStartOfLine, context),
|
||||
Binding::new("shift-$", MoveToEndOfLine, context),
|
||||
Binding::new("shift-G", MoveToEnd, context),
|
||||
Binding::new("w", MoveToNextWordStart(false), context),
|
||||
Binding::new("shift-W", MoveToNextWordStart(true), context),
|
||||
Binding::new("e", MoveToNextWordEnd(false), context),
|
||||
Binding::new("shift-E", MoveToNextWordEnd(true), context),
|
||||
Binding::new("b", MoveToPreviousWordStart(false), context),
|
||||
Binding::new("shift-B", MoveToPreviousWordStart(true), context),
|
||||
]);
|
||||
g_prefix::init(cx);
|
||||
|
||||
cx.add_action(move_left);
|
||||
cx.add_action(move_down);
|
||||
cx.add_action(move_up);
|
||||
|
|
|
@ -1,16 +1,10 @@
|
|||
use crate::{mode::Mode, SwitchMode, VimState};
|
||||
use gpui::{actions, keymap::Binding, MutableAppContext, ViewContext};
|
||||
use gpui::{actions, MutableAppContext, ViewContext};
|
||||
use workspace::Workspace;
|
||||
|
||||
actions!(vim, [MoveToStart]);
|
||||
|
||||
pub fn init(cx: &mut MutableAppContext) {
|
||||
let context = Some("Editor && vim_mode == normal && vim_submode == g");
|
||||
cx.add_bindings(vec![
|
||||
Binding::new("g", MoveToStart, context),
|
||||
Binding::new("escape", SwitchMode(Mode::normal()), context),
|
||||
]);
|
||||
|
||||
cx.add_action(move_to_start);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue