Add dynamic colors

This commit is contained in:
Olivier Roques
2020-12-24 13:41:30 +01:00
parent 7b0dd9a92c
commit 1505322bdd
8 changed files with 250 additions and 95 deletions

View File

@@ -1,25 +1,28 @@
local M = {}
local common = require('hardline.common')
function M.get_hunks()
local function get_hunks()
if not vim.g.loaded_gitgutter then return '' end
local summary = vim.fn.GitGutterGetHunkSummary()
return table.concat({
string.format('+%d', summary[1]),
string.format('~%d', summary[2]),
string.format('-%d', summary[3]),
}, ' ')
end
function M.get_branch()
if not vim.g.loaded_gitgutter then return '' end
return string.format(' %s', vim.fn.FugitiveHead())
end
function M.get_item()
return table.concat({
[[%{luaeval('require("hardline.parts.git").get_hunks()')}]],
[[%{luaeval('require("hardline.parts.git").get_branch()')}]],
' ',
string.format('+%d', summary[1]), ' ',
string.format('~%d', summary[2]), ' ',
string.format('-%d', summary[3]), ' ',
})
end
return M
local function get_branch()
if not vim.g.loaded_gitgutter then return '' end
return string.format('(%s) ', vim.fn.FugitiveHead())
end
local function get_item()
return {
text = table.concat({get_hunks(), get_branch()}),
mode = common.get_active(),
}
end
return {
get_item = get_item,
}