From b582fc554582c755c221fdcbb7dce648e971cd88 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Tue, 18 Apr 2023 10:17:22 +0200 Subject: [PATCH] fix(cmd): show descriptive error when command was not found after loading its plugins --- lua/lazy/core/handler/cmd.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lua/lazy/core/handler/cmd.lua b/lua/lazy/core/handler/cmd.lua index 86711de..28c7d9b 100644 --- a/lua/lazy/core/handler/cmd.lua +++ b/lua/lazy/core/handler/cmd.lua @@ -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,