diff options
Diffstat (limited to 'lua/cmake/lazy.lua')
-rw-r--r-- | lua/cmake/lazy.lua | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lua/cmake/lazy.lua b/lua/cmake/lazy.lua new file mode 100644 index 0000000..7669dcd --- /dev/null +++ b/lua/cmake/lazy.lua @@ -0,0 +1,21 @@ +local lazy = {} + +--- Require on index. +--- +--- Will only require the module after the first index of a module. +--- Only works for modules that export a table. +---@param require_path string +---@return table +lazy.require = function(require_path) + return setmetatable({}, { + __index = function(_, key) + return require(require_path)[key] + end, + + __newindex = function(_, key, value) + require(require_path)[key] = value + end, + }) +end + +return lazy |