32 lines
671 B
Lua
32 lines
671 B
Lua
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
|