Skip to content

Commit 3b5e1df

Browse files
committed
fix: add theme variant field to config class
also adds type hints to other util functions
1 parent 3b57712 commit 3b5e1df

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

lua/cyberdream/config.lua

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
local M = {}
22

33
---@class ThemeConfig
4+
---@field variant? string | "'default'" | "'light'"
45
---@field colors? table<string, string>
56
---@field highlights? table<string, table<string, string>>
67

lua/cyberdream/util.lua

+26
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
local ts = require("cyberdream.treesitter")
22
local M = {}
33

4+
--- Sets the highlight group to the given table of colors.
5+
--- @param group string
6+
--- @param hl vim.api.keyset.highlight
47
function M.highlight(group, hl)
58
group = ts.get(group)
69
if not group then
@@ -20,12 +23,16 @@ function M.highlight(group, hl)
2023
vim.api.nvim_set_hl(0, group, hl)
2124
end
2225

26+
--- Set the syntax highlighting for a group.
27+
--- @param syntax table
2328
function M.syntax(syntax)
2429
for group, colors in pairs(syntax) do
2530
M.highlight(group, colors)
2631
end
2732
end
2833

34+
--- Load the colorscheme.
35+
--- @param theme table
2936
function M.load(theme)
3037
-- only needed to clear when not the default colorscheme
3138
if vim.g.colors_name then
@@ -64,6 +71,25 @@ function M.blend(color1, color2, weight)
6471
return string.format("#%02x%02x%02x", rgb_blended[1], rgb_blended[2], rgb_blended[3])
6572
end
6673

74+
--- Remove an element from a table.
75+
--- @param table table
76+
--- @param index number
77+
--- @return table
78+
function M.remove(table, index)
79+
local new_table = {}
80+
for i = 1, #table do
81+
if i ~= index then
82+
new_table[#new_table + 1] = table[i]
83+
end
84+
end
85+
86+
return new_table
87+
end
88+
89+
--- Parse a template string with a given table of colors.
90+
--- @param template string
91+
--- @param t table
92+
--- @return string
6793
function M.parse_extra_template(template, t)
6894
for k, v in pairs(t) do
6995
template = template:gsub("%${" .. k .. "}", v)

0 commit comments

Comments
 (0)