perf: tons of performance improvements. Lazy should now load in about 1.5ms for 97 plugins

This commit is contained in:
Folke Lemaitre 2022-11-24 22:04:23 +01:00
parent 711834f17c
commit 2507fd5790
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
11 changed files with 220 additions and 278 deletions

View file

@ -8,6 +8,7 @@ M.defaults = {
plugins = "config.plugins",
plugins_local = {
path = vim.fn.expand("~/projects"),
---@type string[]
patterns = {},
},
package_path = vim.fn.stdpath("data") .. "/site/pack/lazy",
@ -27,15 +28,27 @@ M.defaults = {
M.ns = vim.api.nvim_create_namespace("lazy")
M.paths = {
---@type string
main = nil,
---@type string
plugins = nil,
}
---@type table<string, LazyPlugin>
M.plugins = {}
---@type LazyPlugin[]
M.to_clean = {}
---@type LazyConfig
M.options = {}
---@param opts? LazyConfig
function M.setup(opts)
M.options = vim.tbl_deep_extend("force", M.defaults, opts or {})
M.paths.plugins = vim.fn.stdpath("config") .. "/lua/" .. M.options.plugins:gsub("%.", "/")
M.paths.main = M.paths.plugins .. (vim.loop.fs_stat(M.paths.plugins .. ".lua") and ".lua" or "/init.lua")
-- vim.fn.mkdir(M.options.package_path, "p")