lualine.nvim/lua/lualine/utils/lazy_require.lua
shadmansaleh 0126ac0cc0 perf: lazy load modules and dalay config loading till status redraw
This should make require'lualine' less expensive and make lualine
have less impact in startuptime
2021-08-16 23:40:27 +06:00

14 lines
382 B
Lua

return function(modules)
return setmetatable({}, {
__index = function(self, key)
local loaded = rawget(self, key)
if loaded ~= nil then return loaded end
local module_location = modules[key]
if module_location == nil then return nil end
local module = require(module_location)
rawset(self, key, module)
return module
end
})
end