Add support for gina.vim and vim-signify (#2)

* add support for gina.vim

* add support for vim-signify

* fix wrong value in vim-signify empty buffer

* add missing single quotes

* fix table indexing mistake

* add parentheses to make it work
This commit is contained in:
Kasfil Aziz
2021-01-31 21:30:33 +07:00
committed by GitHub
parent aa357ce962
commit 0391e357ce

View File

@@ -2,8 +2,21 @@ local fn = vim.fn
local g = vim.g
local function get_hunks()
if not g.loaded_gitgutter then return '' end
local summary = fn.GitGutterGetHunkSummary()
local summary
if g.loaded_gitgutter then
summary = fn.GitGutterGetHunkSummary()
elseif g.loaded_signify then
summary = fn['sy#repo#get_stats']()
-- signify return [-1,-1,-1] in empty buffer
-- that is why we check if one of value is -1
-- then stop the operation by return empty string
if (summary[1] == -1) then
return ''
end
else
-- return empty string if none of them is loaded
return ''
end
return table.concat({
string.format('+%d', summary[1]),
string.format('~%d', summary[2]),
@@ -12,8 +25,12 @@ local function get_hunks()
end
local function get_branch()
if not g.loaded_fugitive then return false end
local branch = fn.FugitiveHead()
local branch
if g.loaded_fugitive then
branch = fn.FugitiveHead()
elseif g.loaded_gina then
branch = fn['gina#component#repo#branch']()
end
return branch ~= '' and string.format('(%s)', branch) or ''
end