diff --git a/neovim/README.md b/neovim/README.md index 57f4af4..aa6f6e4 100644 --- a/neovim/README.md +++ b/neovim/README.md @@ -37,6 +37,12 @@ machine gets the same set. > nvim-web-devicons needs a Nerd Font in the terminal or the icons render as > tofu. `brew.sh` installs one for ghostty. +> [!NOTE] +> codediff.nvim does its diffing in C. It downloads a prebuilt library into its +> own plugin directory on first use — so the first `:CodeDiff` on a new machine +> needs network, and the binary is not covered by the lock file. `:CodeDiff +> install!` forces a re-download if it ever goes missing or stale. + ## Defaults worth knowing - **The colorscheme is catppuccin**, `flavour = 'auto'`: latte on a light diff --git a/neovim/config/plugins/diffview.lua b/neovim/config/plugins/codediff.lua similarity index 53% rename from neovim/config/plugins/diffview.lua rename to neovim/config/plugins/codediff.lua index 0f7befd..80775fe 100644 --- a/neovim/config/plugins/diffview.lua +++ b/neovim/config/plugins/codediff.lua @@ -1,15 +1,20 @@ -vim.pack.add({ 'https://github.com/sindrets/diffview.nvim' }) +vim.pack.add({ 'https://github.com/esmuellert/codediff.nvim' }) -require('diffview').setup() +require('codediff').setup({ + keymaps = { + -- q closes the diff tab from inside it; gc is here too so the + -- same key that opened things from the g/diff group also shuts them. + view = { quit = { 'q', 'gc' } }, + }, +}) local function map(lhs, rhs, desc) vim.keymap.set('n', lhs, rhs, { desc = desc }) end -map('gd', 'DiffviewOpen', 'Diff against index') -map('gc', 'DiffviewClose', 'Close diff view') -map('gh', 'DiffviewFileHistory %', 'File history') -map('gH', 'DiffviewFileHistory', 'Branch history') +map('gd', 'CodeDiff', 'Diff working tree') +map('gh', 'CodeDiff history %', 'File history') +map('gH', 'CodeDiff history', 'Branch history') -- The base branch name varies per repo (main, master, develop, ...), so ask -- the first remote's HEAD what it is rather than hardcoding one. @@ -28,7 +33,9 @@ end map('gm', function() vim.ui.input({ prompt = 'Diff against: ', default = default_branch() }, function(rev) if rev and rev ~= '' then - vim.cmd('DiffviewOpen ' .. rev .. '...HEAD') + -- rev...HEAD is merge-base semantics: what this branch added, not what + -- the base branch has moved on to since. + vim.cmd('CodeDiff ' .. rev .. '...HEAD') end end) end, 'Diff against branch') diff --git a/neovim/config/plugins/init.lua b/neovim/config/plugins/init.lua index 7046983..ea9535b 100644 --- a/neovim/config/plugins/init.lua +++ b/neovim/config/plugins/init.lua @@ -1,6 +1,6 @@ -- The colorscheme goes first so everything after it is drawn with it applied require('config.plugins.catppuccin') -require('config.plugins.diffview') +require('config.plugins.codediff') require('config.plugins.fzf-lua') require('config.plugins.gitsigns') require('config.plugins.nvim-tree') diff --git a/neovim/nvim-pack-lock.json b/neovim/nvim-pack-lock.json index c80ef95..9508372 100644 --- a/neovim/nvim-pack-lock.json +++ b/neovim/nvim-pack-lock.json @@ -4,9 +4,9 @@ "rev": "edefef779ab08ce1a4a404713e3012b0d202bd35", "src": "https://github.com/catppuccin/nvim" }, - "diffview.nvim": { - "rev": "4516612fe98ff56ae0415a259ff6361a89419b0a", - "src": "https://github.com/sindrets/diffview.nvim" + "codediff.nvim": { + "rev": "e08a35a56a52c290398ebfaec33c34cfcf2d0f3c", + "src": "https://github.com/esmuellert/codediff.nvim" }, "fzf-lua": { "rev": "8671012a7b2a1648595952c655039d51fb301c14",