Neovim plugin to automatically adjust git env vars when syncing dotfiles using the "bare git repo" method

feat: Pulling the commands into one with args to not pollute the global namespace

Changed files
+16 -4
lua
baredot
+2 -2
README.md
···
## Commands
-
- `:BaredotInfo` - Print current status
-
- `:BaredotToggle` - Manually toggle the env vars on / off
+
- `:Baredot info` - Print current status
+
- `:Baredot toggle` - Manually toggle the env vars on / off
## Functions
+14 -2
lua/baredot/commands.lua
···
function Commands.setup(opt)
options = opt
-
vim.api.nvim_create_user_command("BaredotInfo", Commands.info, { desc = "BaredotInfo" })
-
vim.api.nvim_create_user_command("BaredotToggle", Commands.toggle, { desc = "BaredotToggle" })
+
vim.api.nvim_create_user_command("Baredot", function(args)
+
local cmd = vim.trim(args.args or "")
+
if cmd == "toggle" then
+
Commands.toggle()
+
else
+
Commands.info()
+
end
+
end, {
+
desc = "Baredot",
+
nargs = "?",
+
complete = function()
+
return { "info", "toggle" }
+
end
+
})
end
return Commands