mirror of https://github.com/folke/lazy.nvim.git
perf: lazy require commands
This commit is contained in:
parent
0a07fa6cd7
commit
f0cfbf9952
|
@ -411,4 +411,17 @@ function M.merge(...)
|
|||
return ret
|
||||
end
|
||||
|
||||
function M.lazy_require(module)
|
||||
local mod = nil
|
||||
-- if already loaded, return the module
|
||||
-- otherwise return a lazy module
|
||||
return type(package.loaded[module]) == "table" and package.loaded[module]
|
||||
or setmetatable({}, {
|
||||
__index = function(_, key)
|
||||
mod = mod or require(module)
|
||||
return mod[key]
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
local require = require("lazy.core.util").lazy_require
|
||||
local View = require("lazy.view")
|
||||
local Manage = require("lazy.manage")
|
||||
local Util = require("lazy.util")
|
||||
|
|
Loading…
Reference in New Issue