-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_themes.py
executable file
·69 lines (57 loc) · 1.73 KB
/
generate_themes.py
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env python3
import os
# python -m pip install pyyaml
import yaml
def read_config(config):
with open(config, "r") as file:
theme = yaml.safe_load(file)
highlights = []
for key in theme:
try:
highlight = f"hi {key}"
for attr in theme[key]:
highlight += f" {attr}={theme[key][attr]}"
highlights.append(highlight)
except TypeError:
pass
return highlights
def read_links(config):
with open(config, "r") as file:
file = yaml.safe_load(file)
links = []
try:
for key in file:
link = f"hi def link {key} {file[key]}"
print(link)
links.append(link)
except TypeError:
pass
return links
def options():
options = [
"if get(g:, 'walh_dimming')",
" hi def link NormalNC Inactive",
" hi def link NvimTreeNormalNC Inactive",
"else",
" hi def link NormalNC Active",
" hi def link NvimTreeNormalNC Active",
"endif",
]
return options
def gen_theme():
ui = read_config("ui.yaml")
links = read_links("links.yaml")
for theme in os.listdir("themes"):
theme_name = theme.split(".")[0]
p = [
"hi clear",
"syntax reset",
"set notermguicolors",
f"let g:colors_name = '{theme_name}'",
]
c = read_config(f"themes/{theme}")
print(f"creating * {theme_name} * theme")
output = p + ui + c + options() + links
with open(f"colors/{theme_name}.vim", "w") as file:
file.writelines("%s\n" % line for line in output)
gen_theme()