mirror of https://github.com/folke/lazy.nvim.git
fix(cmd): show descriptive error when command was not found after loading its plugins
This commit is contained in:
parent
eddee830ed
commit
b582fc5545
|
@ -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,
|
||||||
|
|
Loading…
Reference in New Issue