Commit graph dotfiles/neovim/config/plugins/codediff.lua
Author SHA1 Message Date
Jonny Barnes
80683b82c1
Add git sync, and stop trusting the cached default branch
BuildEmpire/Totara renamed its default branch from main to totara-20.
Nothing local noticed, because refs/remotes/origin/HEAD is written once at
clone time and remote.<name>.followRemoteHEAD defaults to `create`, which
only fills the ref in when it is missing. So `git default-branch` still
said main, as did nvim's diff-against-branch prompt.

bin/git-sync does the start-of-work sequence for a fork - fast-forward the
default branch from upstream, push it to origin - and works out which
branch that is by asking the server, not the cache. It sets the cached
HEADs from the answer, so everything reading that ref agrees afterwards.
It lives in bin/ rather than as an alias because git picks up git-<name>
on the $PATH as a subcommand, and this is more shell than a gitconfig
alias should hold. followRemoteHEAD = always is set for origin as well, so
an ordinary fetch keeps the ref current without running the script.

The nvim prompt now prefers origin, then upstream, then the remaining
remotes. It took the first remote alphabetically before, which in
be-edition means kdog - a colleague's fork - rather than anything
authoritative.

Verified against a fixture of bare repos whose default branch is
totara-20 and whose cached HEAD is stale: the branch is created tracking
origin when absent, fast-forwarded when behind, pushed to the fork,
refuses to merge when the local copy has diverged, and is a no-op on a
second run. The nvim prompt was checked in three real repos.
2026-08-27 16:05:49 +01:00
Jonny Barnes
d4a4c68787
Replace diffview.nvim with codediff.nvim
diffview was doing the job for reviewing a branch before merging it, but
not well enough. codediff renders diffs the way VSCode does - light
line-level backgrounds with deeper character-level highlights on top of
them - so what actually changed within a line is legible rather than
inferred.

Keymaps carry over one for one: <leader>gd opens the status explorer,
<leader>gh/<leader>gH the file and branch history, and <leader>gm still
prompts for a base branch and diffs rev...HEAD against it. <leader>gc is
folded into codediff's own quit action alongside q, since there is no
close command to map it to.

Its diffing is done in C, and the library is downloaded prebuilt on
first use rather than compiled, so there is no build step for vim.pack
to worry about.
2026-08-27 15:42:08 +01:00
Renamed from neovim/config/plugins/diffview.lua (Browse further)