perf: caching strategy is now configurable

This commit is contained in:
Folke Lemaitre 2022-12-02 12:43:34 +01:00
parent ae379a62dc
commit 6fe425c91a
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
3 changed files with 89 additions and 29 deletions

View file

@ -8,8 +8,12 @@ function M.setup(spec, opts)
end
local start = vim.loop.hrtime()
-- load module cache before anything else
require("lazy.core.module").setup()
local Cache
if not (opts and opts.performance and opts.performance.cache and opts.performance.cache.enabled == false) then
-- load module cache before anything else
Cache = require("lazy.core.cache").setup(opts)
end
local Util = require("lazy.core.util")
local Config = require("lazy.core.config")
local Loader = require("lazy.core.loader")
@ -36,9 +40,17 @@ function M.setup(spec, opts)
Config.plugins["lazy.nvim"]._.loaded = { time = delta, source = "init.lua" }
end
if Cache then
Cache.disable("lazy")
end
-- load plugins with lazy=false or Plugin.init
Loader.init_plugins()
if Cache then
Cache.disable("init")
end
-- all done!
vim.cmd("do User LazyDone")
end