Skip to content

Commit fca984b

Browse files
committed
refactor: move core modules needed for loading under core
1 parent 3218c2d commit fca984b

File tree

12 files changed

+27
-32
lines changed

12 files changed

+27
-32
lines changed

lua/lazy/config.lua lua/lazy/core/config.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
local Util = require("lazy.util")
1+
local Util = require("lazy.core.util")
22

33
local M = {}
44

lua/lazy/loader.lua lua/lazy/core/loader.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
local Util = require("lazy.util")
2-
local Config = require("lazy.config")
1+
local Util = require("lazy.core.util")
2+
local Config = require("lazy.core.config")
33

44
local M = {}
55

lua/lazy/core/module.lua

+3-3
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ function M.setup()
102102

103103
-- preload core modules
104104
local root = vim.fn.fnamemodify(debug.getinfo(1, "S").source:sub(2), ":p:h:h")
105-
for _, name in ipairs({ "util", "config", "plugin", "loader", "core.state" }) do
106-
local modname = "lazy." .. name
107-
M.add(modname, root .. "/" .. name:gsub("%.", "/") .. ".lua")
105+
for _, name in ipairs({ "util", "config", "loader", "state" }) do
106+
local modname = "lazy.core." .. name
107+
M.add(modname, root .. "/core/" .. name:gsub("%.", "/") .. ".lua")
108108
end
109109

110110
table.insert(package.loaders, 2, function(modname)

lua/lazy/core/state.lua

+7-12
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ M.functions = { "init", "config", "run" }
77
M.changed = true
88

99
function M.save()
10-
local Config = require("lazy.config")
10+
local Config = require("lazy.core.config")
1111

1212
---@class LazyState
1313
local state = {
1414
---@type LazyPlugin[]
1515
plugins = {},
16-
loaders = require("lazy.loader").loaders,
16+
loaders = require("lazy.core.loader").loaders,
1717
config = Config.options,
1818
}
1919

@@ -61,8 +61,8 @@ function M.load()
6161
return false
6262
end
6363

64-
local Util = require("lazy.util")
65-
local Config = require("lazy.config")
64+
local Util = require("lazy.core.util")
65+
local Config = require("lazy.core.config")
6666

6767
if not vim.deep_equal(Config.options, state.config) then
6868
Cache.dirty()
@@ -89,9 +89,7 @@ function M.load()
8989
plugin.installed = installed[plugin.opt and "opt" or "start"][plugin.pack]
9090
if plugin.modname then
9191
-- mark module as used
92-
if not Cache.get(plugin.modname) then
93-
Util.error("Module missing for " .. plugin.name)
94-
end
92+
assert(Cache.get(plugin.modname))
9593
for _, fun in ipairs(M.functions) do
9694
if plugin[fun] == true then
9795
plugin[fun] = function(...)
@@ -102,10 +100,7 @@ function M.load()
102100
else
103101
for _, fun in ipairs(M.functions) do
104102
if type(plugin[fun]) == "number" then
105-
local chunk = Cache.get("cache.state.fun." .. plugin[fun])
106-
if not chunk then
107-
Util.error("Chunk missing for " .. plugin.name)
108-
end
103+
local chunk = assert(Cache.get("cache.state.fun." .. plugin[fun]))
109104
plugin[fun] = function(...)
110105
plugin[fun] = loadstring(chunk)
111106
return plugin[fun](...)
@@ -116,7 +111,7 @@ function M.load()
116111
end
117112

118113
-- loaders
119-
local Loader = require("lazy.loader")
114+
local Loader = require("lazy.core.loader")
120115
Loader.loaders = state.loaders
121116

122117
M.changed = false
File renamed without changes.

lua/lazy/init.lua

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ function M.setup(opts)
1919
local Module = require("lazy.core.module").setup()
2020

2121
local require_start = vim.loop.hrtime()
22-
local Util = require("lazy.util")
23-
local Config = require("lazy.config")
24-
local Loader = require("lazy.loader")
22+
local Util = require("lazy.core.util")
23+
local Config = require("lazy.core.config")
24+
local Loader = require("lazy.core.loader")
2525
local State = require("lazy.core.state")
2626

2727
Util.track("cache.setup", module_start - cache_start)
@@ -87,7 +87,7 @@ function M.stats()
8787
loaded = 0,
8888
}
8989

90-
for _, plugin in pairs(require("lazy.config").plugins) do
90+
for _, plugin in pairs(require("lazy.core.config").plugins) do
9191
ret.count = ret.count + 1
9292

9393
if plugin.loaded then

lua/lazy/manager.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
local Config = require("lazy.config")
1+
local Config = require("lazy.core.config")
22
local Task = require("lazy.task")
33
local Runner = require("lazy.runner")
4-
local Util = require("lazy.util")
4+
local Util = require("lazy.core.util")
55

66
local M = {}
77

lua/lazy/plugin.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
local Config = require("lazy.config")
2-
local Util = require("lazy.util")
1+
local Config = require("lazy.core.config")
2+
local Util = require("lazy.core.util")
33
local Module = require("lazy.core.module")
44

55
local M = {}

lua/lazy/task.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
local Process = require("lazy.process")
2-
local Loader = require("lazy.loader")
3-
local Util = require("lazy.util")
2+
local Loader = require("lazy.core.loader")
3+
local Util = require("lazy.core.util")
44

55
---@class LazyTask
66
---@field plugin LazyPlugin

lua/lazy/view/init.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
local Util = require("lazy.util")
1+
local Util = require("lazy.core.util")
22
local Render = require("lazy.view.render")
33

44
local M = {}

lua/lazy/view/render.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
local Config = require("lazy.config")
2-
local Util = require("lazy.util")
1+
local Config = require("lazy.core.config")
2+
local Util = require("lazy.core.util")
33
local Manager = require("lazy.manager")
44
local Sections = require("lazy.view.sections")
55

lua/lazy/view/text.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
local Config = require("lazy.config")
1+
local Config = require("lazy.core.config")
22

33
---@alias TextSegment {str: string, hl?:string, extmark?:table}
44

0 commit comments

Comments
 (0)