feat: fennelize obsidian-sync

This commit is contained in:
Youwen Wu 2025-02-01 14:22:35 -08:00
parent e58f6efffe
commit 06e3caa65e
Signed by: youwen5
GPG key ID: 865658ED1FE61EC3
2 changed files with 21 additions and 9 deletions

View file

@ -0,0 +1,14 @@
(vim.api.nvim_create_user_command :VaultSync
(fn []
(let [date (os.date "%Y-%m-%d %H:%M:%S")
commit-commands ["git add -A"
(string.format "git commit -m \"auto-update(nvim): %s\""
date)]]
(each [_ cmd (ipairs commit-commands)]
(vim.fn.system cmd))
(vim.notify "Committed all local changes."
vim.log.levels.INFO)
(vim.cmd "Neogit push")))
{})
(vim.keymap.set :n :<leader>os vim.cmd.VaultSync)

View file

@ -1,14 +1,12 @@
vim.api.nvim_create_user_command("VaultSync", function() -- [nfnl] Compiled from ./fnl/scripts/obsidian-sync.fnl by https://github.com/Olical/nfnl, do not edit.
local function _1_()
local date = os.date("%Y-%m-%d %H:%M:%S") local date = os.date("%Y-%m-%d %H:%M:%S")
local commit_commands = { local commit_commands = {"git add -A", string.format("git commit -m \"auto-update(nvim): %s\"", date)}
"git add -A",
string.format([[git commit -m "auto-update(nvim): %s"]], date),
}
for _, cmd in ipairs(commit_commands) do for _, cmd in ipairs(commit_commands) do
vim.fn.system(cmd) vim.fn.system(cmd)
end end
vim.notify("Committed all local changes.", vim.log.levels.INFO) vim.notify("Committed all local changes.", vim.log.levels.INFO)
vim.cmd("Neogit push") return vim.cmd("Neogit push")
end, {}) end
vim.api.nvim_create_user_command("VaultSync", _1_, {})
vim.keymap.set("n", "<leader>os", vim.cmd.VaultSync) return vim.keymap.set("n", "<leader>os", vim.cmd.VaultSync)