Files

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

97 lines
2.4 KiB
Lua
Raw Permalink Normal View History

2021-11-05 16:52:55 +08:00
local template = [[local common_fg = "$common_fg"
local inactive_bg = "$inactive_bg"
local inactive_fg = "$inactive_fg"
return {
normal = {
a = { bg = "$normal_a_bg", fg = common_fg, gui = "bold" },
b = { bg = "$normal_b_bg", fg = common_fg },
c = { bg = "$normal_c_bg", fg = "$normal_c_fg" },
},
insert = {
a = { bg = "$insert_a_bg", fg = common_fg, gui = "bold" },
},
command = {
a = { bg = "$command_a_bg", fg = common_fg, gui = "bold" },
},
visual = {
a = { bg = "$visual_a_bg", fg = common_fg, gui = "bold" },
},
replace = {
a = { bg = "$replace_a_bg", fg = common_fg, gui = "bold" },
},
inactive = {
a = { bg = inactive_bg, fg = inactive_fg, gui = "bold" },
b = { bg = inactive_bg, fg = inactive_fg },
c = { bg = inactive_bg, fg = inactive_fg },
},
2021-11-06 12:11:18 +08:00
}]]
2021-11-05 16:52:55 +08:00
local helpers = require "shipwright.transform.helpers"
local check_keys = {
"common_fg",
"inactive_bg",
"inactive_fg",
"normal_a_bg",
"normal_b_bg",
"normal_c_bg",
"normal_c_fg",
"insert_a_bg",
"command_a_bg",
"visual_a_bg",
"replace_a_bg",
}
2021-11-06 11:37:47 +08:00
local function to_lualine(colors)
2021-11-05 16:52:55 +08:00
for _, key in ipairs(check_keys) do
assert(colors[key], "lualine colors table missing key: " .. key)
end
local text = helpers.apply_template(template, colors)
2021-11-06 11:03:27 +08:00
return { text }
2021-11-05 16:52:55 +08:00
end
2021-12-02 19:17:42 +08:00
local function specs_to_colors(colorscheme)
local specs, background = unpack(colorscheme)
local da = background == "light" and -3 or 3
2021-11-05 16:52:55 +08:00
return {
2021-11-06 11:03:27 +08:00
common_fg = specs.Folded.fg,
inactive_bg = specs.StatusLineNC.bg,
inactive_fg = specs.StatusLineNC.fg,
2021-12-02 19:17:42 +08:00
normal_a_bg = specs.PmenuSbar.bg.abs_da(da),
normal_b_bg = specs.PmenuSel.bg.abs_da(da),
normal_c_bg = specs.StatusLine.bg.abs_da(da),
2021-11-06 11:03:27 +08:00
normal_c_fg = specs.StatusLine.fg,
insert_a_bg = specs.DiffText.bg,
command_a_bg = specs.Search.bg,
visual_a_bg = specs.Visual.bg,
replace_a_bg = specs.DiffDelete.bg,
2021-11-05 16:52:55 +08:00
}
end
2021-12-02 16:58:47 +08:00
local ness_list = { "dim", "bright", "stark", "warm", "default" }
2021-12-02 16:57:07 +08:00
for _, ness in ipairs(ness_list) do
2021-12-02 16:58:47 +08:00
local specs_name = ness ~= "default" and "specs_" .. ness or "specs"
2021-12-02 16:57:07 +08:00
local specs = getfenv()[specs_name]
if specs then
---@diagnostic disable: undefined-global
-- selene: allow(undefined_variable)
run(
2021-12-02 19:17:42 +08:00
{ specs, background },
2021-12-02 16:57:07 +08:00
specs_to_colors,
to_lualine,
{ prepend, "-- This file is auto-generated by shipwright.nvim" },
2021-12-02 16:58:47 +08:00
{ overwrite, string.format("lua/lualine/themes/%s_%s.lua", name, ness) }
2021-12-02 16:57:07 +08:00
)
-- selene: deny(undefined_variable)
---@diagnostic enable: undefined-global
end
end