Use vim.schedule()

This commit is contained in:
pfych 2025-03-21 14:59:27 +11:00
parent 2fc0884419
commit 3f4edd589a

View File

@ -1,31 +1,33 @@
vim.api.nvim_create_autocmd("User", { vim.api.nvim_create_autocmd("User", {
pattern = "LazyUpdate", pattern = "LazyUpdate",
callback = function() callback = function()
local home = os.getenv("HOME") or "~/" vim.schedule(function()
local home = os.getenv("HOME") or "~/"
local cmd = { local cmd = {
"yadm", "yadm",
"-C", "-C",
string.format("%s", home), string.format("%s", home),
"commit", "commit",
".config/nvim/lazy-lock.json", ".config/nvim/lazy-lock.json",
"-m", "-m",
"Update lazy-lock.json" "Update lazy-lock.json"
} }
local success, process = pcall(function() local success, process = pcall(function()
return vim.system(cmd):wait() return vim.system(cmd):wait()
end) end)
if process and process.code == 0 then if process and process.code == 0 then
vim.notify("Committed lazy-lock") vim.notify("Committed lazy-lock")
else
if not success then
vim.notify("Failed to run command")
else else
vim.notify("Git ran, but nothing committed") if not success then
vim.notify("Failed to run command")
else
vim.notify("Git ran, but nothing committed")
end
end end
end end)
end end
}) })