diff --git a/lua/lazy/config.lua b/lua/lazy/core/config.lua similarity index 94% rename from lua/lazy/config.lua rename to lua/lazy/core/config.lua index 4936151..e23d6cd 100644 --- a/lua/lazy/config.lua +++ b/lua/lazy/core/config.lua @@ -1,4 +1,4 @@ -local Util = require("lazy.util") +local Util = require("lazy.core.util") local M = {} diff --git a/lua/lazy/loader.lua b/lua/lazy/core/loader.lua similarity index 98% rename from lua/lazy/loader.lua rename to lua/lazy/core/loader.lua index dce014c..f0abc57 100644 --- a/lua/lazy/loader.lua +++ b/lua/lazy/core/loader.lua @@ -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 = {} diff --git a/lua/lazy/core/module.lua b/lua/lazy/core/module.lua index 28853d2..05439e6 100644 --- a/lua/lazy/core/module.lua +++ b/lua/lazy/core/module.lua @@ -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) diff --git a/lua/lazy/core/state.lua b/lua/lazy/core/state.lua index 8e60bc5..9b0b4a1 100644 --- a/lua/lazy/core/state.lua +++ b/lua/lazy/core/state.lua @@ -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 diff --git a/lua/lazy/util.lua b/lua/lazy/core/util.lua similarity index 100% rename from lua/lazy/util.lua rename to lua/lazy/core/util.lua diff --git a/lua/lazy/init.lua b/lua/lazy/init.lua index 22b920b..5bc63d1 100644 --- a/lua/lazy/init.lua +++ b/lua/lazy/init.lua @@ -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 diff --git a/lua/lazy/manager.lua b/lua/lazy/manager.lua index 05f1cd5..59ffae6 100644 --- a/lua/lazy/manager.lua +++ b/lua/lazy/manager.lua @@ -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 = {} diff --git a/lua/lazy/plugin.lua b/lua/lazy/plugin.lua index 4fa533e..5fbe39e 100644 --- a/lua/lazy/plugin.lua +++ b/lua/lazy/plugin.lua @@ -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 = {} diff --git a/lua/lazy/task.lua b/lua/lazy/task.lua index 8b9d4b1..eeda669 100644 --- a/lua/lazy/task.lua +++ b/lua/lazy/task.lua @@ -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 diff --git a/lua/lazy/view/init.lua b/lua/lazy/view/init.lua index fef5162..aea59c8 100644 --- a/lua/lazy/view/init.lua +++ b/lua/lazy/view/init.lua @@ -1,4 +1,4 @@ -local Util = require("lazy.util") +local Util = require("lazy.core.util") local Render = require("lazy.view.render") local M = {} diff --git a/lua/lazy/view/render.lua b/lua/lazy/view/render.lua index 272c615..a62a309 100644 --- a/lua/lazy/view/render.lua +++ b/lua/lazy/view/render.lua @@ -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") diff --git a/lua/lazy/view/text.lua b/lua/lazy/view/text.lua index e4df4cb..fed3d13 100644 --- a/lua/lazy/view/text.lua +++ b/lua/lazy/view/text.lua @@ -1,4 +1,4 @@ -local Config = require("lazy.config") +local Config = require("lazy.core.config") ---@alias TextSegment {str: string, hl?:string, extmark?:table}