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, {})