From 5a0b75657012a4367dc23e2b80405d8306e74e0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Steinbrink?= Date: Fri, 15 May 2026 15:14:24 +0200 Subject: [PATCH] feat(picker): add 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. --- README.md | 7 +++++++ lua/jj/picker/snacks.lua | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/README.md b/README.md index ebc2024..2b8ac31 100644 --- a/README.md +++ b/README.md @@ -328,6 +328,13 @@ Press `` on a file from the `status` output and that's it, it's restored. ![Restore-status](https://github.com/NicolasGB/jj.nvim/raw/main/assets/x-status.gif) +### Status picker (Snacks.nvim) + +When using the [Snacks.nvim](https://github.com/folke/snacks.nvim) picker integration, `picker.status()` opens a fuzzy-findable list of changed files with a live diff preview. Available keybindings: + +- `` - Open the selected file +- `` - Open the selected file and run `Jdiff` + ## Installation Using [lazy.nvim](https://github.com/folke/lazy.nvim): diff --git a/lua/jj/picker/snacks.lua b/lua/jj/picker/snacks.lua index 3dc80cf..3390773 100644 --- a/lua/jj/picker/snacks.lua +++ b/lua/jj/picker/snacks.lua @@ -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 = { + [""] = { "open_and_diff", mode = { "i", "n" } }, + }, + }, + }, preview = function(ctx) if ctx.item.file then snacks.picker.preview.cmd(ctx.item.diff_cmd, ctx, {})