Configure synchronization of files and directories through a plugin.
added more user commands and moved some functions out of init
4 files changed, +34 -15
+20-2lua/syncmap/commands.lua
| @@ -4,8 +4,26 @@ local M = { | ||
| 4 | 4 | local state = require("syncmap.state") |
| 5 | 5 | |
| 6 | 6 | function M.setup() |
| 7 | - vim.api.nvim_create_user_command("SyncmapRestart", state.restart, {}) | |
| 8 | - vim.api.nvim_create_user_command("SyncmapStop", state.clear, {}) | |
| 7 | + vim.api.nvim_create_user_command( | |
| 8 | + "SyncmapRestart", | |
| 9 | + state.restart, | |
| 10 | + { desc = "Clears everything and starts all the inotify servers again" } | |
| 11 | + ) | |
| 12 | + vim.api.nvim_create_user_command( | |
| 13 | + "SyncmapStop", | |
| 14 | + state.clear, | |
| 15 | + { desc = "Clears the active map and all of it's processes" } | |
| 16 | + ) | |
| 17 | + vim.api.nvim_create_user_command( | |
| 18 | + "SyncmapActive", | |
| 19 | + state.show_active, | |
| 20 | + { desc = "Shows currently active inotify servers" } | |
| 21 | + ) | |
| 22 | + vim.api.nvim_create_user_command( | |
| 23 | + "SyncmapOpts", | |
| 24 | + state.show_opts, | |
| 25 | + { desc = "Shows the current settings for Syncmap" } | |
| 26 | + ) | |
| 9 | 27 | end |
| 10 | 28 | |
| 11 | 29 | return M |
+0-10lua/syncmap/init.lua
| @@ -21,14 +21,4 @@ function M.setup(opts) | ||
| 21 | 21 | M.commands.setup() |
| 22 | 22 | end |
| 23 | 23 | |
| 24 | ----Shows the current state of Syncmap | |
| 25 | -function M.show_state() | |
| 26 | - vim.print(M.state.active) | |
| 27 | -end | |
| 28 | - | |
| 29 | ----Shows the current options of Syncmap | |
| 30 | -function M.show_opts() | |
| 31 | - vim.print(M.opts) | |
| 32 | -end | |
| 33 | - | |
| 34 | 24 | return M |
+12-1lua/syncmap/state.lua
| @@ -98,9 +98,10 @@ end | ||
| 98 | 98 | |
| 99 | 99 | ---Kills all the active inotifywatch servers |
| 100 | 100 | function M.killall() |
| 101 | - for src in M.active do | |
| 101 | + for src in pairs(M.active) do | |
| 102 | 102 | utils.kill(src) |
| 103 | 103 | end |
| 104 | + M.active = {} | |
| 104 | 105 | end |
| 105 | 106 | |
| 106 | 107 | ---Clears the saved information by deleting the state file |
| @@ -120,4 +121,14 @@ function M.restart() | ||
| 120 | 121 | M.sync() |
| 121 | 122 | end |
| 122 | 123 | |
| 124 | +---List active | |
| 125 | +function M.show_active() | |
| 126 | + vim.print(M.active) | |
| 127 | +end | |
| 128 | + | |
| 129 | +---Shows the current options of Syncmap | |
| 130 | +function M.show_opts() | |
| 131 | + vim.print(M.opts) | |
| 132 | +end | |
| 133 | + | |
| 123 | 134 | return M |
+2-2lua/syncmap/utils.lua
| @@ -85,8 +85,8 @@ function M.row_to_rsync_params(m) | ||
| 85 | 85 | local flags = M.extract_flags(m) |
| 86 | 86 | ---@type RsyncParams |
| 87 | 87 | return { |
| 88 | - src = m[1], | |
| 89 | - dst = m[2], | |
| 88 | + src = vim.fn.expand(m[1]), | |
| 89 | + dst = vim.fn.expand(m[2]), | |
| 90 | 90 | flags = flags, |
| 91 | 91 | reverse_sync_on_spawn = M.extract_reverse(m), |
| 92 | 92 | } |