Add initial vim mode mode switching
Co-authored-by: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
parent
ccc276da7a
commit
bb9b36dccd
16 changed files with 683 additions and 49 deletions
36
crates/vim/src/mode.rs
Normal file
36
crates/vim/src/mode.rs
Normal file
|
@ -0,0 +1,36 @@
|
|||
use editor::CursorShape;
|
||||
use gpui::keymap::Context;
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum Mode {
|
||||
Normal,
|
||||
Insert,
|
||||
}
|
||||
|
||||
impl Mode {
|
||||
pub fn cursor_shape(&self) -> CursorShape {
|
||||
match self {
|
||||
Mode::Normal => CursorShape::Block,
|
||||
Mode::Insert => CursorShape::Bar,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn keymap_context_layer(&self) -> Context {
|
||||
let mut context = Context::default();
|
||||
context.map.insert(
|
||||
"vim_mode".to_string(),
|
||||
match self {
|
||||
Self::Normal => "normal",
|
||||
Self::Insert => "insert",
|
||||
}
|
||||
.to_string(),
|
||||
);
|
||||
context
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Mode {
|
||||
fn default() -> Self {
|
||||
Self::Normal
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue