feat: support gitsigns

This commit is contained in:
David Zhang
2021-02-19 18:25:26 +08:00
committed by Olivier Roques
parent dcc0294280
commit 55255ed409
2 changed files with 10 additions and 1 deletions

View File

@@ -1,5 +1,6 @@
local fn = vim.fn
local g = vim.g
local b = vim.b
local fmt = string.format
local function get_hunks()
@@ -11,6 +12,12 @@ local function get_hunks()
if (summary[1] == -1) then -- signify returns {-1, -1, -1} in empty buffer
return ''
end
elseif b.gitsigns_status_dict ~= nil then
local status_dict = b.gitsigns_status_dict
if status_dict.added == nil then
return ''
end
summary = {status_dict.added, status_dict.changed, status_dict.removed}
else
return ''
end
@@ -29,6 +36,8 @@ local function get_branch()
branch = fn['gina#component#repo#branch']()
elseif g.loaded_gitbranch then
branch = fn['gitbranch#name']()
elseif b.gitsigns_head ~= nil then
branch = b.gitsigns_head
end
return branch ~= '' and fmt('(%s)', branch) or ''
end