local M = {} ---@param tbl table ---@param path string local function get_nested_value(tbl, path) for key in string.gmatch(path, "[^%.]+") do if tbl and tbl[key] then tbl = tbl[key] else return nil end end return tbl end ---@param str string ---@param tbl table ---@return string function M.template(str, tbl) return ( string.gsub(str, "${(.-)}", function(path) local value = get_nested_value(tbl, path) return value and tostring(value) or "${" .. path .. "}" end) ) end ---@param name string filename to save extra ---@param contents string file contents (extra theme) function M.write(name, contents) print("writing extra/" .. name) vim.fn.mkdir(vim.fs.dirname("extras/" .. name), "p") local file = io.open("extras/" .. name, "w") if file then file:write(contents) file:close() end end return M