fix(cmd): show descriptive error when command was not found after loading its plugins

This commit is contained in:
Folke Lemaitre 2023-04-18 10:17:22 +02:00
parent eddee830ed
commit b582fc5545
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
1 changed files with 7 additions and 1 deletions

View File

@ -28,14 +28,20 @@ function M:_add(cmd)
command.range = { event.line1, event.line2 } command.range = { event.line1, event.line2 }
end end
---@type string
local plugins = "`" .. table.concat(vim.tbl_values(self.active[cmd]), ", ") .. "`"
self:_load(cmd) self:_load(cmd)
local info = vim.api.nvim_get_commands({})[cmd] local info = vim.api.nvim_get_commands({})[cmd]
if not info then
return Util.error("Command `" .. cmd .. "` not found after loading " .. plugins)
end
command.nargs = info.nargs command.nargs = info.nargs
if event.args and event.args ~= "" and info.nargs and info.nargs:find("[1?]") then if event.args and event.args ~= "" and info.nargs and info.nargs:find("[1?]") then
command.args = { event.args } command.args = { event.args }
end end
vim.cmd(command) vim.cmd(command)
end, { end, {
bang = true, bang = true,