Files
zenbones-theme/lua/zenbones/util.lua

33 lines
891 B
Lua
Raw Normal View History

2021-09-21 16:47:35 +08:00
local M = {}
-- got from http://lua-users.org/wiki/StringInterpolation
function M.interp(s, tab)
return (s:gsub("($%b{})", function(w)
return tab[w:sub(3, -2)] or w
end))
end
2021-09-21 20:55:53 +08:00
function M.bg_to_base_name()
return vim.opt.background:get() == "light" and "zenbones" or "zenflesh"
end
local function write_template(path, template, values)
print("[write template] " .. path)
local content = M.interp(template, values)
local file = io.open(path, "w")
file:write(content)
file:close()
end
2021-09-21 21:21:42 +08:00
function M.build(name, specs, palette, terminal, options)
local exclude = options.exclude or {}
2021-10-03 09:28:37 +08:00
local templates = { "vim", "iterm", "kitty", "alacritty", "wezterm", "lualine", "lightline", "tmux" }
2021-09-21 20:55:53 +08:00
for _, t in ipairs(templates) do
2021-09-21 21:21:42 +08:00
if not vim.tbl_contains(exclude, t) then
write_template(unpack(require("zenbones.template." .. t)(name, specs, palette, terminal)))
end
2021-09-21 20:55:53 +08:00
end
end
2021-09-21 16:47:35 +08:00
return M