Configure synchronization of files and directories through a plugin.
works with the new simple_cmd
2 files changed, +13 -19
+12-18lua/syncmap/rsync.lua
| @@ -28,28 +28,22 @@ function M.spawn_watcher(args) | ||
| 28 | 28 | }) |
| 29 | 29 | end |
| 30 | 30 | |
| 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 | + | |
| 31 | 41 | 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 }, | |
| 42 | 43 | path = "sh", |
| 43 | 44 | cwd = args.src, |
| 44 | 45 | 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)) | |
| 53 | 47 | end, |
| 54 | 48 | }) |
| 55 | 49 | end |
+1-1lua/syncmap/simple_cmd.lua
| @@ -20,7 +20,7 @@ local M = {} | ||
| 20 | 20 | ---@param path string the exectuable path |
| 21 | 21 | ---@param p SpawnCommandParams |
| 22 | 22 | function M.spawn(path, p) |
| 23 | - local args = p[2] | |
| 23 | + local args = p.args | |
| 24 | 24 | local stdio = p.stdio or { nil, nil, nil } |
| 25 | 25 | local cwd = p.cwd or vim.fn.getcwd() |
| 26 | 26 | local env = p.env or vim.fn.environ() |