AutoYADM commit: 2024-12-18 16:50:04

This commit is contained in:
Daniel Fichtinger 2024-12-18 16:50:04 -05:00
parent 24cd695da0
commit fcbaa006de

View file

@ -0,0 +1,49 @@
local M = {}
local parse_output = function(proc)
local result = proc:wait()
local ret = {}
if result.code == 0 then
for line in vim.gsplit(result.stdout, "\n", { plain = true, triempty = true }) do
line = line:gsub("/$", "")
ret[line] = true
end
end
return ret
end
local new_git_status = function()
return setmetatable({}, {
__index = function(self, key)
local ignore_proc = vim.system(
{ "git", "ls-files", "--ignored", "--exclude-standard", "--others", "--directory" },
{
cwd = key,
text = true,
}
)
local tracked_proc = vim.system({ "git", "ls-tree", "HEAD", "--name-only" }, {
cwd = key,
text = true,
})
local ret = {
ignored = parse_output(ignore_proc),
tracked = parse_output(tracked_proc),
}
rawset(self, key, ret)
return ret
end,
})
end
M.git_status = new_git_status()
local refresh = require("oil.actions").refresh
local orig_refresh = refresh.callback
refresh.callback = function(...)
M.git_status = new_git_status()
orig_refresh(...)
end
return M