lazy.nvim/lua/lazy/init.lua

71 lines
1.2 KiB
Lua
Raw Normal View History

2022-11-20 21:33:47 +00:00
local M = {}
---@param opts? LazyConfig
function M.setup(opts)
2022-11-20 21:34:55 +00:00
--FIXME: preload()
2022-11-20 21:33:47 +00:00
2022-11-20 21:34:55 +00:00
local Util = require("lazy.util")
local Config = require("lazy.config")
local Plugin = require("lazy.plugin")
2022-11-20 21:33:47 +00:00
2022-11-20 21:34:55 +00:00
Util.track("lazy_setup")
2022-11-20 21:33:47 +00:00
2022-11-20 21:34:55 +00:00
Util.track("lazy_config")
Config.setup(opts)
Util.track()
2022-11-20 21:33:47 +00:00
2022-11-20 21:34:55 +00: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-20 21:33:47 +00:00
2022-11-20 21:34:55 +00:00
Util.track("plugin_process")
Plugin.process()
Util.track()
2022-11-20 21:33:47 +00:00
2022-11-20 21:34:55 +00:00
Util.track("lazy_install")
for _, plugin in pairs(Config.plugins) do
if not plugin.installed then
-- require("lazy.manager").install({
-- wait = true,
-- })
break
end
end
Util.track()
2022-11-20 21:33:47 +00:00
2022-11-20 21:34:55 +00:00
Util.track("loader_setup")
local Loader = require("lazy.loader")
Loader.setup()
Util.track()
2022-11-20 21:33:47 +00:00
2022-11-20 21:34:55 +00:00
Loader.init_plugins()
2022-11-20 21:33:47 +00:00
2022-11-20 21:34:55 +00:00
Util.track() -- end setup
vim.cmd("do User LazyDone")
2022-11-20 21:33:47 +00:00
end
function M.stats()
2022-11-20 21:34:55 +00:00
local ret = {
count = 0,
loaded = 0,
}
2022-11-20 21:33:47 +00:00
2022-11-20 21:34:55 +00:00
for _, plugin in pairs(require("lazy.config").plugins) do
ret.count = ret.count + 1
2022-11-20 21:33:47 +00:00
2022-11-20 21:34:55 +00:00
if plugin.loaded then
ret.loaded = ret.loaded + 1
end
end
2022-11-20 21:33:47 +00:00
2022-11-20 21:34:55 +00:00
return ret
2022-11-20 21:33:47 +00:00
end
return M