Restructure action macro to assign a namespace to every action
Also, allow arbitrary types to be used as Actions via the impl_actions macro Co-authored-by: Nathan Sobo <nathan@zed.dev> Co-authored-by: Keith Simmons <keith@zed.dev>
This commit is contained in:
co-authored by
Nathan Sobo
Keith Simmons
parent
206b0f0f8c
commit
5242a3a6dc
@@ -1,11 +1,10 @@
|
||||
use crate::{mode::Mode, SwitchMode, VimState};
|
||||
use editor::Bias;
|
||||
use gpui::{action, keymap::Binding, MutableAppContext, ViewContext};
|
||||
use gpui::{actions, keymap::Binding, MutableAppContext, ViewContext};
|
||||
use language::SelectionGoal;
|
||||
use workspace::Workspace;
|
||||
|
||||
use crate::{mode::Mode, SwitchMode, VimState};
|
||||
|
||||
action!(NormalBefore);
|
||||
actions!(vim, [NormalBefore]);
|
||||
|
||||
pub fn init(cx: &mut MutableAppContext) {
|
||||
let context = Some("Editor && vim_mode == insert");
|
||||
|
||||
+32
-13
@@ -1,23 +1,42 @@
|
||||
mod g_prefix;
|
||||
|
||||
use crate::{mode::NormalState, Mode, SwitchMode, VimState};
|
||||
use editor::{char_kind, movement, Bias};
|
||||
use gpui::{action, keymap::Binding, MutableAppContext, ViewContext};
|
||||
use gpui::{actions, impl_actions, keymap::Binding, MutableAppContext, ViewContext};
|
||||
use language::SelectionGoal;
|
||||
use workspace::Workspace;
|
||||
|
||||
use crate::{mode::NormalState, Mode, SwitchMode, VimState};
|
||||
#[derive(Clone)]
|
||||
struct MoveToNextWordStart(pub bool);
|
||||
|
||||
action!(GPrefix);
|
||||
action!(MoveLeft);
|
||||
action!(MoveDown);
|
||||
action!(MoveUp);
|
||||
action!(MoveRight);
|
||||
action!(MoveToStartOfLine);
|
||||
action!(MoveToEndOfLine);
|
||||
action!(MoveToEnd);
|
||||
action!(MoveToNextWordStart, bool);
|
||||
action!(MoveToNextWordEnd, bool);
|
||||
action!(MoveToPreviousWordStart, bool);
|
||||
#[derive(Clone)]
|
||||
struct MoveToNextWordEnd(pub bool);
|
||||
|
||||
#[derive(Clone)]
|
||||
struct MoveToPreviousWordStart(pub bool);
|
||||
|
||||
impl_actions!(
|
||||
vim,
|
||||
[
|
||||
MoveToNextWordStart,
|
||||
MoveToNextWordEnd,
|
||||
MoveToPreviousWordStart,
|
||||
]
|
||||
);
|
||||
|
||||
actions!(
|
||||
vim,
|
||||
[
|
||||
GPrefix,
|
||||
MoveLeft,
|
||||
MoveDown,
|
||||
MoveUp,
|
||||
MoveRight,
|
||||
MoveToStartOfLine,
|
||||
MoveToEndOfLine,
|
||||
MoveToEnd,
|
||||
]
|
||||
);
|
||||
|
||||
pub fn init(cx: &mut MutableAppContext) {
|
||||
let context = Some("Editor && vim_mode == normal");
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
use gpui::{action, keymap::Binding, MutableAppContext, ViewContext};
|
||||
use crate::{mode::Mode, SwitchMode, VimState};
|
||||
use gpui::{actions, keymap::Binding, MutableAppContext, ViewContext};
|
||||
use workspace::Workspace;
|
||||
|
||||
use crate::{mode::Mode, SwitchMode, VimState};
|
||||
|
||||
action!(MoveToStart);
|
||||
actions!(vim, [MoveToStart]);
|
||||
|
||||
pub fn init(cx: &mut MutableAppContext) {
|
||||
let context = Some("Editor && vim_mode == normal && vim_submode == g");
|
||||
|
||||
@@ -7,13 +7,16 @@ mod vim_test_context;
|
||||
|
||||
use collections::HashMap;
|
||||
use editor::{CursorShape, Editor};
|
||||
use gpui::{action, MutableAppContext, ViewContext, WeakViewHandle};
|
||||
use gpui::{impl_actions, MutableAppContext, ViewContext, WeakViewHandle};
|
||||
|
||||
use mode::Mode;
|
||||
use settings::Settings;
|
||||
use workspace::{self, Workspace};
|
||||
|
||||
action!(SwitchMode, Mode);
|
||||
#[derive(Clone)]
|
||||
pub struct SwitchMode(pub Mode);
|
||||
|
||||
impl_actions!(vim, [SwitchMode]);
|
||||
|
||||
pub fn init(cx: &mut MutableAppContext) {
|
||||
editor_events::init(cx);
|
||||
|
||||
Reference in New Issue
Block a user