From d41487904c05e0fa6f5c474579b710a6bbf6111c Mon Sep 17 00:00:00 2001 From: Michael Chris Lopez Date: Sat, 4 Sep 2021 16:40:29 +0800 Subject: [PATCH] move template files into lua --- _templates/colors/zenbones.vim.txt | 32 --------------- _templates/extras/kitty/zenbones.conf.txt | 39 ------------------- lua/zenbones/build.lua | 5 +-- lua/zenbones/build/kitty.lua | 47 +++++++++++++++++++++-- lua/zenbones/build/vim.lua | 35 +++++++++++++++++ 5 files changed, 81 insertions(+), 77 deletions(-) delete mode 100644 _templates/colors/zenbones.vim.txt delete mode 100644 _templates/extras/kitty/zenbones.conf.txt diff --git a/_templates/colors/zenbones.vim.txt b/_templates/colors/zenbones.vim.txt deleted file mode 100644 index 4092848..0000000 --- a/_templates/colors/zenbones.vim.txt +++ /dev/null @@ -1,32 +0,0 @@ -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} diff --git a/_templates/extras/kitty/zenbones.conf.txt b/_templates/extras/kitty/zenbones.conf.txt deleted file mode 100644 index 7e04192..0000000 --- a/_templates/extras/kitty/zenbones.conf.txt +++ /dev/null @@ -1,39 +0,0 @@ -# vim:ft=kitty -## name: zenbones -## license: MIT -## author: Michael Chris Lopez -## upstream: https://github.com/mcchrish/zenbones.nvim/raw/main/extras/kitty/zenbones.conf - -background ${background} -foreground ${foreground} -selection_background ${selection_background} -selection_foreground ${selection_foreground} -url_color ${url_color} -cursor ${cursor} - -# Tabs -active_tab_background ${active_tab_background} -active_tab_foreground ${active_tab_foreground} -inactive_tab_background ${inactive_tab_background} -inactive_tab_foreground ${inactive_tab_foreground} -#tab_bar_background ${tab_bar_background} - -# normal -color0 ${color0} -color1 ${color1} -color2 ${color2} -color3 ${color3} -color4 ${color4} -color5 ${color5} -color6 ${color6} -color7 ${color7} - -# bright -color8 ${color8} -color9 ${color9} -color10 ${color10} -color11 ${color11} -color12 ${color12} -color13 ${color13} -color14 ${color14} -color15 ${color15} diff --git a/lua/zenbones/build.lua b/lua/zenbones/build.lua index b6c80e4..e342406 100644 --- a/lua/zenbones/build.lua +++ b/lua/zenbones/build.lua @@ -8,10 +8,9 @@ function interp(s, tab) end)) end -local function write_template(path, spec) +local function write_template(path, template, values) print("[write template] " .. path) - local template = io.open("_templates/" .. path .. ".txt", "r"):read "*all" - local content = interp(template, spec) + local content = interp(template, values) local file = io.open(path, "w") file:write(content) file:close() diff --git a/lua/zenbones/build/kitty.lua b/lua/zenbones/build/kitty.lua index a49bf74..b7da423 100644 --- a/lua/zenbones/build/kitty.lua +++ b/lua/zenbones/build/kitty.lua @@ -1,9 +1,50 @@ +local template = [[# vim:ft=kitty +## name: zenbones +## license: MIT +## author: Michael Chris Lopez +## upstream: https://github.com/mcchrish/zenbones.nvim/raw/main/extras/kitty/zenbones.conf + +background ${background} +foreground ${foreground} +selection_background ${selection_background} +selection_foreground ${selection_foreground} +url_color ${url_color} +cursor ${cursor} + +# Tabs +active_tab_background ${active_tab_background} +active_tab_foreground ${active_tab_foreground} +inactive_tab_background ${inactive_tab_background} +inactive_tab_foreground ${inactive_tab_foreground} +#tab_bar_background ${tab_bar_background} + +# normal +color0 ${color0} +color1 ${color1} +color2 ${color2} +color3 ${color3} +color4 ${color4} +color5 ${color5} +color6 ${color6} +color7 ${color7} + +# bright +color8 ${color8} +color9 ${color9} +color10 ${color10} +color11 ${color11} +color12 ${color12} +color13 ${color13} +color14 ${color14} +color15 ${color15} +]] + local theme = require "zenbones" local terminal = require "zenbones.terminal" local bg = theme.Normal.bg.hex local fg = theme.Normal.fg.hex -local specs = { +local values = { background = bg, foreground = fg, selection_background = theme.Visual.bg.hex, @@ -16,7 +57,7 @@ local specs = { inactive_tab_foreground = fg, } for i, v in ipairs(terminal.colors) do - specs["color" .. (i - 1)] = v.hex + values["color" .. (i - 1)] = v.hex end -return { "extras/kitty/zenbones.conf", specs } +return { "extras/kitty/zenbones.conf", template, values } diff --git a/lua/zenbones/build/vim.lua b/lua/zenbones/build/vim.lua index 14a2ebe..2b77fd0 100644 --- a/lua/zenbones/build/vim.lua +++ b/lua/zenbones/build/vim.lua @@ -2,6 +2,40 @@ local lush = require "lush" local theme = require "zenbones" local terminal = require "zenbones.terminal" +local template = [[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} +]] + local termcolors = "" for i, v in ipairs(terminal.colors) do termcolors = termcolors .. string.format("let g:terminal_color_%s = '%s'\n", (i - 1), v.hex) @@ -12,6 +46,7 @@ local vimcolors = table.concat(vim.fn.sort(lush.compile(theme, { exclude_keys = return { "colors/zenbones.vim", + template, { termcolors = termcolors, vimcolors = vimcolors,