refactor: move core modules needed for loading under core

This commit is contained in:
Folke Lemaitre 2022-11-22 21:28:08 +01:00
parent 3218c2d9ec
commit fca984b18c
No known key found for this signature in database
GPG Key ID: 41F8B1FBACAE2040
12 changed files with 27 additions and 32 deletions

View File

@ -1,4 +1,4 @@
local Util = require("lazy.util")
local Util = require("lazy.core.util")
local M = {}

View File

@ -1,5 +1,5 @@
local Util = require("lazy.util")
local Config = require("lazy.config")
local Util = require("lazy.core.util")
local Config = require("lazy.core.config")
local M = {}

View File

@ -102,9 +102,9 @@ function M.setup()
-- preload core modules
local root = vim.fn.fnamemodify(debug.getinfo(1, "S").source:sub(2), ":p:h:h")
for _, name in ipairs({ "util", "config", "plugin", "loader", "core.state" }) do
local modname = "lazy." .. name
M.add(modname, root .. "/" .. name:gsub("%.", "/") .. ".lua")
for _, name in ipairs({ "util", "config", "loader", "state" }) do
local modname = "lazy.core." .. name
M.add(modname, root .. "/core/" .. name:gsub("%.", "/") .. ".lua")
end
table.insert(package.loaders, 2, function(modname)

View File

@ -7,13 +7,13 @@ M.functions = { "init", "config", "run" }
M.changed = true
function M.save()
local Config = require("lazy.config")
local Config = require("lazy.core.config")
---@class LazyState
local state = {
---@type LazyPlugin[]
plugins = {},
loaders = require("lazy.loader").loaders,
loaders = require("lazy.core.loader").loaders,
config = Config.options,
}
@ -61,8 +61,8 @@ function M.load()
return false
end
local Util = require("lazy.util")
local Config = require("lazy.config")
local Util = require("lazy.core.util")
local Config = require("lazy.core.config")
if not vim.deep_equal(Config.options, state.config) then
Cache.dirty()
@ -89,9 +89,7 @@ function M.load()
plugin.installed = installed[plugin.opt and "opt" or "start"][plugin.pack]
if plugin.modname then
-- mark module as used
if not Cache.get(plugin.modname) then
Util.error("Module missing for " .. plugin.name)
end
assert(Cache.get(plugin.modname))
for _, fun in ipairs(M.functions) do
if plugin[fun] == true then
plugin[fun] = function(...)
@ -102,10 +100,7 @@ function M.load()
else
for _, fun in ipairs(M.functions) do
if type(plugin[fun]) == "number" then
local chunk = Cache.get("cache.state.fun." .. plugin[fun])
if not chunk then
Util.error("Chunk missing for " .. plugin.name)
end
local chunk = assert(Cache.get("cache.state.fun." .. plugin[fun]))
plugin[fun] = function(...)
plugin[fun] = loadstring(chunk)
return plugin[fun](...)
@ -116,7 +111,7 @@ function M.load()
end
-- loaders
local Loader = require("lazy.loader")
local Loader = require("lazy.core.loader")
Loader.loaders = state.loaders
M.changed = false

View File

@ -19,9 +19,9 @@ function M.setup(opts)
local Module = require("lazy.core.module").setup()
local require_start = vim.loop.hrtime()
local Util = require("lazy.util")
local Config = require("lazy.config")
local Loader = require("lazy.loader")
local Util = require("lazy.core.util")
local Config = require("lazy.core.config")
local Loader = require("lazy.core.loader")
local State = require("lazy.core.state")
Util.track("cache.setup", module_start - cache_start)
@ -87,7 +87,7 @@ function M.stats()
loaded = 0,
}
for _, plugin in pairs(require("lazy.config").plugins) do
for _, plugin in pairs(require("lazy.core.config").plugins) do
ret.count = ret.count + 1
if plugin.loaded then

View File

@ -1,7 +1,7 @@
local Config = require("lazy.config")
local Config = require("lazy.core.config")
local Task = require("lazy.task")
local Runner = require("lazy.runner")
local Util = require("lazy.util")
local Util = require("lazy.core.util")
local M = {}

View File

@ -1,5 +1,5 @@
local Config = require("lazy.config")
local Util = require("lazy.util")
local Config = require("lazy.core.config")
local Util = require("lazy.core.util")
local Module = require("lazy.core.module")
local M = {}

View File

@ -1,6 +1,6 @@
local Process = require("lazy.process")
local Loader = require("lazy.loader")
local Util = require("lazy.util")
local Loader = require("lazy.core.loader")
local Util = require("lazy.core.util")
---@class LazyTask
---@field plugin LazyPlugin

View File

@ -1,4 +1,4 @@
local Util = require("lazy.util")
local Util = require("lazy.core.util")
local Render = require("lazy.view.render")
local M = {}

View File

@ -1,5 +1,5 @@
local Config = require("lazy.config")
local Util = require("lazy.util")
local Config = require("lazy.core.config")
local Util = require("lazy.core.util")
local Manager = require("lazy.manager")
local Sections = require("lazy.view.sections")

View File

@ -1,4 +1,4 @@
local Config = require("lazy.config")
local Config = require("lazy.core.config")
---@alias TextSegment {str: string, hl?:string, extmark?:table}