Configure synchronization of files and directories through a plugin.
Register one command with options
1 file changed, +20 -20
+20-20lua/syncmap/commands.lua
| @@ -4,26 +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( | |
| 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 | - "SyncmapClean", | |
| 14 | - state.clean, | |
| 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 | - ) | |
| 7 | + vim.api.nvim_create_user_command("Syncmap", function(args) | |
| 8 | + local arg = args.args | |
| 9 | + if arg == "restart" then | |
| 10 | + state.restart() | |
| 11 | + elseif arg == "clean" then | |
| 12 | + state.clean() | |
| 13 | + elseif arg == "active" then | |
| 14 | + state.show_active() | |
| 15 | + elseif arg == "opts" then | |
| 16 | + state.show_opts() | |
| 17 | + else | |
| 18 | + vim.notify("Unknown Syncmap command: " .. arg, vim.log.levels.ERROR) | |
| 19 | + end | |
| 20 | + end, { | |
| 21 | + desc = "Syncmap control command", | |
| 22 | + nargs = 1, | |
| 23 | + complete = function() | |
| 24 | + return { "restart", "clean", "active", "opts" } | |
| 25 | + end, | |
| 26 | + }) | |
| 27 | 27 | end |
| 28 | 28 | |
| 29 | 29 | return M |