irongit

Configure synchronization of files and directories through a plugin.

added more user commands and moved some functions out of init

huncholanehuncholaneauthored
parent 346305dcommit 5ee73423d16ca80c37df6fa4b5ae80a9a3993a45Browse files

4 files changed, +34 -15

+20-2lua/syncmap/commands.lua
@@ -4,8 +4,26 @@ local M = {
44 local state = require("syncmap.state")
55
66 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+ )
927 end
1028
1129 return M
+0-10lua/syncmap/init.lua
@@ -21,14 +21,4 @@ function M.setup(opts)
2121 M.commands.setup()
2222 end
2323
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-
3424 return M
+12-1lua/syncmap/state.lua
@@ -98,9 +98,10 @@ end
9898
9999 ---Kills all the active inotifywatch servers
100100 function M.killall()
101- for src in M.active do
101+ for src in pairs(M.active) do
102102 utils.kill(src)
103103 end
104+ M.active = {}
104105 end
105106
106107 ---Clears the saved information by deleting the state file
@@ -120,4 +121,14 @@ function M.restart()
120121 M.sync()
121122 end
122123
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+
123134 return M
+2-2lua/syncmap/utils.lua
@@ -85,8 +85,8 @@ function M.row_to_rsync_params(m)
8585 local flags = M.extract_flags(m)
8686 ---@type RsyncParams
8787 return {
88- src = m[1],
89- dst = m[2],
88+ src = vim.fn.expand(m[1]),
89+ dst = vim.fn.expand(m[2]),
9090 flags = flags,
9191 reverse_sync_on_spawn = M.extract_reverse(m),
9292 }