forked from jsit/disco.vim
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfromtermcolors.vim
More file actions
421 lines (347 loc) · 14.6 KB
/
fromtermcolors.vim
File metadata and controls
421 lines (347 loc) · 14.6 KB
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
" Vim color file vim-fromtermcolors
" Maintainer: [jcherven] <jcherven@mail.usf.edu>
" Last Change:
" URL:
" Description: A full set of 1-, 8-, 16-, 88-, 256-, and GUI-color-compatible colors.
" Run :so $VIMRUNTIME/syntax/hitest.vim to see the currently used highlight
" groups for debugging
" We need to use :h color-nr numbers for cterm, in case we are on a low-color
" terminal
let s:color_map = {
\'NormalBlack' : 0,
\'NormalRed' : 1,
\'NormalGreen' : 2,
\'NormalYellow' : 3,
\'NormalBlue' : 4,
\'NormalMagenta' : 5,
\'NormalCyan' : 6,
\'NormalWhite' : 7,
\'BrightBlack' : 8,
\'BrightRed' : 9,
\'BrightGreen' : 10,
\'BrightYellow' : 11,
\'BrightBlue' : 12,
\'BrightMagenta' : 13,
\'BrightCyan' : 14,
\'BrightWhite' : 15,
\}
" Sets the highlighting for the given group. {{{
" From github.com/jsit/vim-tomorrow-theme
" Originally by Chris Kempson and contributors
fun! <SID>set_colors(group, fg, bg, attr)
if !empty(a:fg)
if type(a:fg) == 1 " If a:bg is a string, look it up for cterm
exec "hi " . a:group . " guifg=" . a:fg . " ctermfg=" . get(s:color_map, a:fg)
else
exec "hi " . a:group . " guifg=" . a:fg . " ctermfg=" . a:fg
endif
endif
if !empty(a:bg)
if type(a:bg) == 1 " If a:bg is a string, look it up for cterm
exec "hi " . a:group . " guibg=" . a:bg . " ctermbg=" . get(s:color_map, a:bg)
else
exec "hi " . a:group . " guibg=" . a:bg . " ctermbg=" . a:bg
endif
endif
if a:attr != ""
exec "hi " . a:group . " gui=" . a:attr . " cterm=" . a:attr
endif
endfun
hi clear
if exists("syntax_on")
syntax reset
endif
let g:colors_name = "fromtermcolors"
" Check to see if we can do colors 8-15
if has('gui_running') || (&t_Co > 8 && (!exists('g:fromtermcolors_nobright') || g:fromtermcolors_nobright != 1))
let s:gt_eight = 1
else
let s:gt_eight = 0
endif
" Check to see if we can do italic
if (&t_ZH != '' && &t_ZH != '[7m')
let s:italic = 1
else
let s:italic = 0
endif
" }}}
" Define our colors based on the background setting
if &background == "dark" && s:gt_eight
let s:brightbg = 'BrightBlack'
let s:brightfg = 'NormalWhite'
let s:normalbg = 'NormalBlack'
let s:normalfg = 'NormalWhite'
else
let s:normalfg = 'NormalBlack'
if s:gt_eight
let s:normalbg = 'NormalWhite'
let s:brightbg = 'NormalWhite'
let s:brightfg = 'BrightBlack'
else
let s:normalbg = 'NONE'
let s:brightbg = 'NormalWhite'
let s:brightfg = 'NormalWhite'
endif
endif
if &background == "dark" && s:gt_eight && (!exists('g:fromtermcolors_fg_dark') || g:fromtermcolors_fg_dark != 1)
let s:brightred = 'BrightRed'
let s:brightgreen = 'BrightGreen'
let s:brightyellow = 'BrightYellow'
let s:brightblue = 'BrightBlue'
let s:brightmagenta = 'BrightMagenta'
let s:brightcyan = 'BrightCyan'
let s:normalred = 'NormalRed'
let s:normalgreen = 'NormalGreen'
let s:normalyellow = 'NormalYellow'
let s:normalblue = 'NormalBlue'
let s:normalmagenta = 'NormalMagenta'
let s:normalcyan = 'NormalCyan'
let s:cursoryellow = 'BrightWhite'
else
let s:brightred = 'NormalRed'
let s:brightgreen = 'NormalGreen'
let s:brightyellow = 'NormalYellow'
let s:brightblue = 'NormalBlue'
let s:brightmagenta = 'NormalMagenta'
let s:brightcyan = 'NormalCyan'
if s:gt_eight
let s:normalred = 'BrightRed'
let s:normalgreen = 'BrightGreen'
let s:normalyellow = 'BrightYellow'
let s:normalblue = 'BrightBlue'
let s:normalmagenta = 'BrightMagenta'
let s:normalcyan = 'BrightCyan'
let s:cursoryellow = 'BrightYellow'
else
let s:normalred = s:brightred
let s:normalgreen = s:brightgreen
let s:normalyellow = s:brightyellow
let s:normalblue = s:brightblue
let s:normalmagenta = s:brightmagenta
let s:normalcyan = s:brightcyan
let s:cursoryellow = s:brightyellow
endif
endif
" Use something other than red if user has asked to use red only for errors
if exists('g:fromtermcolors_red_error_only') && g:fromtermcolors_red_error_only == 1
let s:alt_red = s:normalcyan
let s:dim_alt_red = s:normalcyan
else
let s:alt_red = s:brightred
let s:dim_alt_red = s:normalred
endif
if exists('g:fromtermcolors_color_map') " {{{
for [s:key, s:val] in items(g:fromtermcolors_color_map)
execute 'let s:' . s:key . ' = ' . s:val
endfor
endif
" }}}
" Highlight Groups (:h highlight-groups)
" call <SID>set_colors(group, fg, bg, attr)
if s:brightfg != s:brightbg " Needs to be different from Comment
call <SID>set_colors("ColorColumn" , "NONE" , s:brightbg , "")
call <SID>set_colors("CursorColumn" , "NONE" , s:brightbg , "")
if s:gt_eight " Only turn off bold if we have enough colors
call <SID>set_colors("CursorLine" , "" , "" , "underline")
else
call <SID>set_colors("CursorLine" , "" , "" , "underline")
endif
else
call <SID>set_colors("ColorColumn" , "NONE" , "NONE" , "")
call <SID>set_colors("CursorColumn" , "NONE" , "NONE" , "")
call <SID>set_colors("CursorLine" , "" , "" , "underline")
endif
call <SID>set_colors("Conceal" , "" , "NONE" , "")
call <SID>set_colors("Cursor" , "NONE" , s:cursoryellow , "reverse")
call <SID>set_colors("CursorIM" , "" , "" , "")
call <SID>set_colors("CursorLineNr" , s:cursoryellow , s:normalblue , "")
call <SID>set_colors("Directory" , s:brightblue , "" , "")
call <SID>set_colors("DiffAdd" , s:normalbg , s:normalgreen , "")
call <SID>set_colors("DiffDelete" , s:normalbg , s:normalred , "")
call <SID>set_colors("DiffChange" , s:normalbg , s:normalcyan , "")
call <SID>set_colors("DiffText" , s:normalbg , s:brightcyan , "NONE")
hi link EndOfBuffer NonText
call <SID>set_colors("ErrorMsg" , s:normalfg , s:normalred , "")
if s:brightfg != s:brightbg " Needs to be different from SignColumn
call <SID>set_colors("VertSplit" , s:normalblue , "" , "NONE")
else
call <SID>set_colors("VertSplit" , s:normalfg , s:normalfg , "reverse")
endif
if s:brightfg != s:brightbg
call <SID>set_colors("Folded" , s:brightfg , s:brightbg , "")
call <SID>set_colors("FoldColumn" , s:brightfg , s:brightbg , "")
call <SID>set_colors("SignColumn" , s:brightfg , s:brightbg , "")
else
call <SID>set_colors("Folded" , "NONE" , s:brightfg , "")
call <SID>set_colors("FoldColumn" , "NONE" , s:brightfg , "")
call <SID>set_colors("SignColumn" , "NONE" , s:brightfg , "")
endif
call <SID>set_colors("IncSearch" , s:normalblue , s:brightfg , "")
call <SID>set_colors("LineNr" , s:brightbg , "" , "")
call <SID>set_colors("MatchParen" , s:normalbg , s:brightfg , "")
call <SID>set_colors("ModeMsg" , s:brightgreen , "" , "")
call <SID>set_colors("MoreMsg" , s:brightgreen , "" , "")
call <SID>set_colors("NonText" , s:brightbg , "" , "")
if &background == "dark" && has('gui_running')
call <SID>set_colors("Normal" , "white" , "black" , "")
else
call <SID>set_colors("Normal" , "" , "" , "")
endif
call <SID>set_colors("PMenu" , s:normalfg , s:brightbg , "")
if s:brightfg != s:brightbg
call <SID>set_colors("PMenuSel" , s:cursoryellow , s:normalblue , "")
else
call <SID>set_colors("PMenuSel" , s:cursoryellow , s:normalfg , "")
endif
call <sid>set_colors("Cursor" , s:cursoryellow, s:normalbg, "")
call <sid>set_colors("CursorLine" , "", "", "")
call <sid>set_colors("NvimInternalError", s:normalred, "", "")
call <SID>set_colors("PMenuSbar" , s:normalfg, s:brightbg, "")
call <SID>set_colors("PMenuThumb" , s:normalfg, s:brightbg, "")
call <SID>set_colors("Question" , s:brightgreen, "", "")
call <SID>set_colors("RedrawDebugClear" , s:normalbg, "", "")
call <SID>set_colors("RedrawDebugComposed", s:normalbg, "", "")
call <SID>set_colors("RedrawDebugRecompose", s:normalbg, "", "")
call <SID>set_colors("Search" , s:normalblue, s:brightfg, "reverse")
call <SID>set_colors("SpecialKey" , s:brightbg, "", "")
call <SID>set_colors("SpellBad" , s:normalred, s:normalfg, "reverse")
call <SID>set_colors("SpellCap" , "", s:normalred, "reverse")
call <SID>set_colors("SpellLocal" , "", s:normalred, "reverse")
call <SID>set_colors("SpellRare" , s:normalred, s:normalfg, "reverse")
call <SID>set_colors("StatusLine" , s:normalyellow, "", "reverse")
call <SID>set_colors("StatusLineNC" , s:normalblue, s:brightbg, "")
call <SID>set_colors("StatusLineTerm" , s:brightgreen, "NONE", "reverse")
call <SID>set_colors("StatusLineTermNC" , s:normalgreen , "NONE", "reverse")
call <SID>set_colors("TabLine" , s:brightbg, s:normalblue, "NONE")
call <SID>set_colors("TabLineFill" , s:normalblue, s:brightfg, "")
call <SID>set_colors("TabLineSel" , s:normalfg, s:normalbg, "NONE")
call <SID>set_colors("Title" , s:brightyellow, "", "")
call <sid>set_colors("TermCursor" , s:cursoryellow, "", "")
call <sid>set_colors("TermCursorNC" , s:normalfg, "", "")
call <SID>set_colors("Visual" , "", s:normalblue, "")
call <SID>set_colors("VisualNOS" , s:brightbg, "", "")
call <SID>set_colors("WarningMsg" , s:brightred, s:brightbg, "")
call <SID>set_colors("WildMenu" , s:brightgreen, s:brightbg, "")
" End Highlight Groups
" Group Names (:h group-name) {{{
if (s:italic)
call <SID>set_colors("Comment", s:brightbg, "", "italic")
else
call <SID>set_colors("Comment", s:brightbg, "", "")
endif
call <SID>set_colors("Constant", s:brightgreen, "", "")
hi link String Constant
hi link Character Constant
hi link Number Constant
hi link Boolean Constant
hi link Float Constant
if s:gt_eight " Only turn off bold if we have enough colors
call <SID>set_colors("Identifier", s:brightcyan, "", "NONE")
else
call <SID>set_colors("Identifier", s:brightcyan, "", "")
endif
hi link Function Identifier
call <SID>set_colors("Statement", s:brightmagenta, "", "")
hi link Conditional Statement
hi link Repeat Statement
hi link Label Statement
hi link Operator Statement
hi link Keyword Statement
hi link Exception Statement
call <SID>set_colors("PreProc", s:brightblue, "", "")
hi link Include PreProc
hi link Define PreProc
hi link Macro PreProc
hi link PreCondit PreProc
call <SID>set_colors("Type", s:brightyellow, "", "")
hi link StorageClass Type
hi link Structure Type
hi link Typedef Type
call <SID>set_colors("Special", s:alt_red, "", "")
hi link SpecialChar Special
hi link Tag Special
hi link Delimiter Special
hi link SpecialComment Special
hi link Debug Special
call <SID>set_colors("Underlined" , s:normalfg , "" , "underline")
call <SID>set_colors("Ignore" , s:brightbg , "" , "")
call <SID>set_colors("Error" , s:brightred , "white" , "reverse")
call <SID>set_colors("Todo" , s:normalbg , s:brightyellow , "")
" End Group Names }}}
" Syntax-specific highlighting {{{
" From github.com/jsit/vim-tomorrow-theme
" Originally by Chris Kempson and contributors
" " Vim Highlighting
" exe 'hi link vimCommand Function'
"
" " C Highlighting
" call <SID>set_colors("cType" , s:brightyellow , "NONE" , "")
" call <SID>set_colors("cStorageClass" , s:brightmagenta , "NONE" , "")
" call <SID>set_colors("cConditional" , s:brightmagenta , "NONE" , "")
" call <SID>set_colors("cRepeat" , s:brightmagenta , "NONE" , "")
"
" " PHP Highlighting
" call <SID>set_colors("phpVarSelector" , s:alt_red , "NONE" , "")
" call <SID>set_colors("phpKeyword" , s:brightmagenta , "NONE" , "")
" call <SID>set_colors("phpRepeat" , s:brightmagenta , "NONE" , "")
" call <SID>set_colors("phpConditional" , s:brightmagenta , "NONE" , "")
" call <SID>set_colors("phpStatement" , s:brightmagenta , "NONE" , "")
" call <SID>set_colors("phpMemberSelector" , s:normalfg , "NONE" , "")
"
" " Ruby Highlighting
" call <SID>set_colors("rubySymbol" , s:brightgreen , "NONE" , "")
" call <SID>set_colors("rubyConstant" , s:brightyellow , "NONE" , "")
" call <SID>set_colors("rubyAttribute" , s:brightblue , "NONE" , "")
" call <SID>set_colors("rubyInclude" , s:brightblue , "NONE" , "")
" call <SID>set_colors("rubyLocalVariableOrMethod" , s:brightcyan , "NONE" , "")
" call <SID>set_colors("rubyCurlyBlock" , s:brightcyan , "NONE" , "")
" call <SID>set_colors("rubyStringDelimiter" , s:brightgreen , "NONE" , "")
" call <SID>set_colors("rubyInterpolationDelimiter" , s:brightcyan , "NONE" , "")
" call <SID>set_colors("rubyConditional" , s:brightmagenta , "NONE" , "")
" call <SID>set_colors("rubyRepeat" , s:brightmagenta , "NONE" , "")
"
" " Python Highlighting
" exe 'hi link pythonInclude Include'
" exe 'hi link pythonStatement Statement'
" exe 'hi link pythonConditional Conditional'
" exe 'hi link pythonRepeat Repeat'
" exe 'hi link pythonException Exception'
" exe 'hi link pythonFunction Function'
"
" " Go Highlighting
" exe 'hi link goStatement Statement'
" exe 'hi link goConditional Conditional'
" exe 'hi link goRepeat Repeat'
" exe 'hi link goException Exception'
" call <SID>set_colors("goDeclaration" , s:brightblue , "NONE" , "")
" exe 'hi link goConstants Constant'
" call <SID>set_colors("goBuiltins" , s:brightcyan , "NONE" , "")
"
" " CoffeeScript Highlighting
" exe 'hi link coffeeKeyword Keyword'
" exe 'hi link coffeeConditional Conditional'
"
" " JavaScript Highlighting
" exe 'hi link javaScriptBraces Normal'
" exe 'hi link javaScriptFunction Function'
" exe 'hi link javaScriptConditional Conditional'
" exe 'hi link javaScriptRepeat Repeat'
" exe 'hi link javaScriptNumber Number'
" exe 'hi link javaScriptMember Type'
"
" " HTML Highlighting
" hi link htmlTagName Type
" hi link htmlTag Type
" hi link htmlEndTag Type
" hi link htmlArg Statement
" hi link htmlSpecialTagName Statement
" hi link htmlScriptTag Statement
" vim-showmarks
call <SID>set_colors("ShowMarksHLl" , s:normalbg , s:brightblue , "")
call <SID>set_colors("ShowMarksHLu" , s:normalbg , s:brightblue , "")
call <SID>set_colors("ShowMarksHLo" , s:normalbg , s:brightblue , "")
" End syntax-specific highlighting }}}
" Clean up
delf <SID>set_colors
unlet s:brightbg s:brightfg s:normalbg s:normalfg s:brightblue s:brightyellow s:brightred s:brightgreen s:brightcyan s:brightmagenta s:cursoryellow s:normalred s:normalgreen s:normalcyan
" ex: set noexpandtab nolist foldmethod=marker: