Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Add enable vim mode checkbox to welcome screen

Joseph T. Lyons4b2c24dd8c98
diff --git a/Cargo.lock b/Cargo.lock
index c57548057d9..3c7affc76fc 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 d27be2c54b8..aad97c558e2 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 ea01f822a7b..c7ad62f1555 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 4d8df53a1b2..a5d95429bdf 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::<TelemetrySettings>(cx);
+ let vim_mode_setting = settings::get::<VimModeSetting>(cx).0;
enum Metrics {}
enum Diagnostics {}
@@ -144,6 +146,27 @@ impl View for WelcomePage {
)
.with_child(
Flex::column()
+ .with_child(
+ theme::ui::checkbox::<Diagnostics, Self, _>(
+ "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::<VimModeSetting>(
+ fs,
+ cx,
+ move |setting| *setting = Some(checked),
+ )
+ }
+ },
+ )
+ .contained()
+ .with_style(theme.welcome.checkbox_container),
+ )
.with_child(
theme::ui::checkbox_with_label::<Metrics, _, Self, _>(
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) {