Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Add "workspace: Toggle Vim Mode"
Conrad Irwinc7991ef04cc5
diff --git a/crates/vim/src/vim.rs b/crates/vim/src/vim.rsindex aad97c558e2..c34607d1c0c 100644--- a/crates/vim/src/vim.rs+++ b/crates/vim/src/vim.rs@@ -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.