Files
nvim-hardline/lua/hardline/parts/git.lua
Olivier Roques 3f8e61a4e4 Refactor
2020-12-26 00:25:31 +01:00

29 lines
684 B
Lua

local fn = vim.fn
local g = vim.g
local function get_hunks()
if not g.loaded_gitgutter then return '' end
local summary = fn.GitGutterGetHunkSummary()
return table.concat({
string.format('+%d', summary[1]),
string.format('~%d', summary[2]),
string.format('-%d', summary[3]),
}, ' ')
end
local function get_branch()
if not g.loaded_gitgutter then return '' end
local branch = fn.FugitiveHead()
return branch ~= '' and string.format('(%s)', branch) or ''
end
local function get_item()
local hunks, branch = get_hunks(), get_branch()
if branch == '' then return '' end
return table.concat({hunks, ' ' .. branch})
end
return {
get_item = get_item,
}