aboutsummaryrefslogtreecommitdiff
path: root/lua/prismite/init.lua
blob: 8fd4d028ece3f6832a3f1e5d8cbeb3e7c9328011 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
local utils = require "prismite.utils"

local M = {}

local function term_color(idx, color)
    vim.g["terminal_color_" .. idx] = color
end

function M.load()
    if vim.g.colors_name then
        vim.cmd.hi "clear"
    end

    vim.g.colors_name = "prismite"
    vim.o.termguicolors = true

    local colors = require "prismite.palette"
    term_color(0, colors.bg_lowest)
    term_color(8, colors.bg_low)
    term_color(1, colors.red)
    term_color(9, colors.red_bright)
    term_color(2, colors.green)
    term_color(10, colors.green_bright)
    term_color(3, colors.yellow)
    term_color(11, colors.yellow_bright)
    term_color(4, colors.blue)
    term_color(12, colors.blue_bright)
    term_color(5, colors.pink)
    term_color(13, colors.pink_bright)
    term_color(6, colors.cyan)
    term_color(14, colors.cyan_bright)
    term_color(7, colors.fg)
    term_color(15, colors.fg_high)

    local groups = vim.tbl_deep_extend("error", {}, unpack(require "prismite.groups"))
    for group, hl in pairs(groups) do
        if type(hl.fg) == "table" and utils.is_oklch(hl.fg) then
            hl.fg = utils.oklch2hex(hl.fg)
        end

        if type(hl.bg) == "table" and utils.is_oklch(hl.bg) then
            hl.bg = utils.oklch2hex(hl.bg)
        end

        if type(hl.sp) == "table" and utils.is_oklch(hl.sp) then
            hl.sp = utils.oklch2hex(hl.sp)
        end

        vim.api.nvim_set_hl(0, group, hl)
    end
end

return M