2021-09-04 13:14:01 +08:00
|
|
|
local lush = require "lush"
|
|
|
|
|
local theme = require "zenbones"
|
2021-09-04 15:42:35 +08:00
|
|
|
local terminal = require "zenbones.terminal"
|
2021-09-04 13:14:01 +08:00
|
|
|
|
2021-09-04 14:57:37 +08:00
|
|
|
-- got from http://lua-users.org/wiki/StringInterpolation
|
|
|
|
|
function interp(s, tab)
|
|
|
|
|
return (s:gsub("($%b{})", function(w)
|
|
|
|
|
return tab[w:sub(3, -2)] or w
|
|
|
|
|
end))
|
|
|
|
|
end
|
2021-09-04 13:14:01 +08:00
|
|
|
|
2021-09-04 14:57:37 +08:00
|
|
|
local function write_template(path, spec)
|
|
|
|
|
print("[write template] " .. path)
|
2021-09-04 15:42:35 +08:00
|
|
|
local template = io.open("_templates/" .. path .. ".txt", "r"):read "*all"
|
2021-09-04 14:57:37 +08:00
|
|
|
local content = interp(template, spec)
|
|
|
|
|
local file = io.open(path, "w")
|
|
|
|
|
file:write(content)
|
|
|
|
|
file:close()
|
|
|
|
|
end
|
2021-09-04 13:14:01 +08:00
|
|
|
|
|
|
|
|
local function viml_build()
|
|
|
|
|
local termcolors = ""
|
|
|
|
|
for i, v in ipairs(require("zenbones.terminal").colors) do
|
|
|
|
|
termcolors = termcolors .. string.format("let g:terminal_color_%s = '%s'\n", (i - 1), v.hex)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- Compile lush table, concatenate to a single string, and remove blend property
|
|
|
|
|
local vimcolors = table.concat(vim.fn.sort(lush.compile(theme, { exclude_keys = { "blend" } })), "\n")
|
2021-09-04 14:57:37 +08:00
|
|
|
write_template("colors/zenbones.vim", {
|
|
|
|
|
termcolors = termcolors,
|
2021-09-04 15:42:35 +08:00
|
|
|
vimcolors = vimcolors,
|
2021-09-04 14:57:37 +08:00
|
|
|
})
|
2021-09-04 13:14:01 +08:00
|
|
|
end
|
|
|
|
|
|
2021-09-04 15:42:35 +08:00
|
|
|
local function kitty_build()
|
|
|
|
|
local bg = theme.Normal.bg.hex
|
|
|
|
|
local fg = theme.Normal.fg.hex
|
|
|
|
|
local specs = {
|
|
|
|
|
background = bg,
|
|
|
|
|
foreground = fg,
|
|
|
|
|
selection_background = theme.Visual.bg.hex,
|
|
|
|
|
selection_foreground = fg,
|
|
|
|
|
url_color = terminal.colors[14].hex,
|
|
|
|
|
cursor = fg,
|
|
|
|
|
active_tab_background = theme.Search.bg.hex,
|
|
|
|
|
active_tab_foreground = fg,
|
|
|
|
|
inactive_tab_background = theme.StatusLine.bg.hex,
|
|
|
|
|
inactive_tab_foreground = fg,
|
|
|
|
|
}
|
|
|
|
|
for i, v in ipairs(terminal.colors) do
|
|
|
|
|
specs["color" .. (i - 1)] = v.hex
|
|
|
|
|
end
|
|
|
|
|
write_template("extras/kitty/zenbones.conf", specs)
|
|
|
|
|
end
|
|
|
|
|
|
2021-09-04 13:14:01 +08:00
|
|
|
local function build()
|
|
|
|
|
viml_build()
|
2021-09-04 15:42:35 +08:00
|
|
|
kitty_build()
|
2021-09-04 13:14:01 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return { build = build }
|