What
Extend the statusline's git branch component to also show the buffer's hunk counts — added, changed, and removed lines — using data already provided by gitsigns.
Where
lua/config/statusline.lua — current_git_branch() function, lines 28–38:
local function current_git_branch()
local branch = vim.b.gitsigns_head
if not branch or branch == "" then return "" end
return " %#Git# " .. branch .. " " .. "%*"
end
Why it matters
gitsigns already exposes b:gitsigns_status_dict (with .added, .changed, .removed integer fields) on every buffer it tracks. The statusline currently shows the branch name but no indication of whether the buffer has local changes or how large they are. Adding +2 ~1 -0 next to the branch name makes that visible at a glance without opening diffview or running git status.
Fits naturally with the existing diagnostic count display ( N┊ N┊…) — same "counts at a glance" philosophy.
Suggested implementation
local function current_git_branch()
local ok, _ = pcall(require, "gitsigns")
if not ok then return "" end
local branch = vim.b.gitsigns_head
if not branch or branch == "" then return "" end
local stats = vim.b.gitsigns_status_dict
local diff = ""
if stats then
if (stats.added or 0) > 0 then diff = diff .. " +" .. stats.added end
if (stats.changed or 0) > 0 then diff = diff .. " ~" .. stats.changed end
if (stats.removed or 0) > 0 then diff = diff .. " -" .. stats.removed end
end
return " %#Git# " .. branch .. diff .. " %*"
end
Optional: use separate highlight groups for each sign (green +, yellow ~, red -) to match the sign-column colours.
What
Extend the statusline's git branch component to also show the buffer's hunk counts — added, changed, and removed lines — using data already provided by gitsigns.
Where
lua/config/statusline.lua—current_git_branch()function, lines 28–38:Why it matters
gitsigns already exposes
b:gitsigns_status_dict(with.added,.changed,.removedinteger fields) on every buffer it tracks. The statusline currently shows the branch name but no indication of whether the buffer has local changes or how large they are. Adding+2 ~1 -0next to the branch name makes that visible at a glance without opening diffview or running git status.Fits naturally with the existing diagnostic count display (
N┊ N┊…) — same "counts at a glance" philosophy.Suggested implementation
Optional: use separate highlight groups for each sign (green
+, yellow~, red-) to match the sign-column colours.