2021-11-05 14:43:28 +08:00
|
|
|
local M = {}
|
|
|
|
|
|
2021-12-02 16:44:18 +08:00
|
|
|
local function make_specs(specs_name, ness)
|
2022-10-22 09:32:57 +08:00
|
|
|
local background = vim.o.background
|
2021-12-02 16:44:18 +08:00
|
|
|
package.loaded[specs_name] = nil
|
|
|
|
|
if ness == nil then
|
|
|
|
|
return require(specs_name)
|
|
|
|
|
end
|
|
|
|
|
vim.g[specs_name .. "_" .. background .. "ness"] = ness
|
|
|
|
|
local specs = require(specs_name)
|
|
|
|
|
vim.g[specs_name .. "_" .. background .. "ness"] = nil
|
|
|
|
|
return specs
|
|
|
|
|
end
|
2021-11-06 11:36:59 +08:00
|
|
|
|
2021-12-02 16:44:18 +08:00
|
|
|
local function make_env(colorscheme)
|
|
|
|
|
local specs_name = colorscheme.specs
|
2021-11-06 11:36:59 +08:00
|
|
|
local builder = require "shipwright.builder"
|
2021-12-02 16:44:18 +08:00
|
|
|
local p = require(specs_name .. ".palette")[colorscheme.background]
|
|
|
|
|
local env = {
|
2021-11-06 11:36:59 +08:00
|
|
|
name = colorscheme.name,
|
2021-12-02 16:44:18 +08:00
|
|
|
specs_name = specs_name,
|
2021-11-06 11:36:59 +08:00
|
|
|
p = p,
|
2021-11-11 15:08:32 +08:00
|
|
|
background = colorscheme.background,
|
2021-11-14 14:12:06 +08:00
|
|
|
description = colorscheme.description,
|
2021-11-06 11:36:59 +08:00
|
|
|
term = require("zenbones.term").colors_map(p),
|
|
|
|
|
transform = require "zenbones.shipwright.transform",
|
|
|
|
|
}
|
2021-12-02 16:44:18 +08:00
|
|
|
|
2022-10-22 09:32:57 +08:00
|
|
|
vim.o.background = colorscheme.background
|
2021-12-02 16:44:18 +08:00
|
|
|
env.specs = make_specs(specs_name)
|
|
|
|
|
local ness = colorscheme.background == "light" and { "dim", "bright" } or { "stark", "warm" }
|
|
|
|
|
env["specs_" .. ness[1]] = make_specs(specs_name, ness[1])
|
|
|
|
|
env["specs_" .. ness[2]] = make_specs(specs_name, ness[2])
|
|
|
|
|
|
|
|
|
|
return builder.make_env(env)
|
2021-11-05 14:43:28 +08:00
|
|
|
end
|
|
|
|
|
|
2021-11-05 15:14:42 +08:00
|
|
|
local function make_build_fn(file)
|
|
|
|
|
return loadfile(string.format("lua/zenbones/shipwright/runners/%s.lua", file))
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local function make_runners(config)
|
|
|
|
|
if not config.background then
|
|
|
|
|
return {
|
|
|
|
|
setfenv(
|
|
|
|
|
make_build_fn(config.file),
|
|
|
|
|
make_env {
|
|
|
|
|
name = config.name .. "_light",
|
|
|
|
|
specs = config.name,
|
|
|
|
|
background = "light",
|
2021-11-14 14:12:06 +08:00
|
|
|
description = config.description,
|
2021-11-05 15:14:42 +08:00
|
|
|
}
|
|
|
|
|
),
|
|
|
|
|
setfenv(
|
|
|
|
|
make_build_fn(config.file),
|
|
|
|
|
make_env {
|
|
|
|
|
name = config.name .. "_dark",
|
|
|
|
|
specs = config.name,
|
|
|
|
|
background = "dark",
|
2021-11-14 14:12:06 +08:00
|
|
|
description = config.description,
|
2021-11-05 15:14:42 +08:00
|
|
|
}
|
|
|
|
|
),
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
setfenv(
|
|
|
|
|
make_build_fn(config.file),
|
2021-11-05 14:43:28 +08:00
|
|
|
make_env {
|
2021-11-05 15:14:42 +08:00
|
|
|
name = config.name,
|
|
|
|
|
specs = config.name,
|
|
|
|
|
background = config.background,
|
2021-11-14 14:12:06 +08:00
|
|
|
description = config.description,
|
2021-11-05 14:43:28 +08:00
|
|
|
}
|
2021-11-05 15:14:42 +08:00
|
|
|
),
|
|
|
|
|
}
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
M.run = function()
|
2021-12-28 07:06:48 +08:00
|
|
|
local runner_files = {
|
|
|
|
|
"vim",
|
|
|
|
|
"iterm",
|
|
|
|
|
"alacritty",
|
|
|
|
|
"kitty",
|
2025-12-01 15:27:32 +01:00
|
|
|
"ghostty",
|
2021-12-28 07:06:48 +08:00
|
|
|
"wezterm",
|
|
|
|
|
"tmux",
|
|
|
|
|
"windows_terminal",
|
2021-12-30 21:33:14 +01:00
|
|
|
"foot",
|
2021-12-28 07:06:48 +08:00
|
|
|
"lualine",
|
|
|
|
|
"lightline",
|
|
|
|
|
}
|
2021-12-04 08:57:11 +08:00
|
|
|
local colorschemes = vim.fn.json_decode(vim.fn.readfile "zenbones.json")
|
2021-11-05 15:14:42 +08:00
|
|
|
for _, colorscheme in ipairs(colorschemes) do
|
|
|
|
|
for _, file in ipairs(runner_files) do
|
2021-11-06 12:13:13 +08:00
|
|
|
if not vim.tbl_contains(colorscheme.exclude or {}, file) then
|
|
|
|
|
colorscheme.file = file
|
|
|
|
|
for _, runner in ipairs(make_runners(colorscheme)) do
|
|
|
|
|
assert(pcall(runner))
|
|
|
|
|
end
|
2021-11-05 15:14:42 +08:00
|
|
|
end
|
|
|
|
|
end
|
2021-11-05 14:43:28 +08:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return M
|