lazy.nvim/lua/lazy/init.lua

71 lines
1.2 KiB
Lua
Raw Normal View History

2022-11-21 05:33:47 +08:00
local M = {}
---@param opts? LazyConfig
function M.setup(opts)
2022-11-21 05:34:55 +08:00
--FIXME: preload()
2022-11-21 05:33:47 +08:00
2022-11-21 05:34:55 +08:00
local Util = require("lazy.util")
local Config = require("lazy.config")
local Plugin = require("lazy.plugin")
2022-11-21 05:33:47 +08:00
2022-11-21 05:34:55 +08:00
Util.track("lazy_setup")
2022-11-21 05:33:47 +08:00
2022-11-21 05:34:55 +08:00
Util.track("lazy_config")
Config.setup(opts)
Util.track()
2022-11-21 05:33:47 +08:00
2022-11-21 05:34:55 +08:00
Util.track("plugin_normalize")
Plugin.normalize(Config.options.plugins)
if not Config.plugins.lazy then
Plugin.plugin({
"folke/lazy.nvim",
opt = false,
})
end
Util.track()
2022-11-21 05:33:47 +08:00
2022-11-21 05:34:55 +08:00
Util.track("plugin_process")
Plugin.process()
Util.track()
2022-11-21 05:33:47 +08:00
2022-11-21 05:34:55 +08:00
Util.track("lazy_install")
for _, plugin in pairs(Config.plugins) do
if not plugin.installed then
2022-11-21 07:27:28 +08:00
require("lazy.manager").install({
wait = true,
})
2022-11-21 05:34:55 +08:00
break
end
end
Util.track()
2022-11-21 05:33:47 +08:00
2022-11-21 05:34:55 +08:00
Util.track("loader_setup")
local Loader = require("lazy.loader")
Loader.setup()
Util.track()
2022-11-21 05:33:47 +08:00
2022-11-21 05:34:55 +08:00
Loader.init_plugins()
2022-11-21 05:33:47 +08:00
2022-11-21 05:34:55 +08:00
Util.track() -- end setup
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-21 05:34:55 +08:00
for _, plugin in pairs(require("lazy.config").plugins) do
ret.count = ret.count + 1
2022-11-21 05:33:47 +08:00
2022-11-21 05:34:55 +08:00
if plugin.loaded then
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