move specs to a single dir, allow custom global config prefix

This commit is contained in:
Michael Chris Lopez
2021-10-11 13:56:02 +08:00
parent 707be04d87
commit ad6bbe7e8d
10 changed files with 48 additions and 42 deletions

View File

@@ -4,10 +4,10 @@ local hsluv = lush.hsluv
local base_name = util.bg_to_base_name()
local p = require("neobones.palette")[base_name]
local generator = require "zenbones.specs"
local specs = generator.generate(p, base_name, generator.get_global_config(base_name, "neobones"))
if base_name == "zenbones" then
local generator = require "zenbones.specs"
local specs = generator.generate(p, generator.get_global_config())
return lush.extends({ specs }).with(function()
return {
helpHyperTextJump { fg = hsluv "#195174" }, -- --link-color
@@ -16,8 +16,6 @@ if base_name == "zenbones" then
}
end)
else
local generator = require "zenflesh.specs"
local specs = generator.generate(p, generator.get_global_config())
return lush.extends({ specs }).with(function()
return {
FloatBorder { fg = hsluv "#203f57" }, -- --border-color

View File

@@ -4,8 +4,8 @@ local util = require "zenbones.util"
local base_name = util.bg_to_base_name()
local p = require("rosebones.palette")[base_name]
local generator = require(base_name .. ".specs")
local specs = generator.generate(p, generator.get_global_config(base_name))
local generator = require "zenbones.specs"
local specs = generator.generate(p, base_name, generator.get_global_config(base_name, "rosebones"))
-- extend specs using Lush
return lush.extends({ specs }).with(function()

View File

@@ -1,4 +1,4 @@
local generator = require "zenbones.specs"
local p = require "zenbones.palette"
return generator.generate(p, generator.get_global_config())
return generator.generate(p, "zenbones", generator.get_global_config "zenbones")

View File

@@ -1,5 +1,3 @@
local util = require "zenbones.util"
local lush = require "lush"
local hsluv = lush.hsluv
return util.palette_extend({}, "zenbones")

View File

@@ -0,0 +1,34 @@
local M = {}
function M.get_global_config(base_name, prefix)
prefix = type(prefix) == "string" and prefix or base_name
if base_name == "zenbones" then
return {
lightness = vim.g[prefix .. "_lightness"],
comment_gui = vim.g[prefix .. "_italic_comments"] ~= false and "italic" or "NONE",
dim_noncurrent_window = vim.g[prefix .. "_dim_noncurrent_window"],
solid_vert_split = vim.g[prefix .. "_solid_vert_split"],
}
elseif base_name == "zenflesh" then
return {
darkness = vim.g[prefix .. "_darkness"],
comment_gui = vim.g[prefix .. "_italic_comments"] ~= false and "italic" or "NONE",
lighten_noncurrent_window = vim.g[prefix .. "_lighten_noncurrent_window"],
solid_vert_split = vim.g[prefix .. "_solid_vert_split"],
}
else
error "Unknown base_name"
end
end
function M.generate(p, base_name, opt)
if base_name == "zenbones" then
return require "zenbones.specs.zenbones"(p, opt)
elseif base_name == "zenflesh" then
return require "zenbones.specs.zenflesh"(p, opt)
else
error "Unknown base_name"
end
end
return M

View File

@@ -1,17 +1,6 @@
local lush = require "lush"
local M = {}
function M.get_global_config(base_name)
return {
lightness = vim.g.zenbones_lightness,
comment_gui = vim.g.zenbones_italic_comments ~= false and "italic" or "NONE",
dim_noncurrent_window = vim.g.zenbones_dim_noncurrent_window,
solid_vert_split = vim.g.zenbones_solid_vert_split,
}
end
function M.generate(p, opt)
local function generate(p, opt)
local normal_bg = p.bg
local diff_bg_l = 0
@@ -422,5 +411,5 @@ function M.generate(p, opt)
return lush.merge(specs)
end
return M
return generate
-- vi:nowrap

View File

@@ -1,17 +1,6 @@
local lush = require "lush"
local M = {}
function M.get_global_config(base_name)
return {
darkness = vim.g.zenflesh_darkness,
comment_gui = vim.g.zenflesh_italic_comments ~= false and "italic" or "NONE",
lighten_noncurrent_window = vim.g.zenflesh_lighten_noncurrent_window,
solid_vert_split = vim.g.zenflesh_solid_vert_split,
}
end
function M.generate(p, opt)
local function generate(p, opt)
local normal_bg = p.bg
local diff_bg_l = 0
@@ -26,7 +15,7 @@ function M.generate(p, opt)
vim.api.nvim_echo({ { error_msg, "WarningMsg" } }, true, {})
end
local comment_gui = opt.comment_gui ~= false and "italic" or "NONE"
local comment_gui = opt.comment_gui
-- stylua: ignore start
local theme = lush(function()
@@ -422,5 +411,5 @@ function M.generate(p, opt)
return lush.merge(specs)
end
return M
return generate
-- vi:nowrap

View File

@@ -1,5 +1,3 @@
local lush = require "lush"
local hsluv = lush.hsluv
local M = {}
-- got from http://lua-users.org/wiki/StringInterpolation
@@ -14,6 +12,8 @@ function M.bg_to_base_name()
end
function M.palette_extend(p, base_name)
local lush = require "lush"
local hsluv = lush.hsluv
if base_name == "zenbones" then
p = vim.tbl_extend("keep", p, {
bg = hsluv(39, 12, 94), -- sand

View File

@@ -1,4 +1,4 @@
local generator = require "zenflesh.specs"
local generator = require "zenbones.specs"
local p = require "zenflesh.palette"
return generator.generate(p, generator.get_global_config())
return generator.generate(p, "zenflesh", generator.get_global_config "zenflesh")

View File

@@ -1,5 +1,3 @@
local util = require "zenbones.util"
local lush = require "lush"
local hsluv = lush.hsluv
return util.palette_extend({}, "zenflesh")