Files
Astrobox/lua/astrobox/init.lua

45 lines
1.1 KiB
Lua

local config = require("astrobox.config")
local highlights = require("astrobox.highlights")
local palette = require("astrobox.palette")
local theme = require("astrobox.theme")
local M = {
---@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 = 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.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()
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
M.set_highlights(M.hl)
vim.g.colors_name = "astrobox"
end
return M