Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
settings_ui: Add vim motions on navigation menu (#39988)
Alvaro Parker941033e37330
diff --git a/Cargo.lock b/Cargo.lockindex f3f558c32ea..4d1ae4f58bc 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -18662,6 +18662,7 @@ dependencies = ["serde","serde_json","settings",+ "settings_ui","task","text","theme",diff --git a/assets/keymaps/vim.json b/assets/keymaps/vim.jsonindex da7491a0070..8382fd0653a 100644--- a/assets/keymaps/vim.json+++ b/assets/keymaps/vim.json@@ -432,7 +432,7 @@"shift-t": ["vim::PushFindBackward", { "after": true, "multiline": true }],"shift-f": ["vim::PushFindBackward", { "after": false, "multiline": true }],"alt-.": "vim::RepeatFind",-+// Changes"shift-r": "editor::Paste","`": "vim::ConvertToLowerCase",@@ -442,14 +442,14 @@"ctrl-r": "vim::Redo","y": "vim::HelixYank","p": "vim::HelixPaste",- "shift-p": ["vim::HelixPaste", { "before": true }],+ "shift-p": ["vim::HelixPaste", { "before": true }],">": "vim::Indent","<": "vim::Outdent","=": "vim::AutoIndent","d": "vim::HelixDelete","c": "vim::HelixSubstitute","alt-c": "vim::HelixSubstituteNoYank",-+// Selection manipulation"s": "vim::HelixSelectRegex","alt-s": ["editor::SplitSelectionIntoLines", { "keep_selections": true }],@@ -466,7 +466,7 @@"alt-i": "editor::SelectSmallerSyntaxNode","alt-p": "editor::SelectPreviousSyntaxNode","alt-n": "editor::SelectNextSyntaxNode",-+// Goto mode"g e": "vim::EndOfDocument","g h": "vim::StartOfLine",@@ -477,11 +477,11 @@"g b": "vim::WindowBottom","g r": "editor::FindAllReferences", // zed specific"g n": "pane::ActivateNextItem",- "shift-l": "pane::ActivateNextItem",+ "shift-l": "pane::ActivateNextItem","g p": "pane::ActivatePreviousItem","shift-h": "pane::ActivatePreviousItem","g .": "vim::HelixGotoLastModification", // go to last modification-+// Window mode"space w h": "workspace::ActivatePaneLeft","space w l": "workspace::ActivatePaneRight",@@ -512,7 +512,7 @@"]": ["vim::PushHelixNext", { "around": true }],"[": ["vim::PushHelixPrevious", { "around": true }],"g q": "vim::PushRewrap",- "g w": "vim::PushRewrap",+ "g w": "vim::PushRewrap"// "tab": "pane::ActivateNextItem",// "shift-tab": "pane::ActivatePrevItem",}@@ -1017,5 +1017,16 @@// and Windows."alt-l": "editor::AcceptEditPrediction"}+ },+ {+ "context": "SettingsWindow > NavigationMenu && !search",+ "bindings": {+ "l": "settings_editor::ExpandNavEntry",+ "h": "settings_editor::CollapseNavEntry",+ "k": "settings_editor::FocusPreviousNavEntry",+ "j": "settings_editor::FocusNextNavEntry",+ "g g": "settings_editor::FocusFirstNavEntry",+ "shift-g": "settings_editor::FocusLastNavEntry"+ }}]diff --git a/crates/settings_ui/src/settings_ui.rs b/crates/settings_ui/src/settings_ui.rsindex 103e2ed8047..3b47cb51081 100644--- a/crates/settings_ui/src/settings_ui.rs+++ b/crates/settings_ui/src/settings_ui.rs@@ -7,9 +7,9 @@ use feature_flags::FeatureFlag;use fuzzy::StringMatchCandidate;use gpui::{Action, App, DEFAULT_ADDITIONAL_WINDOW_SIZE, Div, Entity, FocusHandle, Focusable, Global,- ListState, ReadGlobal as _, ScrollHandle, Stateful, Subscription, Task, TitlebarOptions,- UniformListScrollHandle, Window, WindowBounds, WindowHandle, WindowOptions, actions, div, list,- point, prelude::*, px, uniform_list,+ KeyContext, ListState, ReadGlobal as _, ScrollHandle, Stateful, Subscription, Task,+ TitlebarOptions, UniformListScrollHandle, Window, WindowBounds, WindowHandle, WindowOptions,+ actions, div, list, point, prelude::*, px, uniform_list,};use heck::ToTitleCase as _;use project::{Project, WorktreeId};@@ -2078,8 +2078,15 @@ impl SettingsWindow {"Focus Navbar"};+ let mut key_context = KeyContext::new_with_defaults();+ key_context.add("NavigationMenu");+ key_context.add("menu");+ if self.search_bar.focus_handle(cx).is_focused(window) {+ key_context.add("search");+ }+v_flex()- .key_context("NavigationMenu")+ .key_context(key_context).on_action(cx.listener(|this, _: &CollapseNavEntry, window, cx| {let Some(focused_entry) = this.focused_nav_entry(window, cx) else {return;diff --git a/crates/vim/Cargo.toml b/crates/vim/Cargo.tomlindex 9d6381f8e6a..4cea29508f4 100644--- a/crates/vim/Cargo.toml+++ b/crates/vim/Cargo.toml@@ -67,6 +67,7 @@ lsp = { workspace = true, features = ["test-support"] }parking_lot.workspace = trueproject_panel.workspace = truerelease_channel.workspace = true+settings_ui.workspace = truesettings.workspace = trueperf.workspace = trueutil = { workspace = true, features = ["test-support"] }diff --git a/crates/vim/src/test/vim_test_context.rs b/crates/vim/src/test/vim_test_context.rsindex 8dfc0c392d9..0ea300e30cb 100644--- a/crates/vim/src/test/vim_test_context.rs+++ b/crates/vim/src/test/vim_test_context.rs@@ -30,6 +30,7 @@ impl VimTestContext {editor::init_settings(cx);project::Project::init_settings(cx);theme::init(theme::LoadThemes::JustBase, cx);+ settings_ui::init(cx);});}