fix(statusline): handle non-git buffers better
This commit is contained in:
@@ -77,21 +77,26 @@ vim.opt.updatetime = 100
|
|||||||
|
|
||||||
function _G._status_line_git()
|
function _G._status_line_git()
|
||||||
local status = vim.b.gitsigns_status_dict
|
local status = vim.b.gitsigns_status_dict
|
||||||
|
|
||||||
if not status then
|
if not status then
|
||||||
return ''
|
return ''
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local added = status.added or 0
|
||||||
|
local changed = status.changed or 0
|
||||||
|
local removed = status.removed or 0
|
||||||
|
|
||||||
local parts = {}
|
local parts = {}
|
||||||
|
|
||||||
if status.added > 0 then
|
if added > 0 then
|
||||||
table.insert(parts, string.format("%%#GitSignsAdd#+%d%%*", status.added))
|
table.insert(parts, string.format("%%#GitSignsAdd#+%d%%*", status.added))
|
||||||
end
|
end
|
||||||
|
|
||||||
if status.changed > 0 then
|
if changed > 0 then
|
||||||
table.insert(parts, string.format('%%#GitSignsChange#~%d%%*', status.changed))
|
table.insert(parts, string.format('%%#GitSignsChange#~%d%%*', status.changed))
|
||||||
end
|
end
|
||||||
|
|
||||||
if status.removed > 0 then
|
if removed > 0 then
|
||||||
table.insert(parts, string.format('%%#GitSignsDelete#-%d%%*', status.removed))
|
table.insert(parts, string.format('%%#GitSignsDelete#-%d%%*', status.removed))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user