Files
zenbones-theme/lua/zenbones/template/vim.lua

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

63 lines
1.7 KiB
Lua
Raw Normal View History

2021-09-21 20:55:53 +08:00
local template = [[" This file is auto-generated from lua/zenbones/template/vim.lua
2021-09-18 14:32:29 +08:00
if exists('g:colors_name')
2021-09-04 16:40:29 +08:00
highlight clear
syntax reset
set t_Co=256
endif
2021-09-14 05:53:51 +08:00
let g:colors_name = '${name}'
2021-09-04 16:40:29 +08:00
${termcolors}
if get(g:, "zenbones_compat") != v:true
let g:colors_name = '${name}'
lua package.loaded["${specs_path}"] = nil
lua require "lush"(require "${specs_path}", { force_clean = false })
finish
else
${vimcolors}
endif
2021-09-04 16:40:29 +08:00
if has('terminal')
let g:terminal_ansi_colors = [
\ g:terminal_color_0,
\ g:terminal_color_1,
\ g:terminal_color_2,
\ g:terminal_color_3,
\ g:terminal_color_4,
\ g:terminal_color_5,
\ g:terminal_color_6,
\ g:terminal_color_7,
\ g:terminal_color_8,
\ g:terminal_color_9,
\ g:terminal_color_10,
\ g:terminal_color_11,
\ g:terminal_color_12,
\ g:terminal_color_13,
\ g:terminal_color_14,
\ g:terminal_color_15
\ ]
endif
]]
2021-09-21 20:55:53 +08:00
local lush = require "lush"
2021-10-09 16:27:46 +08:00
return function(name, theme, palette, term)
2021-09-14 07:50:23 +08:00
local termcolors = ""
2021-10-09 16:27:46 +08:00
for i, v in ipairs(term) do
2021-09-14 07:50:23 +08:00
termcolors = termcolors .. string.format("let g:terminal_color_%s = '%s'\n", (i - 1), v.hex)
end
2021-09-04 16:02:45 +08:00
2021-09-14 07:50:23 +08:00
-- Compile lush table, concatenate to a single string, and remove blend property
local vimcolors = table.concat(vim.fn.sort(lush.compile(theme, { exclude_keys = { "blend" } })), "\n")
2021-09-04 16:02:45 +08:00
2021-09-14 07:50:23 +08:00
return {
string.format("colors/%s.vim", name),
template,
{
name = name,
specs_path = name,
2021-09-14 07:50:23 +08:00
termcolors = termcolors,
vimcolors = vimcolors,
},
}
2021-09-14 05:53:51 +08:00
end