Refacto palette and theme, added more colors
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user