2021-11-06 12:04:23 +08:00
|
|
|
local function to_vim_autoload(colorscheme)
|
2021-11-11 15:08:32 +08:00
|
|
|
local vimcolors, term = unpack(colorscheme)
|
2021-11-06 11:37:55 +08:00
|
|
|
local termcolors = ""
|
|
|
|
|
for i, v in ipairs(term) do
|
2021-11-08 17:26:17 +08:00
|
|
|
termcolors = termcolors .. string.format("let g:terminal_color_%s = '%s'\n", (i - 1), v)
|
2021-11-06 11:37:55 +08:00
|
|
|
end
|
|
|
|
|
|
2021-11-11 15:08:32 +08:00
|
|
|
termcolors = {
|
2021-11-08 17:26:17 +08:00
|
|
|
string.format("let g:terminal_color_0 = '%s'", term.black),
|
|
|
|
|
string.format("let g:terminal_color_1 = '%s'", term.red),
|
|
|
|
|
string.format("let g:terminal_color_2 = '%s'", term.green),
|
|
|
|
|
string.format("let g:terminal_color_3 = '%s'", term.yellow),
|
|
|
|
|
string.format("let g:terminal_color_4 = '%s'", term.blue),
|
|
|
|
|
string.format("let g:terminal_color_5 = '%s'", term.magenta),
|
|
|
|
|
string.format("let g:terminal_color_6 = '%s'", term.cyan),
|
|
|
|
|
string.format("let g:terminal_color_7 = '%s'", term.white),
|
|
|
|
|
string.format("let g:terminal_color_8 = '%s'", term.bright_black),
|
|
|
|
|
string.format("let g:terminal_color_9 = '%s'", term.bright_red),
|
|
|
|
|
string.format("let g:terminal_color_10 = '%s'", term.bright_green),
|
|
|
|
|
string.format("let g:terminal_color_11 = '%s'", term.bright_yellow),
|
|
|
|
|
string.format("let g:terminal_color_12 = '%s'", term.bright_blue),
|
|
|
|
|
string.format("let g:terminal_color_13 = '%s'", term.bright_magenta),
|
|
|
|
|
string.format("let g:terminal_color_14 = '%s'", term.bright_cyan),
|
|
|
|
|
string.format("let g:terminal_color_15 = '%s'", term.bright_white),
|
2021-11-11 15:08:32 +08:00
|
|
|
}
|
2021-11-08 17:26:17 +08:00
|
|
|
|
2021-11-11 15:08:32 +08:00
|
|
|
return vim.list_extend(termcolors, vimcolors)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local function left_pad(lines, length)
|
|
|
|
|
local padded_lines = {}
|
|
|
|
|
for _, line in ipairs(lines) do
|
|
|
|
|
line = table.insert(padded_lines, string.rep(" ", length) .. line)
|
|
|
|
|
end
|
|
|
|
|
return padded_lines
|
2021-11-06 11:37:55 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local lushwright = require "shipwright.transform.lush"
|
|
|
|
|
|
2021-11-07 08:16:33 +08:00
|
|
|
---@diagnostic disable: undefined-global
|
2021-11-06 12:04:23 +08:00
|
|
|
-- selene: allow(undefined_variable)
|
2021-11-06 11:37:55 +08:00
|
|
|
run(
|
|
|
|
|
specs,
|
|
|
|
|
lushwright.to_vimscript,
|
|
|
|
|
lushwright.vim_compatible_vimscript,
|
2021-11-06 12:04:23 +08:00
|
|
|
function(vimcolors)
|
2021-11-11 15:08:32 +08:00
|
|
|
return { vimcolors, term }
|
2021-11-06 12:04:23 +08:00
|
|
|
end,
|
2021-11-06 11:37:55 +08:00
|
|
|
to_vim_autoload,
|
2021-11-11 15:08:32 +08:00
|
|
|
{ prepend, [[" This codeblock is auto-generated by shipwright.nvim]] },
|
|
|
|
|
{ left_pad, 4 },
|
|
|
|
|
{
|
|
|
|
|
patchwrite,
|
|
|
|
|
string.format("colors/%s.vim", specs_name),
|
|
|
|
|
string.format([[" %s start]], background),
|
|
|
|
|
string.format([[" %s end]], background),
|
|
|
|
|
}
|
2021-11-06 11:37:55 +08:00
|
|
|
)
|
2021-11-06 12:04:23 +08:00
|
|
|
-- selene: deny(undefined_variable)
|
2021-11-07 08:16:33 +08:00
|
|
|
---@diagnostic enable: undefined-global
|
2021-11-06 17:21:36 +08:00
|
|
|
|
|
|
|
|
local function remove_italics(specs)
|
|
|
|
|
local italic_specs = {}
|
|
|
|
|
for key, hl in pairs(specs) do
|
|
|
|
|
if hl.gui == "italic" and key ~= "Italic" then
|
|
|
|
|
table.insert(italic_specs, string.format("highlight %s gui=NONE cterm=NONE", key))
|
|
|
|
|
end
|
|
|
|
|
end
|
2021-11-06 17:25:30 +08:00
|
|
|
return vim.fn.sort(italic_specs)
|
2021-11-06 17:21:36 +08:00
|
|
|
end
|
|
|
|
|
|
2021-11-07 08:16:33 +08:00
|
|
|
---@diagnostic disable: undefined-global
|
2021-11-06 17:21:36 +08:00
|
|
|
-- selene: allow(undefined_variable)
|
2021-11-11 15:08:32 +08:00
|
|
|
run(specs, remove_italics, { prepend, [[" This codeblock is auto-generated by shipwright.nvim]] }, { left_pad, 8 }, {
|
2021-11-07 01:31:50 +00:00
|
|
|
patchwrite,
|
2021-11-11 15:08:32 +08:00
|
|
|
string.format("colors/%s.vim", specs_name),
|
|
|
|
|
string.format([[" no italics %s start]], background),
|
|
|
|
|
string.format([[" no italics %s end]], background),
|
2021-11-07 01:31:50 +00:00
|
|
|
})
|
2021-11-06 17:21:36 +08:00
|
|
|
-- selene: deny(undefined_variable)
|
2021-11-07 08:16:33 +08:00
|
|
|
---@diagnostic enable: undefined-global
|