mirror of
https://github.com/zoriya/jj.nvim.git
synced 2026-08-15 23:53:18 +00:00
feat(picker): add <C-d> keybinding to open file and run Jdiff (#110)
In the status picker, pressing Ctrl-d opens the selected file in the current window and immediately runs :Jdiff, so the diff view follows without a second step.
This commit is contained in:
@@ -28,6 +28,24 @@ function M.status(opts, files)
|
||||
source = "jj",
|
||||
items = files,
|
||||
title = "JJ Status",
|
||||
actions = {
|
||||
open_and_diff = function(picker, item)
|
||||
picker:close()
|
||||
if item and item.file then
|
||||
vim.schedule(function()
|
||||
vim.cmd("edit " .. vim.fn.fnameescape(item.file))
|
||||
vim.cmd("Jdiff")
|
||||
end)
|
||||
end
|
||||
end,
|
||||
},
|
||||
win = {
|
||||
input = {
|
||||
keys = {
|
||||
["<C-d>"] = { "open_and_diff", mode = { "i", "n" } },
|
||||
},
|
||||
},
|
||||
},
|
||||
preview = function(ctx)
|
||||
if ctx.item.file then
|
||||
snacks.picker.preview.cmd(ctx.item.diff_cmd, ctx, {})
|
||||
|
||||
Reference in New Issue
Block a user