fix(cmd): properly deal with commands with nargs=? or nargs=1. Fixes #659

This commit is contained in:
Folke Lemaitre 2023-03-16 23:54:09 +01:00
parent b4b11f48aa
commit efe36bdfda
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
1 changed files with 7 additions and 0 deletions

View File

@ -29,6 +29,13 @@ function M:_add(cmd)
end
self:_load(cmd)
local info = vim.api.nvim_get_commands({})[cmd]
command.nargs = info.nargs
if event.args and event.args ~= "" and info.nargs and info.nargs:find("[1?]") then
command.args = { event.args }
end
vim.cmd(command)
end, {
bang = true,