2022-11-20 21:33:47 +00:00
|
|
|
local M = {}
|
|
|
|
|
2022-12-01 12:33:55 +00:00
|
|
|
---@param spec LazySpec Should be a module name to load, or a plugin spec
|
2022-11-20 21:33:47 +00:00
|
|
|
---@param opts? LazyConfig
|
2022-12-01 12:33:55 +00:00
|
|
|
function M.setup(spec, opts)
|
2022-11-22 20:12:33 +00:00
|
|
|
local module_start = vim.loop.hrtime()
|
2022-11-24 21:04:23 +00:00
|
|
|
require("lazy.core.module").setup()
|
2022-11-22 20:28:08 +00:00
|
|
|
local Util = require("lazy.core.util")
|
|
|
|
local Config = require("lazy.core.config")
|
|
|
|
local Loader = require("lazy.core.loader")
|
2022-11-25 21:48:17 +00:00
|
|
|
local Plugin = require("lazy.core.plugin")
|
2022-11-20 21:33:47 +00:00
|
|
|
|
2022-11-26 20:29:40 +00:00
|
|
|
Util.track("module", vim.loop.hrtime() - module_start)
|
2022-11-21 20:50:16 +00:00
|
|
|
|
2022-11-22 20:12:33 +00:00
|
|
|
Util.track("setup")
|
2022-11-20 21:33:47 +00:00
|
|
|
|
2022-11-22 20:12:33 +00:00
|
|
|
Util.track("config")
|
2022-12-01 12:33:55 +00:00
|
|
|
Config.setup(spec, opts)
|
2022-11-20 21:34:55 +00:00
|
|
|
Util.track()
|
2022-11-20 21:33:47 +00:00
|
|
|
|
2022-11-25 21:48:17 +00:00
|
|
|
Plugin.load()
|
2022-11-20 21:33:47 +00:00
|
|
|
|
2022-12-01 10:06:44 +00:00
|
|
|
Util.track("loader")
|
|
|
|
Loader.setup()
|
2022-11-20 21:34:55 +00:00
|
|
|
Util.track()
|
2022-11-20 21:33:47 +00:00
|
|
|
|
2022-11-30 13:19:50 +00:00
|
|
|
local lazy_delta = vim.loop.hrtime() - module_start
|
2022-11-24 21:04:23 +00:00
|
|
|
|
2022-11-29 23:18:59 +00:00
|
|
|
Util.track() -- end setup
|
2022-11-30 13:19:50 +00:00
|
|
|
|
2022-11-20 21:34:55 +00:00
|
|
|
Loader.init_plugins()
|
2022-11-24 21:04:23 +00:00
|
|
|
|
2022-11-26 12:58:18 +00:00
|
|
|
if Config.plugins["lazy.nvim"] then
|
2022-11-28 10:19:50 +00:00
|
|
|
Config.plugins["lazy.nvim"]._.loaded.time = lazy_delta
|
2022-11-26 12:58:18 +00:00
|
|
|
end
|
2022-11-20 21:33:47 +00:00
|
|
|
|
2022-11-20 21:34:55 +00:00
|
|
|
vim.cmd("do User LazyDone")
|
2022-11-20 21:33:47 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function M.stats()
|
2022-11-29 23:18:59 +00:00
|
|
|
local ret = { count = 0, loaded = 0 }
|
2022-11-22 20:28:08 +00:00
|
|
|
for _, plugin in pairs(require("lazy.core.config").plugins) do
|
2022-11-20 21:34:55 +00:00
|
|
|
ret.count = ret.count + 1
|
2022-11-28 10:19:50 +00:00
|
|
|
if plugin._.loaded then
|
2022-11-20 21:34:55 +00:00
|
|
|
ret.loaded = ret.loaded + 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return ret
|
2022-11-20 21:33:47 +00:00
|
|
|
end
|
|
|
|
|
2022-11-29 11:49:15 +00:00
|
|
|
function M.bootstrap()
|
|
|
|
local lazypath = vim.fn.stdpath("data") .. "/site/pack/lazy/start/lazy.nvim"
|
|
|
|
if not vim.loop.fs_stat(lazypath) then
|
|
|
|
vim.fn.system({
|
|
|
|
"git",
|
|
|
|
"clone",
|
|
|
|
"--filter=blob:none",
|
|
|
|
"--single-branch",
|
|
|
|
"https://github.com/folke/lazy.nvim.git",
|
|
|
|
lazypath,
|
|
|
|
})
|
|
|
|
vim.opt.runtimepath:append(lazypath)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-11-20 21:33:47 +00:00
|
|
|
return M
|