-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathColorizer.vmb
3219 lines (2982 loc) · 105 KB
/
Colorizer.vmb
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
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
" Vimball Archiver by Charles E. Campbell
UseVimball
finish
plugin/ColorizerPlugin.vim [[[1
95
" Plugin: Highlight Colornames and Values
" Maintainer: Christian Brabandt <cb@256bit.org>
" URL: http://www.github.com/chrisbra/color_highlight
" Last Change: Thu, 15 Jan 2015 21:49:17 +0100
" Licence: Vim License (see :h License)
" Version: 0.11
" GetLatestVimScripts: 3963 11 :AutoInstall: Colorizer.vim
"
" This plugin was inspired by the css_color.vim plugin from Nikolaus Hofer.
" Changes made: - make terminal colors work more reliably and with all
" color terminals
" - performance improvements, coloring is almost instantenously
" - detect rgb colors like this: rgb(R,G,B)
" - detect hsl coloring: hsl(H,V,L)
" - fix small bugs
" Init some variables "{{{1
" Plugin folklore "{{{2
if v:version < 700 || exists("g:loaded_colorizer") || &cp
finish
endif
let g:loaded_colorizer = 1
let s:cpo_save = &cpo
set cpo&vim
" helper functions "{{{1
fu! ColorHiArgs(A,L,P)
return "syntax\nmatch\nnosyntax\nnomatch"
endfu
" define commands "{{{1
command! -bang -range=% -nargs=? -complete=custom,ColorHiArgs ColorHighlight
\ :call Colorizer#DoColor(<q-bang>, <q-line1>, <q-line2>, <q-args>)
command! -bang -nargs=1 RGB2Term
\ :call Colorizer#RGB2Term(<q-args>, <q-bang>)
command! -nargs=1 Term2RGB :call Colorizer#Term2RGB(<q-args>)
command! -bang ColorClear :call Colorizer#ColorOff()
command! -bang ColorToggle :call Colorizer#ColorToggle()
command! -nargs=1 HSL2RGB :call Colorizer#HSL2Term(<q-args>)
command! ColorContrast :call Colorizer#SwitchContrast()
command! ColorSwapFgBg :call Colorizer#SwitchFGBG()
" define mappings "{{{1
nnoremap <Plug>Colorizer :<C-U>ColorToggle<CR>
xnoremap <Plug>Colorizer :ColorHighlight<CR>
nnoremap <Plug>ColorContrast :<C-U>ColorContrast<CR>
xnoremap <Plug>ColorContrast :<C-U>ColorContrast<CR>
nnoremap <Plug>ColorFgBg :<C-U>ColorSwapFgBg<CR>
xnoremap <Plug>ColorFgBg :<C-U>ColorSwapFgBg<CR>
if get(g:, 'colorizer_auto_map', 0)
" only map, if the mapped keys are not yet taken by a different plugin
" and the user hasn't mapped the function to different keys
if empty(maparg('<Leader>cC', 'n')) && empty(hasmapto('<Plug>Colorizer', 'n'))
nmap <silent> <Leader>cC <Plug>Colorizer
endif
if empty(maparg('<Leader>cC', 'x')) && empty(hasmapto('<Plug>Colorizer', 'x'))
xmap <silent> <Leader>cC <Plug>Colorizer
endif
if empty(maparg('<Leader>cT', 'n')) && empty(hasmapto('<Plug>ColorContrast', 'n'))
nmap <silent> <Leader>cT <Plug>ColorContrast
endif
if empty(maparg('<Leader>cT', 'x')) && empty(hasmapto('<Plug>ColorContrast', 'n'))
xmap <silent> <Leader>cT <Plug>ColorContrast
endif
if empty(maparg('<Leader>cF', 'n')) && empty(hasmapto('<Plug>ColorFgBg', 'n'))
nmap <silent> <Leader>cF <Plug>ColorFgBg
endif
if empty(maparg('<Leader>cF', 'x')) && empty(hasmapto('<Plug>ColorFgBg', 'x'))
xmap <silent> <Leader>cF <Plug>ColorFgBg
endif
endif
" Enable Autocommands "{{{1
if exists("g:colorizer_auto_color")
" Prevent autoloading
exe "call Colorizer#AutoCmds(g:colorizer_auto_color)"
endif
if exists("g:colorizer_auto_filetype")
" Setup some autocommands for specific filetypes.
aug FT_ColorizerPlugin
au!
exe "au Filetype" g:colorizer_auto_filetype
\ "call Colorizer#LocalFTAutoCmds(1)\|
\ :ColorHighlight"
aug END
endif
" Plugin folklore and Vim Modeline " {{{1
let &cpo = s:cpo_save
unlet s:cpo_save
" vim: set foldmethod=marker et fdl=0:
doc/Colorizer.txt [[[1
520
*Colorizer.txt* A plugin to color colornames and codes
Author: Christian Brabandt <cb@256bit.org>
Version: 0.11 Thu, 15 Jan 2015 21:49:17 +0100
Copyright: (c) 2009-2013 by Christian Brabandt
The VIM LICENSE applies to Colorizer.txt
(see |copyright|) except use ColorizerPlugin instead of "Vim".
NO WARRANTY, EXPRESS OR IMPLIED. USE AT-YOUR-OWN-RISK.
==============================================================================
Contents *Colorizer*
==============================================================================
1. Colorizer Manual.............................|Colorizer-manual|
1.1 :ColorHighlight......................|:ColorHighlight|
1.2 :ColorClear..........................|:ColorClear|
1.3 :RGB2Term............................|:RGB2Term|
1.4 :HSL2RGB.............................|:HSL2RGB|
1.5 :Term2RGB............................|:Term2RGB|
1.6 :ColorContrast.......................|:ColorContrast|
1.7 :ColorSwapFgBg.......................|:ColorSwapFgBg|
1.8 :ColorToggle.........................|:ColorToggle|
2. Configuration................................|Colorizer-config|
2.1 Automatic loading...................|Colorizer-auto|
2.2 Automatically highlight filetypes...|Colorizer-hl-ft|
2.3 Skip coloring comments..............|Colorizer-comments|
2.4 Adjust the contrast.................|Colorizer-contrast|
2.5 Highlight colornames................|Colorizer-hl-names|
2.6 Use X11 colornames..................|Colorizer-names|
2.7 Use syntax highlighting.............|Colorizer-syntax|
2.8 Specify patterns to highlight.......|Colorizer-pattern|
2.9 Colorizing Taskwarrior files........|Colorizer-taskwarrior-files|
2.10 Colorizing vim syntax files.........|Colorizer-vim-files|
2.11 Use custom colornames...............|Colorizer-custom-colornames|
2.12 Colorizing :hi statements...........|Colorizer-vim-hi|
3. Colorizer Mappings...........................|Colorizer-maps|
4. Colorizer Tips...............................|Colorizer-tips|
5. Colorizer Feedback...........................|Colorizer-feedback|
6. Colorizer History............................|Colorizer-history|
==============================================================================
1. Colorizer Manual *Colorizer-manual*
==============================================================================
Functionality
This plugin is based on the css_color plugin by Nikolaus Hofer. The idea is to
highlight color names and codes in the same color that they represent.
The plugin understands the W3C colors (used for CSS files for example), the
color names from the X11 Window System and also codes in hex notation, like
#FF0000 (which represents Red in the RGB color system). Additionally, it
supports the CSS color specifications, e.g. rgb(RR,GG,BB) color representation
in either absolute or percentage values and also the HVL color
representation like hvl(H,V,L)
It works best in the gui version of Vim, but the plugin also supports 256 and
88 color terminals and translates the colors to those supported by the
terminal. 16 and 8 color terminals should work theoretically too, but have not
been widely tested. Note that translating the colors to the terminal might
impose a performance penalty, depending on the terminal type and the number of
matches in the file.
This plugin defines the following commands:
*:ColorHighlight*
:[range]ColorHighlight[!] [args]
Scan the lines given by [range] for color code names and highlight those. If
[range] is omitted, the whole file will be scanned. If the ! is used, the
plugin will redefine all highlighting groups. If ! is not used, it will
skip patterns, that would take too long and make Vim unresponsive.
[args] can by any of "syntax" or "match". "syntax" means to convert the
highlighting to syntax highlighting. This is useful, so a plugin like
|2html.vim| can convert the colors correctly to HTML. The default is
"match", which uses the |matchadd()| function. (Prepending "no" is
supported and will disable that setting and use the opposite).
*:ColorClear*
:ColorClear Turn off color highlighting.
*:RGB2Term*
:RGB2Term <color> Translate the color code given as argument to
the closest color that can be displayed in the
terminal. The color must be given in the
format #RRGGBB (the hex format of the colors red,
green and blue (the '#' is optional), or
alternatively like rgb(X,X,X)
Uses the number of colors your terminal is capable
of (or 256 colors for gVim).
*:HSL2RGB*
:HSL2RGB hsl(h,v,l) Translate the HVL color defined by the string
'hsl(h,v%,l%)' into a color that the current
terminal can display. Note that the color must be
given in the format 'hsl(HH, V, L)' where HH
defines the Hue as absolute value between 0 and
255 and V and L represent a percentage for value
and Lightness.
*:Term2RGB*
:Term2RGB number Translate terminal color <number> to an RGB color
(using the xterm 256 color cube).
*:ColorContrast*
:ColorContrast Switch between all different color contrast
settings (foreground colors).
*:ColorSwapFgBg*
:ColorSwapFgBg Switch between foreground and background colors.
This will toggle in 3 ways. From Swapping
foreground and background colors, to only
highlighting the foreground color back to normal
foreground background color.
*:ColorToggle*
:ColorToggle Switch between highlighting colors and no
highlighting.
==============================================================================
2 Colorizer Configuration *Colorizer-config*
==============================================================================
2.1 Automatic loading *Colorizer-auto*
---------------------
The Colorizer plugin can be configured to automatically load when opening a
new file. Note that this might slow down the loading process, especially on
the terminal. To enable this, simply set the variable 'g:colorizer_auto_color'
to 1, e.g. by defining it in your |.vimrc| >
:let g:colorizer_auto_color = 1
<
(Not recommended, see below at |Colorizer-hl-ft| for the preferred way)
2.2 Automatically highlight filetypes *Colorizer-hl-ft*
-------------------------------------
If you want to have certain filetypes automatically highlighted, you can use
the variable g:colorizer_auto_filetype, e.g. to enable highlighting for
HTML and CSS files by default, add the following to your |.vimrc|: >
:let g:colorizer_auto_filetype='css,html'
<
After restarting Vim, the plugin will become active whenever the filetype is
set to either html or css.
2.3 Skip coloring comments *Colorizer-comments*
--------------------------
You can skip comments from being colored by setting the variable
g:colorizer_skip_comments to 1: >
:let g:colorizer_skip_comments = 1
<
The plugin will skip all matches of color codes and names that appear inside
comments (this only works when syntax highlighting is enabled |:syn-on|)
Note however, that if the same color is used inside comments and outside
comments, it will also be highlighted inside the comments, because
coloring is done matching only the color pattern and once this is done outside
of comments, this will also match inside comments.
2.4 Adjust the contrast *Colorizer-contrast*
-----------------------
Colorizer can be adjusted to blur the contrast between foreground and
background color. For this, the variable 'g:colorizer_fgcontrast' can be used.
It can be given any value between -1 and 2 with 2 being the default. Each
smaller value will decrease the contrast a little bit, with -1 being special,
as there is the foreground color equals the background color. Use
|:ColorContrast| to cycle through the different values.
2.5 Highlight colornames *Colorizer-hl-names*
------------------------
If for any reason you don't want the plugin to highlight colornames, you can
prevent this by setting the g:colorizer_colornames variable to 0, e.g. put >
:let g:colorizer_colornames = 0
<
into your |.vimrc|
2.6 Use X11 colornames *Colorizer-names*
----------------------
Colorizer can be configured to support all color names defined by the X11
Window System. By default it only supports the colors defined by the W3C for
the CSS specification. To use the X11 color names, set the variable
'g:colorzer_x11_names' to 1, e,g. put in your |.vimrc| >
let g:colorizer_x11_names = 1
<
2.7 Use syntax highlighting *Colorizer-syntax*
---------------------------
The plugin by default uses the |matchadd()| functions for highlighting colors
on the fly. Unfortunately, this is a problem, if you want to have the result
successfully transformed to a HTML file using the |2html.vim| plugin. Therefore,
the Colorizer plugin can also convert the highlighting to correct syntax
highlighting. Use either the >
:ColorHighlight syntax
<
command (see |:ColorHighlight|) or set the variable 'g:colorizer_syntax' to 1,
e.g. in your |.vimrc| put >
let g:colorizer_syntax = 1
<
2.8 Specify pattern to highlight *Colorizer-pattern*
--------------------------------
By default, Colorizer detects the following patterns and highlights them as
hex colors (for better readability it is separated into 3 parts): >
# %(\x\{3}\|\x\{6}\) \%(\>\|[-_]\)\@=/'
<
This means it always looks for a '#' followed by either a 3 or 6 hexadecimal
digits denoting the RGB hex color codes, followed by either the word-boundary
(|/\>|), a hyphen or a underscore. But only the first and middle part will be
highlighted (i.e. the RGB color codes).
You can of course specify a different pattern for your needs by setting the
g:colorizer_hex_pattern variable. e.g. to display '#RRGGBB' and have all of it
highlighted, use >
let g:colorizer_hex_pattern = ['#', '\%(\x\{3}\|\x\{6}\)', '']
2.9 Colorizing Taskwarrior files *Colorizer-taskwarrior-files*
--------------------------------
For taskwarrior files, this plugin can also highlight those colors. By
default, this will only work, if the file name ends with '.theme'
For an example, see this website:
http://taskwarrior.org/news/182
2.10 Colorizing vim syntax files *Colorizer-vim-files*
--------------------------------
Colorizer also supports highlighting vim syntax files. For this to work, the
'filetype' must be set to vim, then the plugin tries to identify the colors
and highlight them.
2.11 Use custom colornames *Colorizer-custom-colornames*
--------------------------
You can add separate colornames to be colored. For this to work, set the
variable g:colorizer_custom_colors to your liking, e.g. like this: >
let g:colorizer_custom_colors = { 'blue': '#ff0000'}
Guess what, this will color the word blue in red.
2.12 Colorizing :highlight statements *Colorizer-vim-hi*
-------------------------------------
Colorizer also supports highlighting |:hi| statements, that are used by vim
colorschemes and syntax files as well as a dump of the |:hi| command
To colorizer :hi statements, the 'filetype' must be set to vim, while for :hi
dumps, the 'filetype' must be empty.
==============================================================================
3. Colorizer Mappings *Colorizer-maps*
==============================================================================
By default, the Colorizer plugin does not map any key, so that it won't
pollute the global mapping namespace. If you want however to have the
following default maps set up, set the global variable g:colorizer_auto_map
in your |.vimrc| like this: >
:let g:colorizer_auto_map = 1
<
This will set up the following key mappings (if they are not already taken):
Keys Name Function
---- ---- --------
<Leader>cC <Plug>Colorizer Toggle highlighting of Colors. In visual
mode it only highlights the colors in the
selected region (normal and visual mode).
<Leader>cT <Plug>ColorContrast Cycle through contrast setting
|:ColorContrast| (normal and visual mode)
<Leader>cF <Plug>ColorFgBg Toggle foreground and background color
|:ColorSwapFgBg|
It uses the prefix <leader>c to set all functionality up. By default, <Leader>
is defined as '\' (|<Leader>|). Use the name provided in the second column to
map the function to a different key.
==============================================================================
4. Colorizer Tips *Colorizer-tips*
==============================================================================
You can enable the plugin to be loaded for certain filetypes automatically.
This makes sense for example for CSS files or HTML files. To do so, create the
following autocommand in your |.vimrc| >
:au BufNewFile,BufRead *.css,*.html,*.htm :ColorHighlight!
<
This will automatically highlight all existing color codes and names if you
edit either a HTML file or a CSS file. Note that this does not update the
highlighting, after you have been changing the file.
The recommended way to do this is to use the g:colorizer_auto_filetype
variable and set this to the desired filetypes. |Colorizer-hl-ft|
*Colorizer-slowdown*
----------------
Slow performance
----------------
Depending on your file, any of the highlighting functions might cause an
performance decrease. This can be analyed, by setting the variable
g:colorizer_debug to 1 in e.g. your |.vimrc| like this: >
:let g:colorizer_debug = 1
<
The next time, you call |:ColorHighlight|, the plugin will output runtime
statistics, from which you can see, which function caused the slowdowns.
Consider this output:
Colorstatistics at: 12:20 `
Duration: 0.034110 `
colornames: 0.030865s `
hex: 0.000968s `
hsla: 0.000350s `
rgb: 0.000354s `
rgba: 0.000491s `
taskwarrior: 0.000020s `
term: 0.000219s `
term_conceal: 0.000105s `
vimcolors: 0.000036s `
vimhighl_dump: 0.000025s `
vimhighlight: 0.000025s `
From this you can see, that the colorname highlighting caused the largest
slowdown, it took 0.03 seconds to complete. This is expected, as the
colornames pattern is long and contains many branches.
Functions with a value less then 100 have probably been skipped and were not
being executed.
If you want to skip certain functions, you can set the variable
g:colorizer_<name>_disable and then those functions won't be called anymore
(e.g. do disable the colorname highlighting, put in your |.vimrc| this: >
let g:colorizer_colornames_disable = 1
<
If the slowdown is still noticeable, you might want to create
a new issue at the plugins repository (|Colorizer-feedback|). You should
provide a sample file, so that I will be able to reproduce the issue.
Note, this needs a Vim with the |+reltime| feature.
==============================================================================
5. Colorizer Feedback *Colorizer-feedback*
==============================================================================
Feedback is always welcome. If you like the plugin, please rate it at the
vim-page: http://www.vim.org/scripts/script.php?script_id=3963
You can also follow the development of the plugin at github:
http://github.com/chrisbra/color_highlight
Bugs can also be reported there:
https://github.com/chrisbra/color_highlight/issues
Alternatively, you can also report any bugs to the maintainer, mentioned in
the third line of this document. Please don't hesitate to contact me, I
won't bite ;)
If you like the plugin, write me an email (look in the third line for my mail
address). And if you are really happy, vote for the plugin and consider
looking at my Amazon whishlist: http://www.amazon.de/wishlist/2BKAHE8J7Z6UW
==============================================================================
6. Colorizer History *Colorizer-history*
==============================================================================
0.12 (unreleased) {{{1
- TermConceal should also conceal [K
- properly escape terminal colors, so that |Colorizer-syntax| works correctly
- use matchaddpos() for highlighting ansi term colors (should speed up vim
highlighting considerably)
- only reset TermConceal syntax group (reported by audriusk in
https://github.com/chrisbra/Colorizer/issues/41, thanks!)
- correctly check for patch 7.4.083 (:keeppatterns modifier, reported by
gbell12 in https://github.com/chrisbra/Colorizer/issues/42, thanks!)
- disable BufLeave autocommand to disable colors
- basic Neovim support (also should work with TrueColor in Terminal)
- Make |:RGB2term| always init colortable, so that when resetting 't_Co'
it will work correctly
- Make it work with Vims Term Truecolor feature (patch 7.4.1770)
- Make it work with neovim fixes https://github.com/chrisbra/Colorizer/issues/45
and https://github.com/chrisbra/Colorizer/issues/46
- Support css colors: #rrggbbaa format
- handle hsla values correctly
- clear css cssColor syntax rule when ":ColorHighlight syntax" in css files is
used. fixes https://github.com/chrisbra/Colorizer/issues/50 reported by
msva, thanks!
- make TermConceal also hide the sgr0 attributes (to reset the terminal)
fixes https://github.com/chrisbra/Colorizer/issues/53 reported by
LucHermitte, thanks!
- also conceal and highlight nroff sequences like T^HT (as bold) and _^HT (as
underlined)
0.11 Jan 15, 2015 {{{1
- use |TextChanged| autocommand if possible
- Support Ansi True Color support if possible
- Hide ^[[K$ for terminal colors (reported by masukomi at
https://github.com/chrisbra/Colorizer/issues/36, thanks!)
- Do not expand() to expand shellvars (fixed by Daniel Hahler in
https://github.com/chrisbra/Colorizer/issues/37, thanks!)
- Document, how to analyze slowdown |Colorizer-slowdown|
- |:ColorContrast| would error, if the plugin has not been initialized
(reported by Daniel Hahler in
https://github.com/chrisbra/Colorizer/issues/38, thanks!)
- always define reltime variable (reported by mantislin in
https://github.com/chrisbra/Colorizer/issues/39, thanks!)
- Only call conceal function once for ansiterm colors
- reduce calls to DoColor in autocommands (to only do, when something changed)
0.10 Mar 27, 2014 {{{1
- Also highlight Ansi Term sequences
- Match colornames using the "old" RE Engine, if Vim supports it.
- Make |:RGB2Xterm| output the color name in its color
- Rename |:RGB2Xterm| to |:RGB2Term|
- Highlight Taskwarrior file
- Code refactoring
- Make |:ColorSwapFgBg| work as expected (did not always toggle reliably
between all states)
- Correctly parse Ansi Term colors
- |:Term2RGB|
- Highlight Vim color files correctly
- merge colorhighlight plugin https://github.com/blueyed/colorhighlight.vim
0.9: Aug 14, 2013: {{{1
- https://github.com/chrisbra/color_highlight/issues/15 (rgba highlighting
didn't work for floating point value of alpha, reported by LiTuX.S, thanks!)
- https://github.com/chrisbra/color_highlight/issues/16 (rgb() pattern did
match too much, reported by taecilla, thanks!)
- https://github.com/chrisbra/color_highlight/issues/19 (error on calling
ColorWinEnter() command, reported by wedgwood, thanks!)
- https://github.com/chrisbra/color_highlight/issues/20 and
https://github.com/chrisbra/color_highlight/issues/21
(also color on split commands, reported by wedgwood and Andri Möll, Thanks!)
- https://github.com/chrisbra/color_highlight/issues/22 (Make sure, patterns
like white-space won't get colored, reported by Andri Möll, Thanks!)
- https://github.com/chrisbra/color_highlight/issues/23 (ColorToggle got
confused when several windows with highlighting exists, reported by Andri
Möll, Thanks!)
- https://github.com/chrisbra/color_highlight/issues/24 (turning off coloring
should also remove the autocommands, reported by Andri Möll, Thanks!)
0.8: Dec 14, 2012 {{{1
- https://github.com/chrisbra/color_highlight/issues/13 (colorizing should not
stop at word-boundaries, reported by teschmitz, thanks!)
- https://github.com/chrisbra/color_highlight/issues/14 (convert highlighting
to syntax groups, so TOhtml works, reported by teschmitz, thanks!)
0.7: Jul 25, 2012 {{{1
- Highlight rgb colors with whitespace after comma (reported by sergey-vlasov
in https://github.com/chrisbra/color_highlight/issues/12, thanks!)
- Save and restore the search register, so the plugin doesn't clobber it
- check for 'ed' and 'gd' defaults
0.6: May 17, 2012 {{{1
- Fix various issues with hsl coloring (reported by teschmitz in
https://github.com/chrisbra/color_highlight/issues/9, thanks!)
- Make it possible, to skip coloring comments (reported by teschmitz in
https://github.com/chrisbra/color_highlight/issues/10, thanks!)
- search highlighting should overrule color highlighting(reported by teschmitz
in https://github.com/chrisbra/color_highlight/issues/11, thanks!)
- updated documentation (suggested by teschmitz, thanks!)
0.5: Apr 03, 2012 {{{1
- Fix issue 7 (reported by teschmitz in
https://github.com/chrisbra/color_highlight/issues/7, thanks!)
0.4: Mar, 23, 2012 {{{1
- |:ColorSwapFgBg| (suggested by teschmitz, in
https://github.com/chrisbra/color_highlight/issues/3, thanks!)
- make automatic color loading work (reported by wedgwood in
https://github.com/chrisbra/color_highlight/issues/6, thanks!)
|Colorizer-auto| and |Colorizer-hl-ft|
- more documentation updates
- added Mappings (suggested by Ingo Karkat, thanks!) |Colorizer-maps|
- prevent highlighting of color names (suggested by Tarlika Schmitz in
https://github.com/chrisbra/color_highlight/issues/5, thanks!)
|Colorizer-hl-names|
- enable filetype specific autocommands, so that for certain filetypes
colors are highlighted automatically |Colorizer-hl-ft|
(suggested by Tarlika Schmitz, thanks!)
0.3: Mar 15, 2012 {{{1
- Use the g:colorizer_fgcontrast variable to have lesser contrast between
foreground and background colors (patch by Ingo Karkat, thanks!)
- gvim did not color rgb(...) codes
- did not correctly highlight 3 letter color codes (issue
https://github.com/chrisbra/color_highlight/issues/1,
reported by Taybin Rutkin, thanks!)
- support autoloading (requested by Ingo Karkat, thanks!)
- add |GLVS| support
- |:ColorContrast| to interactively switch between contrast settings
(suggested by Ingo Karkat, thanks!)
0.2: Mar 02, 2012 {{{1
- Initial upload
- development versions are available at the github repository
- put plugin on a public repository
(http://github.com/chrisbra/color_highlight)
0.1: Mar 02, 2012 {{{1
- first internal version
}}}
==============================================================================
Modeline:
vim:tw=78:ts=8:ft=help:et:fdm=marker:fdl=0:norl
autoload/Colorizer.vim [[[1
2595
" Plugin: Highlight Colornames and Values
" Maintainer: Christian Brabandt <cb@256bit.org>
" URL: http://www.github.com/chrisbra/color_highlight
" Last Change: Thu, 15 Jan 2015 21:49:17 +0100
" Licence: Vim License (see :h License)
" Version: 0.11
" GetLatestVimScripts: 3963 11 :AutoInstall: Colorizer.vim
"
" This plugin was inspired by the css_color.vim plugin from Nikolaus Hofer.
" Changes made: - make terminal colors work more reliably and with all
" color terminals
" - performance improvements, coloring is almost instantenously
" - detect rgb colors like this: rgb(R,G,B)
" - detect hvl coloring: hvl(H,V,L)
" - fix small bugs
" - Color ANSI Term values and hide terminal escape sequences
" Init some variables "{{{1
let s:cpo_save = &cpo
set cpo&vim
" the 6 value iterations in the xterm color cube "{{{2
let s:valuerange6 = [ 0x00, 0x5F, 0x87, 0xAF, 0xD7, 0xFF ]
"" the 4 value iterations in the 88 color xterm cube "{{{2
let s:valuerange4 = [ 0x00, 0x8B, 0xCD, 0xFF ]
"
"" 16 basic colors "{{{2
let s:basic16 = [
\ [ 0x00, 0x00, 0x00 ],
\ [ 0xCD, 0x00, 0x00 ],
\ [ 0x00, 0xCD, 0x00 ],
\ [ 0xCD, 0xCD, 0x00 ],
\ [ 0x00, 0x00, 0xEE ],
\ [ 0xCD, 0x00, 0xCD ],
\ [ 0x00, 0xCD, 0xCD ],
\ [ 0xE5, 0xE5, 0xE5 ],
\ [ 0x7F, 0x7F, 0x7F ],
\ [ 0xFF, 0x00, 0x00 ],
\ [ 0x00, 0xFF, 0x00 ],
\ [ 0xFF, 0xFF, 0x00 ],
\ [ 0x5C, 0x5C, 0xFF ],
\ [ 0xFF, 0x00, 0xFF ],
\ [ 0x00, 0xFF, 0xFF ],
\ [ 0xFF, 0xFF, 0xFF ]
\ ]
" Cygwin / Window console / ConEmu has different color codes
if ($ComSpec =~# '^\%(command\.com\|cmd\.exe\)$' &&
\ !s:HasGui()) ||
\ (exists("$ConEmuPID") &&
\ $ConEmuANSI ==# "OFF") ||
\ ($TERM ==# 'cygwin' && &t_Co == 16) " Cygwin terminal
" command.com/ConEmu Color Cube (currently only supports 16 colors)
let s:basic16 = [
\ [ 0x00, 0x00, 0x00 ],
\ [ 0x00, 0x00, 0x80 ],
\ [ 0x00, 0x80, 0x00 ],
\ [ 0x00, 0x80, 0x80 ],
\ [ 0x80, 0x00, 0x00 ],
\ [ 0x80, 0x00, 0x80 ],
\ [ 0xFF, 0xFF, 0x00 ],
\ [ 0xFF, 0xFF, 0xFF ],
\ [ 0xC0, 0xC0, 0xC0 ],
\ [ 0x00, 0x00, 0xFF ],
\ [ 0x00, 0xFF, 0x00 ],
\ [ 0x00, 0xFF, 0xFF ],
\ [ 0xFF, 0x00, 0x00 ],
\ [ 0xFF, 0x00, 0xFF ],
\ [ 0xFF, 0xFF, 0x00 ],
\ [ 0xFF, 0xFF, 0xFF ]
\ ]
let &t_Co=16
endif
" xterm-8 colors "{{{2
let s:xterm_8colors = {
\ 'black': '#000000',
\ 'darkblue': '#00008B',
\ 'darkgreen': '#00CD00',
\ 'darkcyan': '#00CDCD',
\ 'darkred': '#CD0000',
\ 'darkmagenta': '#8B008B',
\ 'brown': '#CDCD00',
\ 'darkyellow': '#CDCD00',
\ 'lightgrey': '#E5E5E5',
\ 'lightgray': '#E5E5E5',
\ 'gray': '#E5E5E5',
\ 'grey': '#E5E5E5'
\ }
" xterm-16 colors "{{{2
let s:xterm_16colors = {
\ 'darkgrey': '#7F7F7F',
\ 'darkgray': '#7F7F7F',
\ 'blue': '#5C5CFF',
\ 'lightblue': '#5C5CFF',
\ 'green': '#00FF00',
\ 'lightgreen': '#00FF00',
\ 'cyan': '#00FFFF',
\ 'lightcyan': '#00FFFF',
\ 'red': '#FF0000',
\ 'lightred': '#FF0000',
\ 'magenta': '#FF00FF',
\ 'lightmagenta': '#FF00FF',
\ 'yellow': '#FFFF00',
\ 'lightyellow': '#FFFF00',
\ 'white': '#FFFFFF',
\ }
" add the items from the 8 color xterm variable to the 16 color xterm
call extend(s:xterm_16colors, s:xterm_8colors)
" W3C Colors "{{{2
let s:w3c_color_names = {
\ 'aliceblue': '#F0F8FF',
\ 'antiquewhite': '#FAEBD7',
\ 'aqua': '#00FFFF',
\ 'aquamarine': '#7FFFD4',
\ 'azure': '#F0FFFF',
\ 'beige': '#F5F5DC',
\ 'bisque': '#FFE4C4',
\ 'black': '#000000',
\ 'blanchedalmond': '#FFEBCD',
\ 'blue': '#0000FF',
\ 'blueviolet': '#8A2BE2',
\ 'brown': '#A52A2A',
\ 'burlywood': '#DEB887',
\ 'cadetblue': '#5F9EA0',
\ 'chartreuse': '#7FFF00',
\ 'chocolate': '#D2691E',
\ 'coral': '#FF7F50',
\ 'cornflowerblue': '#6495ED',
\ 'cornsilk': '#FFF8DC',
\ 'crimson': '#DC143C',
\ 'cyan': '#00FFFF',
\ 'darkblue': '#00008B',
\ 'darkcyan': '#008B8B',
\ 'darkgoldenrod': '#B8860B',
\ 'darkgray': '#A9A9A9',
\ 'darkgreen': '#006400',
\ 'darkkhaki': '#BDB76B',
\ 'darkmagenta': '#8B008B',
\ 'darkolivegreen': '#556B2F',
\ 'darkorange': '#FF8C00',
\ 'darkorchid': '#9932CC',
\ 'darkred': '#8B0000',
\ 'darksalmon': '#E9967A',
\ 'darkseagreen': '#8FBC8F',
\ 'darkslateblue': '#483D8B',
\ 'darkslategray': '#2F4F4F',
\ 'darkturquoise': '#00CED1',
\ 'darkviolet': '#9400D3',
\ 'deeppink': '#FF1493',
\ 'deepskyblue': '#00BFFF',
\ 'dimgray': '#696969',
\ 'dodgerblue': '#1E90FF',
\ 'firebrick': '#B22222',
\ 'floralwhite': '#FFFAF0',
\ 'forestgreen': '#228B22',
\ 'fuchsia': '#FF00FF',
\ 'gainsboro': '#DCDCDC',
\ 'ghostwhite': '#F8F8FF',
\ 'gold': '#FFD700',
\ 'goldenrod': '#DAA520',
\ 'gray': '#808080',
\ 'green': '#008000',
\ 'greenyellow': '#ADFF2F',
\ 'honeydew': '#F0FFF0',
\ 'hotpink': '#FF69B4',
\ 'indianred': '#CD5C5C',
\ 'indigo': '#4B0082',
\ 'ivory': '#FFFFF0',
\ 'khaki': '#F0E68C',
\ 'lavender': '#E6E6FA',
\ 'lavenderblush': '#FFF0F5',
\ 'lawngreen': '#7CFC00',
\ 'lemonchiffon': '#FFFACD',
\ 'lightblue': '#ADD8E6',
\ 'lightcoral': '#F08080',
\ 'lightcyan': '#E0FFFF',
\ 'lightgoldenrodyellow': '#FAFAD2',
\ 'lightgray': '#D3D3D3',
\ 'lightgreen': '#90EE90',
\ 'lightpink': '#FFB6C1',
\ 'lightsalmon': '#FFA07A',
\ 'lightseagreen': '#20B2AA',
\ 'lightskyblue': '#87CEFA',
\ 'lightslategray': '#778899',
\ 'lightsteelblue': '#B0C4DE',
\ 'lightyellow': '#FFFFE0',
\ 'lime': '#00FF00',
\ 'limegreen': '#32CD32',
\ 'linen': '#FAF0E6',
\ 'magenta': '#FF00FF',
\ 'maroon': '#800000',
\ 'mediumaquamarine': '#66CDAA',
\ 'mediumblue': '#0000CD',
\ 'mediumorchid': '#BA55D3',
\ 'mediumpurple': '#9370D8',
\ 'mediumseagreen': '#3CB371',
\ 'mediumslateblue': '#7B68EE',
\ 'mediumspringgreen': '#00FA9A',
\ 'mediumturquoise': '#48D1CC',
\ 'mediumvioletred': '#C71585',
\ 'midnightblue': '#191970',
\ 'mintcream': '#F5FFFA',
\ 'mistyrose': '#FFE4E1',
\ 'moccasin': '#FFE4B5',
\ 'navajowhite': '#FFDEAD',
\ 'navy': '#000080',
\ 'oldlace': '#FDF5E6',
\ 'olive': '#808000',
\ 'olivedrab': '#6B8E23',
\ 'orange': '#FFA500',
\ 'orangered': '#FF4500',
\ 'orchid': '#DA70D6',
\ 'palegoldenrod': '#EEE8AA',
\ 'palegreen': '#98FB98',
\ 'paleturquoise': '#AFEEEE',
\ 'palevioletred': '#D87093',
\ 'papayawhip': '#FFEFD5',
\ 'peachpuff': '#FFDAB9',
\ 'peru': '#CD853F',
\ 'pink': '#FFC0CB',
\ 'plum': '#DDA0DD',
\ 'powderblue': '#B0E0E6',
\ 'purple': '#800080',
\ 'red': '#FF0000',
\ 'rosybrown': '#BC8F8F',
\ 'royalblue': '#4169E1',
\ 'saddlebrown': '#8B4513',
\ 'salmon': '#FA8072',
\ 'sandybrown': '#F4A460',
\ 'seagreen': '#2E8B57',
\ 'seashell': '#FFF5EE',
\ 'sienna': '#A0522D',
\ 'silver': '#C0C0C0',
\ 'skyblue': '#87CEEB',
\ 'slateblue': '#6A5ACD',
\ 'slategray': '#708090',
\ 'snow': '#FFFAFA',
\ 'springgreen': '#00FF7F',
\ 'steelblue': '#4682B4',
\ 'tan': '#D2B48C',
\ 'teal': '#008080',
\ 'thistle': '#D8BFD8',
\ 'tomato': '#FF6347',
\ 'turquoise': '#40E0D0',
\ 'violet': '#EE82EE',
\ 'wheat': '#F5DEB3',
\ 'white': '#FFFFFF',
\ 'whitesmoke': '#F5F5F5',
\ 'yellow': '#FFFF00',
\ 'yellowgreen': '#9ACD32'
\ }
" X11 color names taken from "{{{2
" http://cvsweb.xfree86.org/cvsweb/*checkout*/xc/programs/rgb/rgb.txt?rev=1.2
let s:x11_color_names = {
\ 'snow': '#FFFAFA',
\ 'ghostwhite': '#F8F8FF',
\ 'whitesmoke': '#F5F5F5',
\ 'gainsboro': '#DCDCDC',
\ 'floralwhite': '#FFFAF0',
\ 'oldlace': '#FDF5E6',
\ 'linen': '#FAF0E6',
\ 'antiquewhite': '#FAEBD7',
\ 'papayawhip': '#FFEFD5',
\ 'blanchedalmond': '#FFEBCD',
\ 'bisque': '#FFE4C4',
\ 'peachpuff': '#FFDAB9',
\ 'navajowhite': '#FFDEAD',
\ 'moccasin': '#FFE4B5',
\ 'cornsilk': '#FFF8DC',
\ 'ivory': '#FFFFF0',
\ 'lemonchiffon': '#FFFACD',
\ 'seashell': '#FFF5EE',
\ 'honeydew': '#F0FFF0',
\ 'mintcream': '#F5FFFA',
\ 'azure': '#F0FFFF',
\ 'aliceblue': '#F0F8FF',
\ 'lavender': '#E6E6FA',
\ 'lavenderblush': '#FFF0F5',
\ 'mistyrose': '#FFE4E1',
\ 'white': '#FFFFFF',
\ 'black': '#000000',
\ 'darkslategray': '#2F4F4F',
\ 'darkslategrey': '#2F4F4F',
\ 'dimgray': '#696969',
\ 'dimgrey': '#696969',
\ 'slategray': '#708090',
\ 'slategrey': '#708090',
\ 'lightslategray': '#778899',
\ 'lightslategrey': '#778899',
\ 'gray': '#BEBEBE',
\ 'grey': '#BEBEBE',
\ 'lightgrey': '#D3D3D3',
\ 'lightgray': '#D3D3D3',
\ 'midnightblue': '#191970',
\ 'navy': '#000080',
\ 'navyblue': '#000080',
\ 'cornflowerblue': '#6495ED',
\ 'darkslateblue': '#483D8B',
\ 'slateblue': '#6A5ACD',
\ 'mediumslateblue': '#7B68EE',
\ 'lightslateblue': '#8470FF',
\ 'mediumblue': '#0000CD',
\ 'royalblue': '#4169E1',
\ 'blue': '#0000FF',
\ 'dodgerblue': '#1E90FF',
\ 'deepskyblue': '#00BFFF',
\ 'skyblue': '#87CEEB',
\ 'lightskyblue': '#87CEFA',
\ 'steelblue': '#4682B4',
\ 'lightsteelblue': '#B0C4DE',
\ 'lightblue': '#ADD8E6',
\ 'powderblue': '#B0E0E6',
\ 'paleturquoise': '#AFEEEE',
\ 'darkturquoise': '#00CED1',
\ 'mediumturquoise': '#48D1CC',
\ 'turquoise': '#40E0D0',
\ 'cyan': '#00FFFF',
\ 'lightcyan': '#E0FFFF',
\ 'cadetblue': '#5F9EA0',
\ 'mediumaquamarine': '#66CDAA',
\ 'aquamarine': '#7FFFD4',
\ 'darkgreen': '#006400',
\ 'darkolivegreen': '#556B2F',
\ 'darkseagreen': '#8FBC8F',
\ 'seagreen': '#2E8B57',
\ 'mediumseagreen': '#3CB371',
\ 'lightseagreen': '#20B2AA',
\ 'palegreen': '#98FB98',
\ 'springgreen': '#00FF7F',
\ 'lawngreen': '#7CFC00',
\ 'green': '#00FF00',
\ 'chartreuse': '#7FFF00',
\ 'mediumspringgreen': '#00FA9A',
\ 'greenyellow': '#ADFF2F',
\ 'limegreen': '#32CD32',
\ 'yellowgreen': '#9ACD32',
\ 'forestgreen': '#228B22',
\ 'olivedrab': '#6B8E23',
\ 'darkkhaki': '#BDB76B',
\ 'khaki': '#F0E68C',
\ 'palegoldenrod': '#EEE8AA',
\ 'lightgoldenrodyellow': '#FAFAD2',
\ 'lightyellow': '#FFFFE0',
\ 'yellow': '#FFFF00',
\ 'gold': '#FFD700',
\ 'lightgoldenrod': '#EEDD82',
\ 'goldenrod': '#DAA520',
\ 'darkgoldenrod': '#B8860B',
\ 'rosybrown': '#BC8F8F',
\ 'indianred': '#CD5C5C',
\ 'saddlebrown': '#8B4513',
\ 'sienna': '#A0522D',
\ 'peru': '#CD853F',
\ 'burlywood': '#DEB887',
\ 'beige': '#F5F5DC',
\ 'wheat': '#F5DEB3',
\ 'sandybrown': '#F4A460',
\ 'tan': '#D2B48C',
\ 'chocolate': '#D2691E',
\ 'firebrick': '#B22222',
\ 'brown': '#A52A2A',
\ 'darksalmon': '#E9967A',
\ 'salmon': '#FA8072',
\ 'lightsalmon': '#FFA07A',
\ 'orange': '#FFA500',
\ 'darkorange': '#FF8C00',
\ 'coral': '#FF7F50',
\ 'lightcoral': '#F08080',
\ 'tomato': '#FF6347',
\ 'orangered': '#FF4500',