From 32170a88916e0f18ffaf1c32b222a5e2216bdb0e Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Thu, 25 May 2023 08:10:08 +0200 Subject: [PATCH] fix(plugin): fix url based plugin name and added extra safety checks. Fixes #824 --- lua/lazy/core/plugin.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lua/lazy/core/plugin.lua b/lua/lazy/core/plugin.lua index 840a343e..c53ee724 100644 --- a/lua/lazy/core/plugin.lua +++ b/lua/lazy/core/plugin.lua @@ -49,6 +49,7 @@ end -- PERF: optimized code to get package name without using lua patterns function Spec.get_name(pkg) local name = pkg:sub(-4) == ".git" and pkg:sub(1, -5) or pkg + name = name:sub(-1) == "/" and name:sub(1, -2) or name local slash = name:reverse():find("/", 1, true) --[[@as number?]] return slash and name:sub(#name - slash + 2) or pkg:gsub("%W+", "_") end @@ -109,6 +110,11 @@ function Spec:add(plugin, results, is_dep) return end + if not plugin.name or plugin.name == "" then + self:error("Plugin spec " .. vim.inspect(plugin) .. " has no name") + return + end + if type(plugin.config) == "table" then self:warn( "{" .. plugin.name .. "}: setting a table to `Plugin.config` is deprecated. Please use `Plugin.opts` instead"