2021-11-06 14:06:48 +08:00
|
|
|
|
local template = [[function! zenbones#generated#$name#load() abort
|
2021-11-06 11:37:55 +08:00
|
|
|
|
$termcolors
|
|
|
|
|
|
$vimcolors
|
2021-11-06 17:21:36 +08:00
|
|
|
|
|
|
|
|
|
|
let s:italics = (&t_ZH != '' && &t_ZH != '[7m') || has('gui_running') || has('nvim')
|
|
|
|
|
|
if !s:italics
|
|
|
|
|
|
" start_no_italics
|
|
|
|
|
|
" end_no_italics
|
2021-11-06 11:37:55 +08:00
|
|
|
|
endif
|
2021-11-06 14:06:48 +08:00
|
|
|
|
endfunction]]
|
2021-11-06 11:37:55 +08:00
|
|
|
|
|
|
|
|
|
|
local helpers = require "shipwright.transform.helpers"
|
|
|
|
|
|
|
2021-11-06 12:04:23 +08:00
|
|
|
|
local function to_vim_autoload(colorscheme)
|
|
|
|
|
|
local vimcolors, term, name = unpack(colorscheme)
|
2021-11-06 11:37:55 +08:00
|
|
|
|
local termcolors = ""
|
|
|
|
|
|
for i, v in ipairs(term) do
|
|
|
|
|
|
termcolors = termcolors .. string.format("let g:terminal_color_%s = '%s'\n", (i - 1), v.hex)
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
local text = helpers.apply_template(template, {
|
|
|
|
|
|
name = name,
|
|
|
|
|
|
termcolors = termcolors,
|
|
|
|
|
|
vimcolors = table.concat(vimcolors, "\n"),
|
|
|
|
|
|
})
|
|
|
|
|
|
return { text }
|
|
|
|
|
|
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)
|
|
|
|
|
|
return { vimcolors, term, name }
|
|
|
|
|
|
end,
|
2021-11-06 11:37:55 +08:00
|
|
|
|
to_vim_autoload,
|
|
|
|
|
|
{ prepend, [[" This file is auto-generated by shipwright.nvim]] },
|
2021-11-06 14:06:48 +08:00
|
|
|
|
{ overwrite, string.format("autoload/zenbones/generated/%s.vim", name) }
|
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)
|
|
|
|
|
|
run(
|
|
|
|
|
|
specs,
|
|
|
|
|
|
remove_italics,
|
|
|
|
|
|
{
|
|
|
|
|
|
patchwrite,
|
|
|
|
|
|
string.format("autoload/zenbones/generated/%s.vim", name),
|
|
|
|
|
|
[[" start_no_italics]],
|
|
|
|
|
|
[[" end_no_italics]],
|
|
|
|
|
|
}
|
|
|
|
|
|
)
|
|
|
|
|
|
-- selene: deny(undefined_variable)
|
2021-11-07 08:16:33 +08:00
|
|
|
|
---@diagnostic enable: undefined-global
|