From 6af5fdd1c27e887732e7857ba855432a57d20ced Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Thu, 5 Sep 2024 20:35:04 -0600 Subject: [PATCH] vim: Add more diff stuff (#17456) Release Notes: - vim: Added `:diff` and `:revert` (that work with `'<,'>`) to open the selected diff and revert it. - vim: Added `d o` to open the diff and `d p` to revert (spiritually similar to vim's do/dp, though obviously not the same) - vim: Added `ctrl-p` and `ctrl-n` to summon the autocomplete menu in insert mode. --- assets/keymaps/vim.json | 6 +++++- crates/vim/src/command.rs | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/assets/keymaps/vim.json b/assets/keymaps/vim.json index ed5d99782f..c9ab74e282 100644 --- a/assets/keymaps/vim.json +++ b/assets/keymaps/vim.json @@ -323,6 +323,8 @@ "ctrl-t": "vim::Indent", "ctrl-d": "vim::Outdent", "ctrl-k": ["vim::PushOperator", { "Digraph": {} }], + "ctrl-p": "editor::ShowCompletions", + "ctrl-n": "editor::ShowCompletions", "ctrl-r": ["vim::PushOperator", "Register"] } }, @@ -394,7 +396,9 @@ "context": "vim_operator == d", "bindings": { "d": "vim::CurrentLine", - "s": ["vim::PushOperator", "DeleteSurrounds"] + "s": ["vim::PushOperator", "DeleteSurrounds"], + "o": "editor::ToggleHunkDiff", // "d o" + "p": "editor::RevertSelectedHunks" // "d p" } }, { diff --git a/crates/vim/src/command.rs b/crates/vim/src/command.rs index 1887758990..d004513c48 100644 --- a/crates/vim/src/command.rs +++ b/crates/vim/src/command.rs @@ -586,6 +586,8 @@ fn generate_commands(_: &AppContext) -> Vec { VimCommand::new(("lp", "revious"), editor::actions::GoToPrevDiagnostic).count(), VimCommand::new(("lN", "ext"), editor::actions::GoToPrevDiagnostic).count(), VimCommand::new(("j", "oin"), JoinLines).range(), + VimCommand::new(("dif", "fupdate"), editor::actions::ToggleHunkDiff).range(), + VimCommand::new(("rev", "ert"), editor::actions::RevertSelectedHunks).range(), VimCommand::new(("d", "elete"), VisualDeleteLine).range(), VimCommand::new(("y", "ank"), VisualYankLine).range(), VimCommand::new(("sor", "t"), SortLinesCaseSensitive).range(),