create string interpolation and template file
This commit is contained in:
32
_templates/colors/zenbones.vim.txt
Normal file
32
_templates/colors/zenbones.vim.txt
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
if exists('g:colors_name')
|
||||||
|
highlight clear
|
||||||
|
syntax reset
|
||||||
|
set t_Co=256
|
||||||
|
endif
|
||||||
|
|
||||||
|
set background=light
|
||||||
|
let g:colors_name = 'zenbones'
|
||||||
|
|
||||||
|
${termcolors}
|
||||||
|
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
|
||||||
|
|
||||||
|
${vimcolors}
|
||||||
@@ -1,40 +1,21 @@
|
|||||||
local lush = require "lush"
|
local lush = require "lush"
|
||||||
local theme = require "zenbones"
|
local theme = require "zenbones"
|
||||||
|
|
||||||
local viml_template = [[
|
-- got from http://lua-users.org/wiki/StringInterpolation
|
||||||
if exists('g:colors_name')
|
function interp(s, tab)
|
||||||
highlight clear
|
return (s:gsub("($%b{})", function(w)
|
||||||
syntax reset
|
return tab[w:sub(3, -2)] or w
|
||||||
set t_Co=256
|
end))
|
||||||
endif
|
end
|
||||||
|
|
||||||
set background=light
|
local function write_template(path, spec)
|
||||||
let g:colors_name = 'zenbones'
|
print("[write template] " .. path)
|
||||||
|
local template = io.open("_templates/" .. path ..".txt", "r"):read "*all"
|
||||||
%s
|
local content = interp(template, spec)
|
||||||
if has('terminal')
|
local file = io.open(path, "w")
|
||||||
let g:terminal_ansi_colors = [
|
file:write(content)
|
||||||
\ g:terminal_color_0,
|
file:close()
|
||||||
\ g:terminal_color_1,
|
end
|
||||||
\ 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
|
|
||||||
|
|
||||||
%s
|
|
||||||
]]
|
|
||||||
|
|
||||||
local function viml_build()
|
local function viml_build()
|
||||||
local termcolors = ""
|
local termcolors = ""
|
||||||
@@ -44,8 +25,10 @@ local function viml_build()
|
|||||||
|
|
||||||
-- Compile lush table, concatenate to a single string, and remove blend property
|
-- 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")
|
local vimcolors = table.concat(vim.fn.sort(lush.compile(theme, { exclude_keys = { "blend" } })), "\n")
|
||||||
local content = vim.fn.split(string.format(viml_template, termcolors, vimcolors), "\n")
|
write_template("colors/zenbones.vim", {
|
||||||
vim.fn.writefile(content, "colors/zenbones.vim")
|
termcolors = termcolors,
|
||||||
|
vimcolors = vimcolors
|
||||||
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
local function build()
|
local function build()
|
||||||
|
|||||||
Reference in New Issue
Block a user