2022-11-21 05:33:47 +08:00
|
|
|
local M = {}
|
|
|
|
|
|
|
|
---@param opts? LazyConfig
|
|
|
|
function M.setup(opts)
|
2022-11-23 04:12:33 +08:00
|
|
|
local cache_start = vim.loop.hrtime()
|
|
|
|
require("lazy.core.cache").setup()
|
|
|
|
|
|
|
|
local module_start = vim.loop.hrtime()
|
2022-11-25 05:04:23 +08:00
|
|
|
require("lazy.core.module").setup()
|
2022-11-23 04:28:08 +08:00
|
|
|
local Util = require("lazy.core.util")
|
|
|
|
local Config = require("lazy.core.config")
|
|
|
|
local Loader = require("lazy.core.loader")
|
2022-11-26 05:48:17 +08:00
|
|
|
local Plugin = require("lazy.core.plugin")
|
2022-11-21 05:33:47 +08:00
|
|
|
|
2022-11-27 04:29:40 +08:00
|
|
|
Util.track("cache", module_start - cache_start)
|
|
|
|
Util.track("module", vim.loop.hrtime() - module_start)
|
2022-11-22 04:50:16 +08:00
|
|
|
|
2022-11-23 04:12:33 +08:00
|
|
|
Util.track("setup")
|
2022-11-21 05:33:47 +08:00
|
|
|
|
2022-11-23 04:12:33 +08:00
|
|
|
Util.track("config")
|
2022-11-21 05:34:55 +08:00
|
|
|
Config.setup(opts)
|
|
|
|
Util.track()
|
2022-11-21 05:33:47 +08:00
|
|
|
|
2022-11-23 23:10:16 +08:00
|
|
|
Util.track("state")
|
2022-11-26 05:48:17 +08:00
|
|
|
Plugin.load()
|
2022-11-21 05:34:55 +08:00
|
|
|
Util.track()
|
2022-11-21 05:33:47 +08:00
|
|
|
|
2022-11-23 04:12:33 +08:00
|
|
|
Util.track("install")
|
2022-11-21 05:34:55 +08:00
|
|
|
for _, plugin in pairs(Config.plugins) do
|
2022-11-28 18:19:50 +08:00
|
|
|
if not plugin._.installed then
|
2022-11-25 05:04:23 +08:00
|
|
|
vim.cmd("do User LazyInstallPre")
|
2022-11-27 18:02:28 +08:00
|
|
|
require("lazy.manage").install({
|
2022-11-21 07:27:28 +08:00
|
|
|
wait = true,
|
2022-11-25 22:35:40 +08:00
|
|
|
show = Config.options.interactive,
|
2022-11-21 07:27:28 +08:00
|
|
|
})
|
2022-11-21 05:34:55 +08:00
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
Util.track()
|
2022-11-21 05:33:47 +08:00
|
|
|
|
2022-11-23 04:12:33 +08:00
|
|
|
Util.track("loader")
|
2022-11-21 05:34:55 +08:00
|
|
|
Loader.setup()
|
|
|
|
Util.track()
|
2022-11-21 05:33:47 +08:00
|
|
|
|
2022-11-23 04:12:33 +08:00
|
|
|
Util.track() -- end setup
|
|
|
|
|
2022-11-25 05:04:23 +08:00
|
|
|
local lazy_delta = vim.loop.hrtime() - cache_start
|
|
|
|
|
2022-11-21 05:34:55 +08:00
|
|
|
Loader.init_plugins()
|
2022-11-25 05:04:23 +08:00
|
|
|
|
2022-11-26 20:58:18 +08:00
|
|
|
if Config.plugins["lazy.nvim"] then
|
2022-11-28 18:19:50 +08:00
|
|
|
Config.plugins["lazy.nvim"]._.loaded.time = lazy_delta
|
2022-11-26 20:58:18 +08:00
|
|
|
end
|
2022-11-21 05:33:47 +08:00
|
|
|
|
2022-11-21 05:34:55 +08:00
|
|
|
vim.cmd("do User LazyDone")
|
2022-11-21 05:33:47 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
function M.stats()
|
2022-11-21 05:34:55 +08:00
|
|
|
local ret = {
|
|
|
|
count = 0,
|
|
|
|
loaded = 0,
|
|
|
|
}
|
2022-11-21 05:33:47 +08:00
|
|
|
|
2022-11-23 04:28:08 +08:00
|
|
|
for _, plugin in pairs(require("lazy.core.config").plugins) do
|
2022-11-21 05:34:55 +08:00
|
|
|
ret.count = ret.count + 1
|
2022-11-21 05:33:47 +08:00
|
|
|
|
2022-11-28 18:19:50 +08:00
|
|
|
if plugin._.loaded then
|
2022-11-21 05:34:55 +08:00
|
|
|
ret.loaded = ret.loaded + 1
|
|
|
|
end
|
|
|
|
end
|
2022-11-21 05:33:47 +08:00
|
|
|
|
2022-11-21 05:34:55 +08:00
|
|
|
return ret
|
2022-11-21 05:33:47 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
return M
|