Skip to content

Commit

Permalink
feat!: Pulling the commands into one with args to not pollute the glo…
Browse files Browse the repository at this point in the history
…bal namespace
  • Loading branch information
ejrichards committed Jun 17, 2024
1 parent 281acbc commit bda2f8a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ lazy.nvim

## 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

Expand Down
16 changes: 14 additions & 2 deletions lua/baredot/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,20 @@ end
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

0 comments on commit bda2f8a

Please sign in to comment.