git: First stab at adding Linux and Vim keybindings (#23738)

Cole Miller created

Release Notes:

- N/A

Change summary

Cargo.lock                              |  1 
assets/keymaps/default-linux.json       | 29 ++++++++++++++++++++++++++
assets/keymaps/vim.json                 | 15 +++++++++++++
crates/vim/Cargo.toml                   |  1 
crates/vim/src/test/vim_test_context.rs |  1 
5 files changed, 47 insertions(+)

Detailed changes

Cargo.lock 🔗

@@ -14417,6 +14417,7 @@ dependencies = [
  "command_palette_hooks",
  "editor",
  "futures 0.3.31",
+ "git_ui",
  "gpui",
  "indoc",
  "itertools 0.14.0",

assets/keymaps/default-linux.json 🔗

@@ -426,6 +426,7 @@
       "ctrl-shift-m": "diagnostics::Deploy",
       "ctrl-shift-e": "project_panel::ToggleFocus",
       "ctrl-shift-b": "outline_panel::ToggleFocus",
+      "ctrl-shift-g": "git_panel::ToggleFocus",
       "ctrl-?": "assistant::ToggleFocus",
       "alt-save": "workspace::SaveAll",
       "ctrl-alt-s": "workspace::SaveAll",
@@ -692,6 +693,34 @@
       "space": "project_panel::Open"
     }
   },
+  {
+    "context": "GitPanel && !CommitEditor",
+    "use_key_equivalents": true,
+    "bindings": {
+      "escape": "git_panel::Close"
+    }
+  },
+  {
+    "context": "GitPanel && ChangesList",
+    "use_key_equivalents": true,
+    "bindings": {
+      "up": "menu::SelectPrev",
+      "down": "menu::SelectNext",
+      "enter": "menu::Confirm",
+      "space": "git::ToggleStaged",
+      "ctrl-space": "git::StageAll",
+      "ctrl-shift-space": "git::UnstageAll"
+    }
+  },
+  {
+    "context": "GitPanel && CommitEditor > Editor",
+    "use_key_equivalents": true,
+    "bindings": {
+      "escape": "git_panel::FocusChanges",
+      "ctrl-enter": "git::CommitChanges",
+      "ctrl-shift-enter": "git::CommitAllChanges"
+    }
+  },
   {
     "context": "CollabPanel && not_editing",
     "bindings": {

assets/keymaps/vim.json 🔗

@@ -668,5 +668,20 @@
       "shift-g": "menu::SelectLast",
       "g g": "menu::SelectFirst"
     }
+  },
+  {
+    "context": "GitPanel && ChangesList",
+    "use_key_equivalents": true,
+    "bindings": {
+      "k": "menu::SelectPrev",
+      "j": "menu::SelectNext",
+      "g g": "menu::SelectFirst",
+      "shift-g": "menu::SelectLast",
+      "g f": "menu::Confirm",
+      "i": "git_panel::FocusEditor",
+      "x": "git::ToggleStaged",
+      "shift-x": "git::StageAll",
+      "shift-u": "git::UnstageAll"
+    }
   }
 ]

crates/vim/Cargo.toml 🔗

@@ -51,6 +51,7 @@ zed_actions.workspace = true
 assets.workspace = true
 command_palette.workspace = true
 editor = { workspace = true, features = ["test-support"] }
+git_ui.workspace = true
 gpui = { workspace = true, features = ["test-support"] }
 indoc.workspace = true
 language = { workspace = true, features = ["test-support"] }

crates/vim/src/test/vim_test_context.rs 🔗

@@ -22,6 +22,7 @@ impl VimTestContext {
             release_channel::init(SemanticVersion::default(), cx);
             command_palette::init(cx);
             project_panel::init(Assets, cx);
+            git_ui::init(cx);
             crate::init(cx);
             search::init(cx);
         });