django.nvim/lua/django/lazy.lua
2024-12-10 19:07:29 -03:00

17 lines
446 B
Lua

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