Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
vim: Add setting to control whether edit predictions are shown in normal mode (#55956)
Ben Kunkle59daeba295f2
diff --git a/assets/settings/default.json b/assets/settings/default.jsonindex 64f97c451b0..d6d6feac644 100644--- a/assets/settings/default.json+++ b/assets/settings/default.json@@ -2515,6 +2515,9 @@"gdefault": false,"highlight_on_yank_duration": 200,"custom_digraphs": {},+ // When enabled, edit predictions are shown in Vim normal mode.+ // By default, edit predictions are only shown in insert and replace modes.+ "show_edit_predictions_in_normal_mode": false,// Cursor shape for each mode.// The shape can be one of the following: "block", "bar", "underline", "hollow"."cursor_shape": {diff --git a/crates/settings_content/src/settings_content.rs b/crates/settings_content/src/settings_content.rsindex 1124e2ac942..0bf14e2f4ff 100644--- a/crates/settings_content/src/settings_content.rs+++ b/crates/settings_content/src/settings_content.rs@@ -864,6 +864,9 @@ pub struct VimSettingsContent {pub custom_digraphs: Option<HashMap<String, Arc<str>>>,pub highlight_on_yank_duration: Option<u64>,pub cursor_shape: Option<CursorShapeSettings>,+ /// When enabled, edit predictions are shown in Vim normal mode.+ /// By default, edit predictions are only shown in insert and replace modes.+ pub show_edit_predictions_in_normal_mode: Option<bool>,}#[derive(diff --git a/crates/settings_ui/src/page_data.rs b/crates/settings_ui/src/page_data.rsindex ce0c53b3822..acb9f53a675 100644--- a/crates/settings_ui/src/page_data.rs+++ b/crates/settings_ui/src/page_data.rs@@ -2573,7 +2573,7 @@ fn editor_page() -> SettingsPage {]}- fn vim_settings_section() -> [SettingsPageItem; 13] {+ fn vim_settings_section() -> [SettingsPageItem; 14] {[SettingsPageItem::SectionHeader("Vim"),SettingsPageItem::SettingItem(SettingItem {@@ -2700,6 +2700,28 @@ fn editor_page() -> SettingsPage {metadata: None,files: USER,}),+ SettingsPageItem::SettingItem(SettingItem {+ title: "Show Edit Predictions in Normal Mode",+ description: "Whether edit predictions are shown in normal mode. By default, edit predictions are only shown in insert and replace modes.",+ field: Box::new(SettingField {+ json_path: Some("vim.show_edit_predictions_in_normal_mode"),+ pick: |settings_content| {+ settings_content+ .vim+ .as_ref()?+ .show_edit_predictions_in_normal_mode+ .as_ref()+ },+ write: |settings_content, value, _| {+ settings_content+ .vim+ .get_or_insert_default()+ .show_edit_predictions_in_normal_mode = value;+ },+ }),+ metadata: None,+ files: USER,+ }),SettingsPageItem::SettingItem(SettingItem {title: "Cursor Shape - Normal Mode",description: "Cursor shape for normal mode.",diff --git a/crates/vim/src/state.rs b/crates/vim/src/state.rsindex 0851604e1ab..85bf84d8878 100644--- a/crates/vim/src/state.rs+++ b/crates/vim/src/state.rs@@ -79,6 +79,10 @@ impl Mode {pub fn is_helix(&self) -> bool {matches!(self, Self::HelixNormal | Self::HelixSelect)}++ pub fn is_normal(&self) -> bool {+ matches!(self, Self::Normal | Self::HelixNormal)+ }}#[derive(Clone, Debug, PartialEq)]diff --git a/crates/vim/src/vim.rs b/crates/vim/src/vim.rsindex 6c0c3d0201b..d247e240310 100644--- a/crates/vim/src/vim.rs+++ b/crates/vim/src/vim.rs@@ -2209,7 +2209,9 @@ impl Vim {autoindent: self.should_autoindent(),cursor_offset_on_selection: self.mode.is_visual() || self.mode.is_helix(),line_mode: matches!(self.mode, Mode::VisualLine),- hide_edit_predictions: !matches!(self.mode, Mode::Insert | Mode::Replace),+ hide_edit_predictions: !matches!(self.mode, Mode::Insert | Mode::Replace)+ && !(self.mode.is_normal()+ && VimSettings::get_global(cx).show_edit_predictions_in_normal_mode),}}@@ -2259,6 +2261,7 @@ struct VimSettings {pub custom_digraphs: HashMap<String, Arc<str>>,pub highlight_on_yank_duration: u64,pub cursor_shape: CursorShapeSettings,+ pub show_edit_predictions_in_normal_mode: bool,}/// Cursor shape configuration for insert mode.@@ -2346,6 +2349,7 @@ impl Settings for VimSettings {custom_digraphs: vim.custom_digraphs.unwrap(),highlight_on_yank_duration: vim.highlight_on_yank_duration.unwrap(),cursor_shape: vim.cursor_shape.unwrap().into(),+ show_edit_predictions_in_normal_mode: vim.show_edit_predictions_in_normal_mode.unwrap(),}}}