mirror of https://github.com/folke/lazy.nvim.git
perf: prevent string.match to find plugin name from a modpath
This commit is contained in:
parent
ecf03a6892
commit
f23a6eef8c
|
@ -258,8 +258,15 @@ end
|
||||||
-- Finds the plugin that has this path
|
-- Finds the plugin that has this path
|
||||||
---@param path string
|
---@param path string
|
||||||
function M.find(path)
|
function M.find(path)
|
||||||
local name = path:match("/([^/]+)/lua") or path:match("/([^/]+)/?$")
|
local lua = path:find("/lua", 1, true)
|
||||||
return name and Config.plugins[name] or nil
|
if lua then
|
||||||
|
local name = path:sub(1, lua - 1)
|
||||||
|
local slash = name:reverse():find("/", 1, true)
|
||||||
|
if slash then
|
||||||
|
name = name:sub(#name - slash + 2)
|
||||||
|
return name and Config.plugins[name] or nil
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
Loading…
Reference in New Issue