diff --git a/Cargo.lock b/Cargo.lock index c57548057d9d3618d194ee02f9ae57bf63958394..3c7affc76fc1156f7cf00c8364834af42f5948e8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9665,6 +9665,7 @@ dependencies = [ "theme", "theme_selector", "util", + "vim", "workspace", ] diff --git a/crates/vim/src/vim.rs b/crates/vim/src/vim.rs index d27be2c54b80da39cf44e2beff67d606d1bd92bd..aad97c558e2d22e37d349e380b8970720890d642 100644 --- a/crates/vim/src/vim.rs +++ b/crates/vim/src/vim.rs @@ -33,7 +33,7 @@ use workspace::{self, Workspace}; use crate::state::ReplayableAction; -struct VimModeSetting(bool); +pub struct VimModeSetting(pub bool); #[derive(Clone, Deserialize, PartialEq)] pub struct SwitchMode(pub Mode); diff --git a/crates/welcome/Cargo.toml b/crates/welcome/Cargo.toml index ea01f822a7b4e1ace0ce25dca5d6df3935d5a857..c7ad62f15552bd6f6dfff1e3389eef4119234fc0 100644 --- a/crates/welcome/Cargo.toml +++ b/crates/welcome/Cargo.toml @@ -25,6 +25,7 @@ theme_selector = { path = "../theme_selector" } util = { path = "../util" } picker = { path = "../picker" } workspace = { path = "../workspace" } +vim = { path = "../vim" } anyhow.workspace = true log.workspace = true diff --git a/crates/welcome/src/welcome.rs b/crates/welcome/src/welcome.rs index 4d8df53a1b2d15380e0d4f3a823f00dd7672f6ce..a5d95429bdf00b97718d353b7a5f4916dff28f31 100644 --- a/crates/welcome/src/welcome.rs +++ b/crates/welcome/src/welcome.rs @@ -10,6 +10,7 @@ use gpui::{ }; use settings::{update_settings_file, SettingsStore}; use std::{borrow::Cow, sync::Arc}; +use vim::VimModeSetting; use workspace::{ dock::DockPosition, item::Item, open_new, AppState, PaneBackdrop, Welcome, Workspace, WorkspaceId, @@ -65,6 +66,7 @@ impl View for WelcomePage { let width = theme.welcome.page_width; let telemetry_settings = *settings::get::(cx); + let vim_mode_setting = settings::get::(cx).0; enum Metrics {} enum Diagnostics {} @@ -144,6 +146,27 @@ impl View for WelcomePage { ) .with_child( Flex::column() + .with_child( + theme::ui::checkbox::( + "Enable vim mode", + &theme.welcome.checkbox, + vim_mode_setting, + 0, + cx, + |this, checked, cx| { + if let Some(workspace) = this.workspace.upgrade(cx) { + let fs = workspace.read(cx).app_state().fs.clone(); + update_settings_file::( + fs, + cx, + move |setting| *setting = Some(checked), + ) + } + }, + ) + .contained() + .with_style(theme.welcome.checkbox_container), + ) .with_child( theme::ui::checkbox_with_label::( Flex::column() @@ -186,7 +209,7 @@ impl View for WelcomePage { "Send crash reports", &theme.welcome.checkbox, telemetry_settings.diagnostics, - 0, + 1, cx, |this, checked, cx| { if let Some(workspace) = this.workspace.upgrade(cx) {