-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathgen.py
137 lines (128 loc) · 4.29 KB
/
gen.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
"""Script to generate vim color scheme.
Generates a vim color scheme that works with 256 and 16 color terminals,
as well as in gvim."""
PREAMBLE = """\
" Vim color file
" Name: 256_noir.vim
" Maintainer: Andreas van Cranenburgh <andreas@unstable.nl>
" Homepage: https://github.com/andreasvc/vim-256noir/
" Basically: dark background, numerals & errors red,
" rest different shades of gray.
"
" colors 232--250 are shades of gray, from dark to light;
" 16=black, 255=white, 196=red, 88=darkred.
highlight clear
set background=dark
if version > 580
" no guarantees for version 5.8 and below, but this makes it stop
" complaining
if exists("syntax_on")
syntax reset
endif
endif
let g:colors_name = "256_noir"
"""
# Group ctermfg ctermbg cterm
COLORS = """
Normal 250 16 NONE
Keyword 255 16 NONE
Constant 252 16 NONE
String 245 16 NONE
Comment 240 16 NONE
Number 196 16 NONE
Error 255 88 NONE
ErrorMsg 255 124 NONE
Search 245 236 NONE
IncSearch 255 245 reverse
DiffChange 160 255 NONE
DiffText 250 196 bold
SignColumn 124 240 NONE
SpellBad 255 88 undercurl
SpellCap 255 124 NONE
SpellRare 124 16 NONE
WildMenu 240 255 NONE
Pmenu 255 240 NONE
PmenuThumb 232 240 NONE
SpecialKey 16 255 NONE
MatchParen 16 240 NONE
CursorLine NONE 233 NONE
StatusLine 245 16 bold,reverse
StatusLineNC 236 16 reverse
Visual 250 16 reverse
TermCursor NONE NONE reverse
"""
# First tuple element has highlight, rest is linked to it.
LINKS = [
('Normal', 'Boolean', 'Delimiter', 'Identifier', 'Title', 'Debug',
'Exception', 'FoldColumn', 'Macro', 'ModeMsg', 'MoreMsg',
'Question'),
('Keyword', 'Conditional', 'Statement', 'Operator', 'Structure',
'Function', 'Include', 'Type', 'Typedef', 'Todo', 'Label',
'Define', 'DiffAdd', 'diffAdded', 'diffCommon', 'Directory',
'PreCondit', 'PreProc', 'Repeat', 'Special', 'SpecialChar',
'StorageClass'),
('String', 'SpecialComment', 'CursorLineNr'),
('Number', 'Character', 'Float', 'Tag', 'Folded', 'WarningMsg'),
('SpecialKey', 'iCursor'),
('SpellCap', 'SpellLocal'),
('Comment', 'LineNr', 'NonText', 'DiffDelete', 'diffRemoved'),
('Visual', 'PmenuSbar', 'PmenuSel', 'VisualNOS', 'VertSplit'),
('StatusLine', 'Cursor'),
('SpellRare', 'Underlined', 'rstEmphasis'),
('DiffChange', 'diffChanged'),
]
TORGB = {
16: '#000000',
88: '#870000',
124: '#af0000',
160: '#d70000',
196: '#ff0000',
232: '#080808',
233: '#121212',
234: '#1c1c1c',
236: '#303030',
240: '#585858',
245: '#8a8a8a',
250: '#bcbcbc',
252: '#d0d0d0',
255: '#eeeeee',
'NONE': 'NONE',
}
TO16 = {
16: 'Black',
88: 'DarkRed',
124: 'Red',
160: 'Red',
196: 'Red',
232: 'Black',
233: 'Black',
234: 'DarkGray',
236: 'DarkGray',
240: 'DarkGray',
245: 'Gray',
250: 'Gray',
252: 'Gray',
255: 'White',
'NONE': 'NONE',
}
if __name__ == '__main__':
table = [(key, term,
'NONE' if fg == 'NONE' else int(fg),
'NONE' if bg == 'NONE' else int(bg))
for key, fg, bg, term
in (line.strip().split() for line in COLORS.strip().splitlines())]
print(PREAMBLE)
print('if has("gui_running") || &t_Co == 256')
for key, term, fg, bg in table:
print(' hi %s cterm=%s ctermfg=%s ctermbg=%s'
' gui=%s guifg=%s guibg=%s' % (
key, term, fg, bg,
term, TORGB[fg], TORGB[bg]))
print('else') # terminal with less colors, e.g., 88, 16, or 8.
for key, term, fg, bg in table:
print(' hi %s cterm=%s ctermfg=%s ctermbg=%s' % (
key, term, TO16[fg], TO16[bg]))
print('endif')
for a in LINKS:
for b in a[1:]:
print('highlight! link %s %s' % (b, a[0]))