diff options
Diffstat (limited to 'lua/lvim/utils/modules.lua')
| -rw-r--r-- | lua/lvim/utils/modules.lua | 24 | 
1 files changed, 24 insertions, 0 deletions
| diff --git a/lua/lvim/utils/modules.lua b/lua/lvim/utils/modules.lua index d5674483..45cacfa3 100644 --- a/lua/lvim/utils/modules.lua +++ b/lua/lvim/utils/modules.lua @@ -95,4 +95,28 @@ M.reload = function(mod)    return old  end +-- code from <https://github.com/tjdevries/lazy-require.nvim/blob/bb626818ebc175b8c595846925fd96902b1ce02b/lua/lazy-require.lua#L25> +function M.require_on_index(require_path) +  return setmetatable({}, { +    __index = function(_, key) +      return require(require_path)[key] +    end, + +    __newindex = function(_, key, value) +      require(require_path)[key] = value +    end, +  }) +end + +-- code from <https://github.com/tjdevries/lazy-require.nvim/blob/bb626818ebc175b8c595846925fd96902b1ce02b/lua/lazy-require.lua#L25> +function M.require_on_exported_call(require_path) +  return setmetatable({}, { +    __index = function(_, k) +      return function(...) +        return require(require_path)[k](...) +      end +    end, +  }) +end +  return M | 
