From 0391e357cec528c475491f6f468b9b1f7ae0b413 Mon Sep 17 00:00:00 2001 From: Kasfil Aziz Date: Sun, 31 Jan 2021 21:30:33 +0700 Subject: [PATCH] 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 --- lua/hardline/parts/git.lua | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/lua/hardline/parts/git.lua b/lua/hardline/parts/git.lua index 79da254..f490484 100644 --- a/lua/hardline/parts/git.lua +++ b/lua/hardline/parts/git.lua @@ -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