[feature] Add `jumpto-diffs` and `copy-diffs` mappings?
I'd like to improve the experience of using diffview to craft a change/commit.
When in the DiffviewOpen Diffview could we navigate around the selected file without having to move focus to it. It would be nice if [c and ]c worked from the file panel, on the local version. I know all this is doing is saving a few keystrokes around moving focus but it would be nice if it was builtin. Along with that a default keybindings for diffget to revert a change would be nice, I'd suggest X but it is already used so maybe x instead?
And when a hunk is reverted jump to the next hunk? Maybe a binding to stage the focused hunk? I think it's a nicer workflow than using gitsigns or lazygit to quickly craft/filter changes into staging.
It would be nice if
[cand]cworked from the file panel [...] Along with that a default keybindings fordiffget
You can set this up in your own config using :h diffview-actions-view_windo:
local actions = require("diffview.actions")
require("diffview").setup({
keymaps = {
file_panel = {
{
"n", "[c",
actions.view_windo(function(layout_name, sym)
if sym == "b" then
vim.cmd("norm! [c")
end
end)
},
{
"n", "]c",
actions.view_windo(function(layout_name, sym)
if sym == "b" then
vim.cmd("norm! ]c")
end
end)
},
{
"n", "x",
actions.view_windo(function(layout_name, sym)
if sym == "b" then
vim.cmd("diffget")
end
end)
},
}
},
})
But I suppose those would be good default mappings.
This works very nicely and I would definitely welcome it as a default. What would be even better is if it could cross file boundaries as well, as in, jump to next diff in next file if on last diff of a file already. And [C & ]C to jump to first/last diff of current file as well maybe?
Yes, crossing file boundaries would be awesome and [C/]C makes sense too.