irongit

Configure synchronization of files and directories through a plugin.

works with the new simple_cmd

huncholanehuncholaneauthored
parent ce78121commit 655a7ca0876348dc1049f67fa575efab66fb6db8Browse files

2 files changed, +13 -19

+12-18lua/syncmap/rsync.lua
@@ -28,28 +28,22 @@ function M.spawn_watcher(args)
2828 })
2929 end
3030
31+ local cmd = string.format(
32+ "while inotifywait -r -m -e modify,create,delete %q; do rsync %s %q %q; done #syncmap:%s",
33+ args.src,
34+ table.concat(args.flags, " "),
35+ args.src,
36+ args.dst,
37+ args.src
38+ )
39+ local cmd_str = "sh -c '" .. cmd .. "'"
40+
3141 simple_cmd.spawn("sh", {
32- args = {
33- "-c",
34- string.format(
35- "while inotifywait -r -e modify,create,delete %q; do rsync %s %q %q; done",
36- args.src,
37- table.concat(args.flags, " "),
38- args.src,
39- args.dst
40- ),
41- },
42+ args = { "-c", cmd },
4243 path = "sh",
4344 cwd = args.src,
4445 callback = function(code, status, _, pid)
45- log.info(
46- string.format(
47- "The inotify trigger ended with %d code and status %d.\nThe pid from handle is %d.",
48- code,
49- status,
50- pid
51- )
52- )
46+ log.info(string.format("%s\n%d completed with %d code and %d status", cmd_str, pid, code, status))
5347 end,
5448 })
5549 end
+1-1lua/syncmap/simple_cmd.lua
@@ -20,7 +20,7 @@ local M = {}
2020 ---@param path string the exectuable path
2121 ---@param p SpawnCommandParams
2222 function M.spawn(path, p)
23- local args = p[2]
23+ local args = p.args
2424 local stdio = p.stdio or { nil, nil, nil }
2525 local cwd = p.cwd or vim.fn.getcwd()
2626 local env = p.env or vim.fn.environ()