1
1
local ts = require (" cyberdream.treesitter" )
2
2
local M = {}
3
3
4
+ --- Sets the highlight group to the given table of colors.
5
+ --- @param group string
6
+ --- @param hl vim.api.keyset.highlight
4
7
function M .highlight (group , hl )
5
8
group = ts .get (group )
6
9
if not group then
@@ -20,12 +23,16 @@ function M.highlight(group, hl)
20
23
vim .api .nvim_set_hl (0 , group , hl )
21
24
end
22
25
26
+ --- Set the syntax highlighting for a group.
27
+ --- @param syntax table
23
28
function M .syntax (syntax )
24
29
for group , colors in pairs (syntax ) do
25
30
M .highlight (group , colors )
26
31
end
27
32
end
28
33
34
+ --- Load the colorscheme.
35
+ --- @param theme table
29
36
function M .load (theme )
30
37
-- only needed to clear when not the default colorscheme
31
38
if vim .g .colors_name then
@@ -64,6 +71,25 @@ function M.blend(color1, color2, weight)
64
71
return string.format (" #%02x%02x%02x" , rgb_blended [1 ], rgb_blended [2 ], rgb_blended [3 ])
65
72
end
66
73
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
67
93
function M .parse_extra_template (template , t )
68
94
for k , v in pairs (t ) do
69
95
template = template :gsub (" %${" .. k .. " }" , v )
0 commit comments