Skip to content

Commit

Permalink
fix(plugin): fix url based plugin name and added extra safety checks. F…
Browse files Browse the repository at this point in the history
…ixes #824
  • Loading branch information
folke committed May 25, 2023
1 parent 57062f3 commit 32170a8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lua/lazy/core/plugin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 32170a8

Please sign in to comment.