wip: overhaul vim template

This commit is contained in:
Michael Chris Lopez
2021-11-01 10:10:49 +08:00
parent 71aa085609
commit 0b00f673b7
4 changed files with 62 additions and 63 deletions

View File

@@ -22,19 +22,27 @@ end
local config_set = { local config_set = {
{ {
name = "zenbones", name = "zenbones_light",
palette = require "zenbones.palette", specs = "zenbones",
opt = { palette = require("zenbones.palette").light,
template_opt = { setup = function()
vim = { bg = "light" }, vim.opt.background = "light"
}, end,
}, },
{
name = "zenbones_dark",
specs = "zenbones",
palette = require("zenbones.palette").dark,
setup = function()
vim.opt.background = "dark"
end,
}, },
{ {
name = "zenbones_bright", name = "zenbones_bright",
specs = "zenbones", specs = "zenbones",
palette = require "zenbones.palette", palette = require("zenbones.palette").light,
setup = function() setup = function()
vim.g.zenbones_lightness = "bright" vim.g.zenbones_lightness = "bright"
end, end,
@@ -49,7 +57,7 @@ local config_set = {
{ {
name = "zenbones_dim", name = "zenbones_dim",
specs = "zenbones", specs = "zenbones",
palette = require "zenbones.palette", palette = require("zenbones.palette").light,
setup = function() setup = function()
vim.g.zenbones_lightness = "dim" vim.g.zenbones_lightness = "dim"
end, end,
@@ -61,40 +69,35 @@ local config_set = {
}, },
}, },
{ -- {
name = "zenflesh", -- name = "zenflesh_stark",
palette = require "zenflesh.palette", -- specs = "zenflesh",
}, -- palette = require "zenflesh.palette",
-- setup = function()
{ -- vim.g.zenflesh_darkness = "stark"
name = "zenflesh_stark", -- end,
specs = "zenflesh", -- cleanup = function()
palette = require "zenflesh.palette", -- vim.api.nvim_del_var "zenflesh_darkness"
setup = function() -- end,
vim.g.zenflesh_darkness = "stark" -- opt = {
end, -- exclude = { "vim", "lightline", "lualine" },
cleanup = function() -- },
vim.api.nvim_del_var "zenflesh_darkness" -- },
end, --
opt = { -- {
exclude = { "vim", "lightline", "lualine" }, -- name = "zenflesh_warm",
}, -- specs = "zenflesh",
}, -- palette = require "zenflesh.palette",
-- setup = function()
{ -- vim.g.zenflesh_darkness = "warm"
name = "zenflesh_warm", -- end,
specs = "zenflesh", -- cleanup = function()
palette = require "zenflesh.palette", -- vim.api.nvim_del_var "zenflesh_darkness"
setup = function() -- end,
vim.g.zenflesh_darkness = "warm" -- opt = {
end, -- exclude = { "vim", "lightline", "lualine" },
cleanup = function() -- },
vim.api.nvim_del_var "zenflesh_darkness" -- },
end,
opt = {
exclude = { "vim", "lightline", "lualine" },
},
},
{ {
name = "neobones_light", name = "neobones_light",
@@ -218,7 +221,7 @@ local config_set = {
{ {
name = "nordbones", name = "nordbones",
palette = require("nordbones.palette").derived, palette = require("nordbones.palette").dark,
opt = { opt = {
exclude = { "alacritty", "iterm", "kitty", "tmux", "wezterm" }, exclude = { "alacritty", "iterm", "kitty", "tmux", "wezterm" },
}, },

View File

@@ -1,4 +1,5 @@
local generator = require "zenbones.specs" local generator = require "zenbones.specs"
local p = require "zenbones.palette" local bg = vim.opt.background:get()
local p = require("zenbones.palette")[bg]
return generator.generate(p, "light", generator.get_global_config("zenbones", "light")) return generator.generate(p, bg, generator.get_global_config("zenbones", bg))

View File

@@ -1,3 +1,8 @@
local util = require "zenbones.util" local util = require "zenbones.util"
return util.palette_extend({}, "light") local M = {}
M.light = util.palette_extend({}, "light")
M.dark = util.palette_extend {}
return M

View File

@@ -1,21 +1,10 @@
local template = [[" This file is auto-generated from lua/zenbones/template/vim.lua local template = [[" This file is auto-generated from lua/zenbones/template/vim.lua
if exists('g:colors_name') function! ${name}#load()
highlight clear
endif
set background=${background}
let g:colors_name = '${name}'
${termcolors} ${termcolors}
if has('nvim') && (!exists('g:${name}_compat') || g:${name}_compat == 0)
lua package.loaded["${specs_path}"] = nil
lua require "lush"(require "${specs_path}", { force_clean = false })
finish
else
${vimcolors} ${vimcolors}
highlight! link StatusLineTerm StatusLine highlight! link StatusLineTerm StatusLine
highlight! link StatusLineTermNC StatusLineNC highlight! link StatusLineTermNC StatusLineNC
endif
if has('terminal') if has('terminal')
let g:terminal_ansi_colors = [ let g:terminal_ansi_colors = [
@@ -37,10 +26,12 @@ if has('terminal')
\ g:terminal_color_15 \ g:terminal_color_15
\ ] \ ]
endif endif
endfunction
]] ]]
local lush = require "lush" return function(name, specs, p)
return function(name, specs, p, opt) local lush = require "lush"
local term = require("zenbones.term").colors_map(p) local term = require("zenbones.term").colors_map(p)
local termcolors = "" local termcolors = ""
for i, v in ipairs(term) do for i, v in ipairs(term) do
@@ -55,12 +46,11 @@ return function(name, specs, p, opt)
local vimcolors = table.concat(vim.fn.sort(compiled), "\n") local vimcolors = table.concat(vim.fn.sort(compiled), "\n")
return { return {
string.format("colors/%s.vim", name), string.format("autoload/%s.vim", name),
template, template,
{ {
name = name, name = name,
specs_path = name, specs_path = name,
background = opt.bg or "dark",
termcolors = termcolors, termcolors = termcolors,
vimcolors = vimcolors, vimcolors = vimcolors,
}, },