Trans.nvim/lua/Trans/init.lua

26 lines
584 B
Lua
Raw Normal View History

---Set or Get metatable which will find module in folder
---@param folder_name string
---@param origin table?
---@return table
local function metatable(folder_name, origin)
return setmetatable(origin or {}, {
__index = function(tbl, key)
local status, result = pcall(require, ('Trans.%s.%s'):format(folder_name, key))
if not status then return end
tbl[key] = result
return result
end
})
end
2023-03-13 19:50:28 +08:00
local M = metatable('core')
M.metatable = metatable
M.style = metatable("style")
2023-03-13 19:50:28 +08:00
M.cache = {}
2022-12-17 16:07:27 +08:00
return M