Skip to content

Commit

Permalink
chore(palettes): Experiment with the palettes option
Browse files Browse the repository at this point in the history
Experiment with new palettes when `experiments.new_palettes` is enabled
and the `palettes` option is passed.
  • Loading branch information
ful1e5 committed Apr 16, 2023
1 parent 2e73167 commit 880f220
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 8 deletions.
9 changes: 6 additions & 3 deletions lua/github-theme/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,18 @@ M.setup = function(opts)
config.set_options({ overrides = opts.overrides })
end
if opts.dev then
config.set_options({ opts.dev })
config.set_options({ dev = opts.dev })
end

-- New configs
if opts.options then
config.set_options(opts.options)
end
if opts.palettes then
override.palettes = opts.palettes

if opts.experiments.new_palettes == true then
if opts.palettes then
override.palettes = opts.palettes
end
end

dep.check_deprecation(opts)
Expand Down
43 changes: 38 additions & 5 deletions lua/github-theme/palette.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ M.setup = function()
return c
end

-- TODO: Remove assignment after migration has been DONE
M.themes = {
['github_dark'] = 'g_dark',
['github_dark_colorblind'] = 'g_dark_colorblind',
Expand All @@ -43,6 +42,18 @@ M.themes = {
['github_light_tritanopia'] = 'g_light_tritanopia',
}

-- TODO: Use comment code after palette modules renaming
-- M.themes = {
-- 'github_dark',
-- 'github_dark_colorblind',
-- 'github_dark_high_contrast',
-- 'github_dark_tritanopia',
-- 'github_light',
-- 'github_light_colorblind',
-- 'github_light_high_contrast',
-- 'github_light_tritanopia',
-- }

local function override(color, ovr)
for key, value in pairs(ovr) do
color[key] = value
Expand All @@ -66,18 +77,40 @@ function M.load(name)
palette = apply_ovr(name, palette)
palette.meta = raw.meta
palette.generate_spec = raw.generate_spec

-- local valid = collect.contains(M.themes, name)
-- local raw = valid and require('github-theme.palette.' .. name)
-- or require('github-theme.palette.' .. config.theme)
-- local palette = raw.palette
-- palette = apply_ovr('all', palette)
-- palette = apply_ovr(name, palette)
-- palette.meta = raw.meta
-- palette.generate_spec = raw.generate_spec

return palette
else
local result = {}
for _, mod in ipairs(M.themes) do
local raw = require('github-theme.palette.' .. M.themes[mod])
for n, mod in pairs(M.themes) do
local raw = require('github-theme.palette.' .. mod)
local palette = raw.palette
palette = apply_ovr('all', palette)
palette = apply_ovr(mod, palette)
palette = apply_ovr(n, palette)
palette.meta = raw.meta
palette.generate_spec = raw.generate_spec
result[mod] = palette
result[n] = palette
end

-- for _, mod in ipairs(M.themes) do
-- local raw = require('github-theme.palette.' .. mod)
-- local palette = raw.palette
-- palette = apply_ovr('all', palette)
-- palette = apply_ovr(mod, palette)
-- palette.meta = raw.meta
-- palette.generate_spec = raw.generate_spec
-- result[mod] = palette
-- end
--

return result
end
end
Expand Down

0 comments on commit 880f220

Please sign in to comment.