style: added more comments to init

This commit is contained in:
Folke Lemaitre 2022-12-01 16:37:50 +01:00
parent ac9e5401dc
commit e22e8e4506
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
2 changed files with 15 additions and 9 deletions

View File

@ -28,6 +28,7 @@ function M.setup()
end end
function M.init_plugins() function M.init_plugins()
Util.track("loader")
Util.track({ start = "init" }) Util.track({ start = "init" })
for _, plugin in pairs(Config.plugins) do for _, plugin in pairs(Config.plugins) do
if plugin.init then if plugin.init then
@ -40,6 +41,7 @@ function M.init_plugins()
end end
end end
Util.track() Util.track()
Util.track()
end end
---@class Loader ---@class Loader

View File

@ -4,35 +4,39 @@ local M = {}
---@param opts? LazyConfig ---@param opts? LazyConfig
function M.setup(spec, opts) function M.setup(spec, opts)
local start = vim.loop.hrtime() local start = vim.loop.hrtime()
-- load module cache before anything else
require("lazy.core.module").setup() require("lazy.core.module").setup()
local Util = require("lazy.core.util") local Util = require("lazy.core.util")
local Config = require("lazy.core.config") local Config = require("lazy.core.config")
local Loader = require("lazy.core.loader") local Loader = require("lazy.core.loader")
local Plugin = require("lazy.core.plugin") local Plugin = require("lazy.core.plugin")
Util.track({ plugin = "lazy.nvim" }) Util.track({ plugin = "lazy.nvim" }) -- setup start
Util.track("module", vim.loop.hrtime() - start) Util.track("module", vim.loop.hrtime() - start)
-- load config
Util.track("config") Util.track("config")
Config.setup(spec, opts) Config.setup(spec, opts)
Util.track() Util.track()
-- load the plugins
Plugin.load() Plugin.load()
Util.track("loader") -- setup loader and handlers
Loader.setup() Loader.setup()
Util.track()
-- correct time delta and loaded
local delta = vim.loop.hrtime() - start local delta = vim.loop.hrtime() - start
Util.track().time = delta -- end setup Util.track().time = delta -- end setup
Loader.init_plugins()
if Config.plugins["lazy.nvim"] then if Config.plugins["lazy.nvim"] then
Config.plugins["lazy.nvim"]._.loaded = { time = delta, source = "init.lua" } Config.plugins["lazy.nvim"]._.loaded = { time = delta, source = "init.lua" }
end end
-- load plugins with lazy=false or Plugin.init
Loader.init_plugins()
-- all done!
vim.cmd("do User LazyDone") vim.cmd("do User LazyDone")
end end
@ -48,7 +52,7 @@ function M.stats()
end end
function M.bootstrap() function M.bootstrap()
local lazypath = vim.fn.stdpath("data") .. "/site/pack/lazy/start/lazy.nvim" local lazypath = vim.fn.stdpath("data") .. "/site/pack/lazy/opt/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then if not vim.loop.fs_stat(lazypath) then
vim.fn.system({ vim.fn.system({
"git", "git",