Allow actions to be deserialized from JSON
Introduce separate macro for implementing 'internal' actions which are not intended to be loaded from keymaps.
This commit is contained in:
parent
1778622960
commit
fd4b81c8fc
26 changed files with 559 additions and 335 deletions
|
@ -12,6 +12,7 @@ collections = { path = "../collections" }
|
|||
editor = { path = "../editor" }
|
||||
gpui = { path = "../gpui" }
|
||||
language = { path = "../language" }
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
settings = { path = "../settings" }
|
||||
workspace = { path = "../workspace" }
|
||||
log = "0.4"
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use editor::CursorShape;
|
||||
use gpui::keymap::Context;
|
||||
use serde::Deserialize;
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize)]
|
||||
pub enum Mode {
|
||||
Normal(NormalState),
|
||||
Insert,
|
||||
|
@ -44,7 +45,7 @@ impl Default for Mode {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize)]
|
||||
pub enum NormalState {
|
||||
None,
|
||||
GPrefix,
|
||||
|
|
|
@ -4,15 +4,16 @@ use crate::{mode::NormalState, Mode, SwitchMode, VimState};
|
|||
use editor::{char_kind, movement, Bias};
|
||||
use gpui::{actions, impl_actions, keymap::Binding, MutableAppContext, ViewContext};
|
||||
use language::SelectionGoal;
|
||||
use serde::Deserialize;
|
||||
use workspace::Workspace;
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Deserialize)]
|
||||
struct MoveToNextWordStart(pub bool);
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Deserialize)]
|
||||
struct MoveToNextWordEnd(pub bool);
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Deserialize)]
|
||||
struct MoveToPreviousWordStart(pub bool);
|
||||
|
||||
impl_actions!(
|
||||
|
|
|
@ -8,12 +8,13 @@ mod vim_test_context;
|
|||
use collections::HashMap;
|
||||
use editor::{CursorShape, Editor};
|
||||
use gpui::{impl_actions, MutableAppContext, ViewContext, WeakViewHandle};
|
||||
use serde::Deserialize;
|
||||
|
||||
use mode::Mode;
|
||||
use settings::Settings;
|
||||
use workspace::{self, Workspace};
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Deserialize)]
|
||||
pub struct SwitchMode(pub Mode);
|
||||
|
||||
impl_actions!(vim, [SwitchMode]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue