convert autoload structure to single colors file
This commit is contained in:
@@ -9,8 +9,10 @@ local function make_env(colorscheme)
|
||||
local p = require(specs .. ".palette")[colorscheme.background]
|
||||
local env = builder.make_env {
|
||||
name = colorscheme.name,
|
||||
specs_name = specs,
|
||||
specs = require(specs),
|
||||
p = p,
|
||||
background = colorscheme.background,
|
||||
term = require("zenbones.term").colors_map(p),
|
||||
transform = require "zenbones.shipwright.transform",
|
||||
}
|
||||
|
||||
@@ -1,25 +1,11 @@
|
||||
local template = [[function! zenbones#generated#$name#load() abort
|
||||
$termcolors
|
||||
|
||||
$vimcolors
|
||||
|
||||
let s:italics = (&t_ZH != '' && &t_ZH != '[7m') || has('gui_running') || has('nvim')
|
||||
if !s:italics
|
||||
" start_no_italics
|
||||
" end_no_italics
|
||||
endif
|
||||
endfunction]]
|
||||
|
||||
local helpers = require "shipwright.transform.helpers"
|
||||
|
||||
local function to_vim_autoload(colorscheme)
|
||||
local vimcolors, term, name = unpack(colorscheme)
|
||||
local vimcolors, term = unpack(colorscheme)
|
||||
local termcolors = ""
|
||||
for i, v in ipairs(term) do
|
||||
termcolors = termcolors .. string.format("let g:terminal_color_%s = '%s'\n", (i - 1), v)
|
||||
end
|
||||
|
||||
termcolors = table.concat({
|
||||
termcolors = {
|
||||
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),
|
||||
@@ -36,14 +22,17 @@ local function to_vim_autoload(colorscheme)
|
||||
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),
|
||||
}, "\n")
|
||||
}
|
||||
|
||||
local text = helpers.apply_template(template, {
|
||||
name = name,
|
||||
termcolors = termcolors,
|
||||
vimcolors = table.concat(vimcolors, "\n"),
|
||||
})
|
||||
return { text }
|
||||
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
|
||||
end
|
||||
|
||||
local lushwright = require "shipwright.transform.lush"
|
||||
@@ -55,11 +44,17 @@ run(
|
||||
lushwright.to_vimscript,
|
||||
lushwright.vim_compatible_vimscript,
|
||||
function(vimcolors)
|
||||
return { vimcolors, term, name }
|
||||
return { vimcolors, term }
|
||||
end,
|
||||
to_vim_autoload,
|
||||
{ prepend, [[" This file is auto-generated by shipwright.nvim]] },
|
||||
{ overwrite, string.format("autoload/zenbones/generated/%s.vim", name) }
|
||||
{ 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),
|
||||
}
|
||||
)
|
||||
-- selene: deny(undefined_variable)
|
||||
---@diagnostic enable: undefined-global
|
||||
@@ -76,11 +71,11 @@ end
|
||||
|
||||
---@diagnostic disable: undefined-global
|
||||
-- selene: allow(undefined_variable)
|
||||
run(specs, remove_italics, {
|
||||
run(specs, remove_italics, { prepend, [[" This codeblock is auto-generated by shipwright.nvim]] }, { left_pad, 8 }, {
|
||||
patchwrite,
|
||||
string.format("autoload/zenbones/generated/%s.vim", name),
|
||||
[[" start_no_italics]],
|
||||
[[" end_no_italics]],
|
||||
string.format("colors/%s.vim", specs_name),
|
||||
string.format([[" no italics %s start]], background),
|
||||
string.format([[" no italics %s end]], background),
|
||||
})
|
||||
-- selene: deny(undefined_variable)
|
||||
---@diagnostic enable: undefined-global
|
||||
|
||||
Reference in New Issue
Block a user