Refacto palette and theme, added more colors

This commit is contained in:
2024-02-18 16:46:13 +01:00
parent 8a91acbe19
commit e4cfb6ebd0
15 changed files with 431 additions and 240 deletions

View File

@@ -1,36 +1,45 @@
local config = require("astrobox.config")
local palette = require("astrobox.palette")
local highlights = require("astrobox.highlights")
local default_cfg = {
contrast = "default", -- soft, default or hard
overrides = {}
}
local theme = require("astrobox.theme")
local M = {
cfg = {},
palette = {},
---@type Config
cfg = nil,
---@type Palette
palette = nil,
---@type Theme
theme = nil,
---@type table
hl = {},
}
---@param user_cfg Config
function M.setup(user_cfg)
M.cfg = user_cfg
M.cfg = config.make_config(user_cfg)
-- If the colors are set, assume we're reloading and auto apply
if vim.g.colors_name == "astrobox" then
vim.notify("Reloading", vim.log.levels.INFO, { title = "Astrobox" })
vim.cmd.colorscheme("astrobox")
end
end
function M.set_highlights(list)
vim.cmd.highlight("clear")
for hl, def in pairs(list) do
vim.api.nvim_set_hl(0, hl, def)
end
end
function M.load()
local cfg = vim.tbl_extend("force", default_cfg, M.cfg or {})
M.palette = palette(cfg)
M.hl = highlights(M.palette, cfg)
for index, color in ipairs(M.palette.term_colors) do
M.palette = palette(M.cfg)
M.theme = theme.make_theme(M.palette, M.cfg)
M.hl = highlights.make_highlights(M.theme, M.palette, M.cfg)
for index, color in ipairs(M.theme.term_colors) do
vim.g["terminal_color_" .. index - 1] = color
end
vim.g.colors_name = "astrobox"
M.set_highlights(M.hl)
vim.g.colors_name = "astrobox"
end
return M