From 82b7c96edfaf84fd28c04e0dd3a8a12fdfaba44d Mon Sep 17 00:00:00 2001 From: Christoph Schmatzler Date: Tue, 10 Mar 2026 12:32:29 +0000 Subject: [PATCH] Add jj.nvim, diffview.nvim, and code-review.nvim with v (+VCS) and r (+Review) keybinding groups --- modules/_neovim/default.nix | 3 + modules/_neovim/mappings.nix | 159 +++++++++++++++++++++++- modules/_neovim/plugins/code-review.nix | 37 ++++++ modules/_neovim/plugins/diffview.nix | 26 ++++ modules/_neovim/plugins/jj-nvim.nix | 42 +++++++ modules/_neovim/plugins/mini.nix | 12 +- 6 files changed, 268 insertions(+), 11 deletions(-) create mode 100644 modules/_neovim/plugins/code-review.nix create mode 100644 modules/_neovim/plugins/diffview.nix create mode 100644 modules/_neovim/plugins/jj-nvim.nix diff --git a/modules/_neovim/default.nix b/modules/_neovim/default.nix index b11f23a..ae96e17 100644 --- a/modules/_neovim/default.nix +++ b/modules/_neovim/default.nix @@ -9,6 +9,9 @@ ./plugins/harpoon.nix ./plugins/hunk.nix ./plugins/jj-diffconflicts.nix + ./plugins/jj-nvim.nix + ./plugins/code-review.nix + ./plugins/diffview.nix ./plugins/lsp.nix ./plugins/mini.nix ./plugins/oil.nix diff --git a/modules/_neovim/mappings.nix b/modules/_neovim/mappings.nix index a07df9a..3a8a75b 100644 --- a/modules/_neovim/mappings.nix +++ b/modules/_neovim/mappings.nix @@ -117,23 +117,170 @@ action = ":Pick visit_paths"; options.desc = "Visit paths (cwd)"; } - # g - git + # v - vcs { mode = "n"; - key = "gc"; + key = "va"; + action = ":J annotate"; + options.desc = "Annotate (blame)"; + } + { + mode = "n"; + key = "vc"; action = ":JJDiffConflicts"; options.desc = "Resolve conflicts"; } { mode = "n"; - key = "gg"; + key = "vd"; action.__raw = '' - function() - require('toggleterm.terminal').Terminal:new({ cmd = 'jjui', direction = 'float' }):toggle() - end + function() + require('jj.cmd').diff() + end + ''; + options.desc = "Diff (current file)"; + } + { + mode = "n"; + key = "vD"; + action = ":DiffviewOpen"; + options.desc = "Diffview (all changes)"; + } + { + mode = "n"; + key = "ve"; + action.__raw = '' + function() + require('jj.cmd').describe() + end + ''; + options.desc = "Describe (edit message)"; + } + { + mode = "n"; + key = "vf"; + action = ":J fetch"; + options.desc = "Fetch"; + } + { + mode = "n"; + key = "vv"; + action.__raw = '' + function() + require('toggleterm.terminal').Terminal:new({ cmd = 'jjui', direction = 'float' }):toggle() + end ''; options.desc = "jjui"; } + { + mode = "n"; + key = "vh"; + action = ":DiffviewFileHistory %"; + options.desc = "File history"; + } + { + mode = "n"; + key = "vH"; + action = ":DiffviewFileHistory"; + options.desc = "Branch history"; + } + { + mode = "n"; + key = "vl"; + action.__raw = '' + function() + require('jj.cmd').log() + end + ''; + options.desc = "Log"; + } + { + mode = "n"; + key = "vn"; + action.__raw = '' + function() + require('jj.cmd').new() + end + ''; + options.desc = "New change"; + } + { + mode = "n"; + key = "vp"; + action = ":J git push"; + options.desc = "Push"; + } + { + mode = "n"; + key = "vq"; + action = ":DiffviewClose"; + options.desc = "Close diffview"; + } + { + mode = "n"; + key = "vs"; + action.__raw = '' + function() + require('jj.cmd').status() + end + ''; + options.desc = "Status"; + } + # r - review + { + mode = ["n" "v"]; + key = "rc"; + action = ":CodeReviewComment"; + options.desc = "Add comment"; + } + { + mode = "n"; + key = "rd"; + action = ":CodeReviewDeleteComment"; + options.desc = "Delete comment"; + } + { + mode = "n"; + key = "rl"; + action = ":CodeReviewList"; + options.desc = "List comments"; + } + { + mode = "n"; + key = "ro"; + action = ":CodeReviewResolve"; + options.desc = "Resolve thread"; + } + { + mode = "n"; + key = "rp"; + action = ":CodeReviewPreview"; + options.desc = "Preview review"; + } + { + mode = "n"; + key = "rr"; + action = ":CodeReviewReply"; + options.desc = "Reply to comment"; + } + { + mode = "n"; + key = "rs"; + action = ":CodeReviewShowComment"; + options.desc = "Show comment"; + } + { + mode = "n"; + key = "rx"; + action = ":CodeReviewClear"; + options.desc = "Clear all comments"; + } + { + mode = "n"; + key = "ry"; + action = ":CodeReviewCopy"; + options.desc = "Copy review to clipboard"; + } # l - lsp/formatter { mode = "n"; diff --git a/modules/_neovim/plugins/code-review.nix b/modules/_neovim/plugins/code-review.nix new file mode 100644 index 0000000..6473b6c --- /dev/null +++ b/modules/_neovim/plugins/code-review.nix @@ -0,0 +1,37 @@ +{pkgs, ...}: let + code-review-nvim = + pkgs.vimUtils.buildVimPlugin { + pname = "code-review-nvim"; + version = "unstable-2026-03-10"; + src = + pkgs.fetchFromGitHub { + owner = "choplin"; + repo = "code-review.nvim"; + rev = "ed91462e20bd08c3be71efb11a4a7d00459f0b47"; + hash = "sha256-WpbQswkUpB4Nblos8+5UE5I/PHUQOi+RQ+hj4CCdL4o="; + }; + doCheck = false; + }; +in { + programs.nixvim = { + extraPlugins = [ + code-review-nvim + ]; + extraConfigLua = '' + require('code-review').setup({ + comment = { + storage = { + backend = "file", + file = { + dir = ".code-review", + }, + }, + }, + output = { + format = "minimal", + }, + keymaps = false, + }) + ''; + }; +} diff --git a/modules/_neovim/plugins/diffview.nix b/modules/_neovim/plugins/diffview.nix new file mode 100644 index 0000000..9bcaf41 --- /dev/null +++ b/modules/_neovim/plugins/diffview.nix @@ -0,0 +1,26 @@ +{pkgs, ...}: { + programs.nixvim = { + extraPlugins = with pkgs.vimPlugins; [ + diffview-nvim + ]; + extraConfigLua = '' + require('diffview').setup({ + enhanced_diff_hl = true, + view = { + default = { layout = "diff2_horizontal" }, + merge_tool = { layout = "diff3_mixed", disable_diagnostics = true }, + file_history = { layout = "diff2_horizontal" }, + }, + default_args = { + DiffviewOpen = { "--imply-local" }, + }, + hooks = { + diff_buf_read = function(bufnr) + vim.opt_local.wrap = false + vim.opt_local.list = false + end, + }, + }) + ''; + }; +} diff --git a/modules/_neovim/plugins/jj-nvim.nix b/modules/_neovim/plugins/jj-nvim.nix new file mode 100644 index 0000000..2ef69af --- /dev/null +++ b/modules/_neovim/plugins/jj-nvim.nix @@ -0,0 +1,42 @@ +{pkgs, ...}: let + jj-nvim = + pkgs.vimUtils.buildVimPlugin { + pname = "jj-nvim"; + version = "unstable-2026-03-10"; + src = + pkgs.fetchFromGitHub { + owner = "NicolasGB"; + repo = "jj.nvim"; + rev = "bbba4051c862473637e98277f284d12b050588ca"; + hash = "sha256-nokftWcAmmHX6UcH6O79xkLwbUpq1W8N9lf1e+NyGqE="; + }; + doCheck = false; + }; +in { + programs.nixvim = { + extraPlugins = [ + jj-nvim + ]; + extraConfigLua = '' + require('jj').setup({ + diff = { + backend = "diffview", + }, + cmd = { + describe = { + editor = { type = "buffer" }, + }, + log = { + close_on_edit = false, + }, + }, + -- Disable default keymaps — we set our own in mappings.nix + ui = { + log = { + keymaps = true, + }, + }, + }) + ''; + }; +} diff --git a/modules/_neovim/plugins/mini.nix b/modules/_neovim/plugins/mini.nix index 38d666f..cb65cf3 100644 --- a/modules/_neovim/plugins/mini.nix +++ b/modules/_neovim/plugins/mini.nix @@ -27,11 +27,13 @@ { { mode = 'n', keys = 'e', desc = '+Explore/+Edit' }, { mode = 'n', keys = 'f', desc = '+Find' }, - { mode = 'n', keys = 'g', desc = '+Git' }, - { mode = 'n', keys = 'l', desc = '+LSP' }, - { mode = 'x', keys = 'l', desc = '+LSP' }, - { mode = 'n', keys = 'o', desc = '+OpenCode' }, - { mode = 'x', keys = 'o', desc = '+OpenCode' }, + { mode = 'n', keys = 'v', desc = '+VCS' }, + { mode = 'n', keys = 'l', desc = '+LSP' }, + { mode = 'x', keys = 'l', desc = '+LSP' }, + { mode = 'n', keys = 'o', desc = '+OpenCode' }, + { mode = 'x', keys = 'o', desc = '+OpenCode' }, + { mode = 'n', keys = 'r', desc = '+Review' }, + { mode = 'v', keys = 'r', desc = '+Review' }, require("mini.clue").gen_clues.builtin_completion(), require("mini.clue").gen_clues.g(), require("mini.clue").gen_clues.marks(),