Skip to content

Commit

Permalink
fix(cmd): show descriptive error when command was not found after loa…
Browse files Browse the repository at this point in the history
…ding its plugins
  • Loading branch information
folke committed Apr 18, 2023
1 parent eddee83 commit b582fc5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lua/lazy/core/handler/cmd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,20 @@ function M:_add(cmd)
command.range = { event.line1, event.line2 }
end

---@type string
local plugins = "`" .. table.concat(vim.tbl_values(self.active[cmd]), ", ") .. "`"

self:_load(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
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,
Expand Down

0 comments on commit b582fc5

Please sign in to comment.