mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-07 09:17:27 +00:00
Add "workspace: Toggle Vim Mode" (#3147)
Co-Authored-By: Marshall <elliott.codes@gmail.com> Release Notes: - vim: Add "Toggle Vim Mode" command
This commit is contained in:
commit
f422a3c5d0
1 changed files with 10 additions and 1 deletions
|
@ -25,7 +25,7 @@ pub use mode_indicator::ModeIndicator;
|
|||
use motion::Motion;
|
||||
use normal::normal_replace;
|
||||
use serde::Deserialize;
|
||||
use settings::{Setting, SettingsStore};
|
||||
use settings::{update_settings_file, Setting, SettingsStore};
|
||||
use state::{EditorState, Mode, Operator, RecordedSelection, WorkspaceState};
|
||||
use std::{ops::Range, sync::Arc};
|
||||
use visual::{visual_block_motion, visual_replace};
|
||||
|
@ -48,6 +48,7 @@ actions!(
|
|||
vim,
|
||||
[Tab, Enter, Object, InnerObject, FindForward, FindBackward]
|
||||
);
|
||||
actions!(workspace, [ToggleVimMode]);
|
||||
impl_actions!(vim, [Number, SwitchMode, PushOperator]);
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
|
@ -88,6 +89,14 @@ pub fn init(cx: &mut AppContext) {
|
|||
Vim::active_editor_input_ignored("\n".into(), cx)
|
||||
});
|
||||
|
||||
cx.add_action(|workspace: &mut Workspace, _: &ToggleVimMode, cx| {
|
||||
let fs = workspace.app_state().fs.clone();
|
||||
let currently_enabled = settings::get::<VimModeSetting>(cx).0;
|
||||
update_settings_file::<VimModeSetting>(fs, cx, move |setting| {
|
||||
*setting = Some(!currently_enabled)
|
||||
})
|
||||
});
|
||||
|
||||
// Any time settings change, update vim mode to match. The Vim struct
|
||||
// will be initialized as disabled by default, so we filter its commands
|
||||
// out when starting up.
|
||||
|
|
Loading…
Reference in a new issue