vim: Fix escape key switching back to default mode instead of normal mode (#31843)
Closes #31728 This PR introduced new setting `"helix_mode"`. Enabling which will enable the `vim_mode` along with `helix` behavior. This solves issue where `vim`'s `default_mode` was being used to switch between mode instead of opening in `default_mode`. When `helix_mode` is enabled switcing to `Normal mode` will now switch to `HelixNormal` Release Notes: - Fixed - escape key not switching to normal mode when default_mode is insert - Added - `helix_mode` setting to enable/disable helix key bindings --------- Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
parent
d2ca68bd5d
commit
ab189b898d
8 changed files with 72 additions and 14 deletions
|
@ -1,7 +1,7 @@
|
|||
//! Contains the [`VimModeSetting`] used to enable/disable Vim mode.
|
||||
//! Contains the [`VimModeSetting`] and [`HelixModeSetting`] used to enable/disable Vim and Helix modes.
|
||||
//!
|
||||
//! This is in its own crate as we want other crates to be able to enable or
|
||||
//! disable Vim mode without having to depend on the `vim` crate in its
|
||||
//! disable Vim/Helix modes without having to depend on the `vim` crate in its
|
||||
//! entirety.
|
||||
|
||||
use anyhow::Result;
|
||||
|
@ -11,6 +11,7 @@ use settings::{Settings, SettingsSources};
|
|||
/// Initializes the `vim_mode_setting` crate.
|
||||
pub fn init(cx: &mut App) {
|
||||
VimModeSetting::register(cx);
|
||||
HelixModeSetting::register(cx);
|
||||
}
|
||||
|
||||
/// Whether or not to enable Vim mode.
|
||||
|
@ -38,3 +39,29 @@ impl Settings for VimModeSetting {
|
|||
// TODO: could possibly check if any of the `vim.<foo>` keys are set?
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether or not to enable Helix mode.
|
||||
///
|
||||
/// Default: false
|
||||
pub struct HelixModeSetting(pub bool);
|
||||
|
||||
impl Settings for HelixModeSetting {
|
||||
const KEY: Option<&'static str> = Some("helix_mode");
|
||||
|
||||
type FileContent = Option<bool>;
|
||||
|
||||
fn load(sources: SettingsSources<Self::FileContent>, _: &mut App) -> Result<Self> {
|
||||
Ok(Self(
|
||||
sources
|
||||
.user
|
||||
.or(sources.server)
|
||||
.copied()
|
||||
.flatten()
|
||||
.unwrap_or(sources.default.ok_or_else(Self::missing_default)?),
|
||||
))
|
||||
}
|
||||
|
||||
fn import_from_vscode(_vscode: &settings::VsCodeSettings, _current: &mut Self::FileContent) {
|
||||
// TODO: could possibly check if any of the `helix.<foo>` keys are set?
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue