feat(vim-bujo): add git repo for ~/.cache/bujo and commit & push on save
This commit is contained in:
parent
a1033f4912
commit
ff600866dc
1 changed files with 27 additions and 0 deletions
|
|
@ -7,3 +7,30 @@ vim.api.nvim_create_autocmd({ "TermOpen", "BufEnter" }, {
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- vim-bujo auto commit & push on save
|
||||||
|
vim.api.nvim_create_augroup("BujoGit", { clear = true })
|
||||||
|
vim.api.nvim_create_autocmd("BufWritePost", {
|
||||||
|
group = "BujoGit",
|
||||||
|
pattern = vim.fn.expand("$HOME") .. "/.cache/bujo/*",
|
||||||
|
callback = function()
|
||||||
|
local filepath = vim.api.nvim_buf_get_name(0)
|
||||||
|
if filepath:match(vim.fn.expand("~/.cache/bujo/")) then
|
||||||
|
vim.fn.jobstart({
|
||||||
|
"sh", "-c", "cd ~/.cache/bujo && git add . && git commit -m 'Auto-update bujo files' && git push"
|
||||||
|
}, {
|
||||||
|
on_exit = function(_, code)
|
||||||
|
if code == 0 then
|
||||||
|
vim.schedule(function()
|
||||||
|
vim.notify("Bujo files committed and pushed", vim.log.levels.INFO)
|
||||||
|
end)
|
||||||
|
else
|
||||||
|
vim.schedule(function()
|
||||||
|
vim.notify("Error syncing bujo files", vim.log.levels.ERROR)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue