Files
zenbones-theme/lua/zenbones/specs/init.lua

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

75 lines
1.6 KiB
Lua
Raw Normal View History

2021-10-28 18:24:46 +08:00
local function concat_config(prefix, suffixes)
2021-10-26 18:21:21 +08:00
local config = {}
2021-11-03 15:59:41 +08:00
for _, suffix in ipairs(suffixes) do
2021-10-26 18:21:21 +08:00
config[suffix] = vim.g[prefix .. "_" .. suffix]
end
return config
end
2021-11-08 17:47:14 +08:00
local M = {}
--- Get global configuration as a table.
---@param prefix string e.g. "zenbones"
---@param base_bg string light or dark
function M.get_global_config(prefix, base_bg)
2021-10-27 16:49:45 +08:00
if type(vim.g[prefix]) == "table" then
return vim.g[prefix]
end
2021-10-26 18:21:21 +08:00
local common = concat_config(prefix, {
"solid_vert_split",
"solid_float_border",
"solid_line_nr",
"italic_comments",
2021-11-03 15:59:41 +08:00
"transparent_background",
2021-10-26 18:21:21 +08:00
})
if base_bg == "light" then
if vim.g[prefix .. "_dim_noncurrent_window"] then
vim.notify(
prefix .. "_dim_noncurrent_window is replaced by " .. prefix .. "_darken_noncurrent_window",
2021-11-01 10:11:37 +08:00
vim.log.levels.WARN,
{ title = "zenbones" }
)
end
2021-10-26 18:21:21 +08:00
return vim.tbl_extend(
"keep",
concat_config(prefix, {
"lightness",
"darken_noncurrent_window",
"darken_comments",
"darken_line_nr",
"darken_non_text",
2021-11-03 16:16:52 +08:00
"darken_cursor_line",
2021-10-26 18:21:21 +08:00
}),
common
)
elseif base_bg == "dark" then
2021-10-26 18:21:21 +08:00
return vim.tbl_extend(
"keep",
concat_config(prefix, {
"darkness",
"lighten_noncurrent_window",
"lighten_comments",
"lighten_line_nr",
"lighten_non_text",
2021-11-03 16:16:52 +08:00
"lighten_cursor_line",
2021-10-26 18:21:21 +08:00
}),
common
)
else
error(string.format([[Invalid base_bg value: '%s', must be 'light' or 'dark'.]], base_bg))
end
end
2021-11-08 17:47:14 +08:00
--- Generate a specs given a palette.
---@param p table palette
---@param base_bg string light or dark
---@param opt? table
---@return table
function M.generate(p, base_bg, opt)
return require("zenbones.specs." .. base_bg)(p, opt)
end
return M