Swap DiffView with CodeDiff

CodeDiff is supposed to be the successor to DiffView. It also has file
watching built-in so I can drop the custom `directory-watcher.lua`.
This commit is contained in:
2026-08-11 20:30:07 +00:00
parent 995ecb11d3
commit ab86df7274
4 changed files with 61 additions and 190 deletions
+39
View File
@@ -0,0 +1,39 @@
-- VSCode-style diff viewer, replaces sindrets/diffview.nvim.
-- The C diff library is downloaded automatically on first use (:CodeDiff install to force).
return {
"esmuellert/codediff.nvim",
cmd = "CodeDiff",
opts = {
diff = {
layout = "side-by-side",
},
explorer = {
-- Match diffview's file panel: tree listing with +/- line stats
view_mode = "tree",
line_stats = {
enabled = true,
},
},
keymaps = {
view = {
-- gq closed every diffview panel, keep it alongside the default q
quit = { "q", "gq" },
-- Default <leader>b shadows LazyVim's +buffer group, <leader>e/E mirrors
-- LazyVim's explorer mnemonic instead
toggle_explorer = "<leader>E",
focus_explorer = "<leader>e",
-- Defaults t and gc shadow the t{char} motion and the gc comment
-- operator in the (editable) modified buffer
toggle_layout = "gl",
toggle_compact = "gz",
},
},
},
keys = {
{ "<leader>gv", "<cmd>CodeDiff<cr>", desc = "Open [g]it Diff[v]iew tab" },
{ "<leader>gl", "<cmd>CodeDiff history %<cr>", desc = "Toggle git log of current file history" },
{ "<leader>gl", ":'<,'>CodeDiff history<cr>", mode = "v", desc = "Toggle git log of selected lines" },
{ "<leader>gL", "<cmd>CodeDiff history<cr>", desc = "Toggle git log of current branch" },
},
}