user_cmd: use one command instead of multiple

* DirenvCheck -> Direnv reload
* DirenvAllow -> Direnv allow
* DirenvDeny -> Direnv deny

Also renames M.check_direnv to M.reload_direnv for better naming.
This commit is contained in:
itslychee 2024-07-03 12:53:26 -05:00
parent 9500c479f9
commit 20ecd1d869
No known key found for this signature in database

View file

@ -34,15 +34,22 @@ M.setup = function(user_config)
return
end
vim.api.nvim_create_user_command("DirenvAllow", function()
M.allow_direnv()
end, {})
vim.api.nvim_create_user_command("DirenvDeny", function()
M.deny_direnv()
end, {})
vim.api.nvim_create_user_command("DirenvCheck", function()
M.check_direnv()
end, {})
vim.api.nvim_create_user_command("Direnv", function(opts)
local cmds = {
["allow"] = M.allow_direnv,
["deny"] = M.deny_direnv,
["reload"] = M.check_direnv,
}
local cmd = cmds[string.lower(opts.fargs[1])]
if cmd then
cmd()
end
end, {
nargs = 1,
complete = function()
return { "allow", "deny", "reload" }
end,
})
setup_keymaps({
{