refactor(git): rework module around clearer Status and Repo split
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
local repo = require("git.repo")
|
||||
|
||||
local M = {}
|
||||
|
||||
---@return string
|
||||
function M.render()
|
||||
local r = repo.find()
|
||||
if not r then
|
||||
return ""
|
||||
end
|
||||
local name = vim.api.nvim_buf_get_name(0)
|
||||
if name == "" then
|
||||
return ""
|
||||
end
|
||||
local rel = vim.fs.relpath(r.worktree, vim.fn.resolve(name))
|
||||
local list = rel and r.status.entries[rel]
|
||||
if not list then
|
||||
return ""
|
||||
end
|
||||
local parts = {}
|
||||
for _, e in ipairs(list) do
|
||||
table.insert(parts, string.format("%%#%s#%s%%*", e.hl, e.char))
|
||||
end
|
||||
return table.concat(parts, " ")
|
||||
end
|
||||
|
||||
repo.on("refresh", function()
|
||||
vim.cmd.redrawstatus({ bang = true })
|
||||
end)
|
||||
|
||||
return M
|
||||
Reference in New Issue
Block a user