1//! Contains the [`VimModeSetting`] and [`HelixModeSetting`] used to enable/disable Vim and Helix modes.
2//!
3//! This is in its own crate as we want other crates to be able to enable or
4//! disable Vim/Helix modes without having to depend on the `vim` crate in its
5//! entirety.
6
7use gpui::App;
8use settings::{RegisterSetting, Settings, SettingsContent};
9
10#[derive(RegisterSetting)]
11pub struct VimModeSetting(pub bool);
12
13impl Settings for VimModeSetting {
14 fn from_settings(content: &SettingsContent) -> Self {
15 Self(content.vim_mode.unwrap())
16 }
17}
18
19impl VimModeSetting {
20 pub fn is_enabled(cx: &App) -> bool {
21 Self::try_get(cx)
22 .map(|vim_mode| vim_mode.0)
23 .unwrap_or(false)
24 }
25}
26
27#[derive(RegisterSetting)]
28pub struct HelixModeSetting(pub bool);
29
30impl HelixModeSetting {
31 pub fn is_enabled(cx: &App) -> bool {
32 Self::try_get(cx)
33 .map(|helix_mode| helix_mode.0)
34 .unwrap_or(false)
35 }
36}
37
38impl Settings for HelixModeSetting {
39 fn from_settings(content: &SettingsContent) -> Self {
40 Self(content.helix_mode.unwrap())
41 }
42}