mirror of
https://github.com/folke/lazy.nvim.git
synced 2025-06-24 09:49:07 +02:00
perf: minimize meta rebuild when loading specs
This commit is contained in:
parent
972baa615b
commit
1446f6cfbb
4 changed files with 67 additions and 13 deletions
|
@ -362,17 +362,24 @@ end
|
|||
|
||||
-- Finds the plugin that has this path
|
||||
---@param path string
|
||||
function M.find(path)
|
||||
---@param opts? {fast?:boolean}
|
||||
function M.find(path, opts)
|
||||
if not Config.spec then
|
||||
return
|
||||
end
|
||||
opts = opts or {}
|
||||
local lua = path:find("/lua/", 1, true)
|
||||
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 Config.spec.plugins[name] or nil
|
||||
if name then
|
||||
if opts.fast then
|
||||
return Config.spec.meta.plugins[name]
|
||||
end
|
||||
return Config.spec.plugins[name]
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue