From fa20c7760741deee9a76bbf61ae20e9b19d42f35 Mon Sep 17 00:00:00 2001 From: Youwen Wu Date: Sat, 28 Dec 2024 23:55:45 -0800 Subject: [PATCH] feat: add vault quick syncer script --- init.lua | 1 + lua/scripts/obsidian-sync.lua | 14 ++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 lua/scripts/obsidian-sync.lua diff --git a/init.lua b/init.lua index fd546cb..eda99b1 100644 --- a/init.lua +++ b/init.lua @@ -1,5 +1,6 @@ require("keymaps") require("plugins") +require("scripts.obsidian-sync") require("scripts.autoroot").setup() diff --git a/lua/scripts/obsidian-sync.lua b/lua/scripts/obsidian-sync.lua new file mode 100644 index 0000000..2ce1431 --- /dev/null +++ b/lua/scripts/obsidian-sync.lua @@ -0,0 +1,14 @@ +vim.api.nvim_create_user_command("VaultSync", function() + local date = os.date("%Y-%m-%d %H:%M:%S") + local commit_commands = { + "git add -A", + string.format([[git commit -m "neovim-update: %s"]], date), + } + for _, cmd in ipairs(commit_commands) do + vim.fn.system(cmd) + end + vim.notify("Committed all local changes.", vim.log.levels.INFO) + vim.cmd("Neogit push") +end, {}) + +vim.keymap.set("n", "vs", vim.cmd.VaultSync)