-
-
Save dgl/510168 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use Text::VimColor; | |
# This is the output of :hi pasted in, season to taste | |
my $colors = <<EOF; | |
SpecialKey xxx term=bold cterm=bold ctermfg=4 guifg=Cyan | |
NonText xxx term=bold cterm=bold ctermfg=4 gui=bold guifg=Blue | |
Directory xxx term=bold cterm=bold ctermfg=6 guifg=Cyan | |
ErrorMsg xxx term=standout cterm=bold ctermfg=7 ctermbg=1 guifg=White guibg=Red | |
IncSearch xxx term=reverse cterm=reverse gui=reverse | |
Search xxx term=reverse ctermfg=0 ctermbg=3 guifg=Black guibg=Yellow | |
MoreMsg xxx term=bold cterm=bold ctermfg=2 gui=bold guifg=SeaGreen | |
ModeMsg xxx term=bold cterm=bold gui=bold | |
LineNr xxx term=underline cterm=bold ctermfg=3 guifg=Yellow | |
Question xxx term=standout cterm=bold ctermfg=2 gui=bold guifg=Green | |
StatusLine xxx term=bold,reverse cterm=bold,reverse gui=bold,reverse | |
StatusLineNC xxx term=reverse cterm=reverse gui=reverse | |
VertSplit xxx term=reverse cterm=reverse gui=reverse | |
Title xxx term=bold cterm=bold ctermfg=5 gui=bold guifg=Magenta | |
Visual xxx term=reverse cterm=reverse guibg=DarkGrey | |
VisualNOS xxx term=bold,underline cterm=bold,underline gui=bold,underline | |
WarningMsg xxx term=standout cterm=bold ctermfg=1 guifg=Red | |
WildMenu xxx term=standout ctermfg=0 ctermbg=3 guifg=Black guibg=Yellow | |
Folded xxx term=standout cterm=bold ctermfg=6 ctermbg=0 guifg=Cyan guibg=DarkGrey | |
FoldColumn xxx term=standout cterm=bold ctermfg=6 ctermbg=0 guifg=Cyan guibg=Grey | |
DiffAdd xxx term=bold ctermbg=4 guibg=DarkBlue | |
DiffChange xxx term=bold ctermbg=5 guibg=DarkMagenta | |
DiffDelete xxx term=bold cterm=bold ctermfg=4 ctermbg=6 gui=bold guifg=Blue guibg=DarkCyan | |
DiffText xxx term=reverse cterm=bold ctermbg=1 gui=bold guibg=Red | |
SignColumn xxx term=standout cterm=bold ctermfg=6 ctermbg=0 guifg=Cyan guibg=Grey | |
SpellBad xxx term=reverse cterm=underline gui=undercurl guisp=Red | |
SpellCap xxx term=reverse ctermbg=4 guisp=Blue | |
SpellRare xxx term=reverse ctermbg=5 gui=undercurl guisp=Magenta | |
SpellLocal xxx term=underline ctermbg=6 gui=undercurl guisp=Cyan | |
Pmenu xxx ctermbg=5 guibg=Magenta | |
PmenuSel xxx ctermbg=0 guibg=DarkGrey | |
PmenuSbar xxx ctermbg=7 guibg=Grey | |
PmenuThumb xxx cterm=reverse gui=reverse | |
TabLine xxx term=underline cterm=bold,underline ctermfg=7 ctermbg=0 gui=underline guibg=DarkGrey | |
TabLineSel xxx term=bold cterm=bold gui=bold | |
TabLineFill xxx term=reverse cterm=reverse gui=reverse | |
CursorColumn xxx term=reverse ctermbg=0 guibg=Grey40 | |
CursorLine xxx term=underline cterm=underline guibg=Grey40 | |
Cursor xxx guifg=bg guibg=fg | |
lCursor xxx guifg=bg guibg=fg | |
MatchParen xxx term=reverse ctermbg=6 guibg=DarkCyan | |
Normal xxx cleared | |
Comment xxx term=bold cterm=bold ctermfg=4 gui=bold guifg=#0000cc | |
Constant xxx term=underline ctermfg=1 guifg=#ffa0a0 | |
Special xxx term=bold cterm=bold ctermfg=5 guifg=Orange | |
Identifier xxx term=underline cterm=bold ctermfg=6 guifg=#40ffff | |
Statement xxx term=bold cterm=bold ctermfg=2 gui=bold guifg=#009900 | |
PreProc xxx term=underline cterm=bold ctermfg=5 guifg=#ff80ff | |
Type xxx term=underline ctermfg=2 gui=bold guifg=#60ff60 | |
Underlined xxx term=underline cterm=bold,underline ctermfg=4 gui=underline guifg=#80a0ff | |
Ignore xxx ctermfg=0 guifg=bg | |
Error xxx term=reverse cterm=bold ctermfg=7 ctermbg=1 guifg=White guibg=Red | |
Todo xxx term=standout ctermfg=0 ctermbg=3 guifg=Blue guibg=Yellow | |
String xxx links to Constant | |
Character xxx links to Constant | |
Number xxx links to Constant | |
Boolean xxx links to Constant | |
Float xxx links to Number | |
Function xxx links to Identifier | |
Conditional xxx links to Statement | |
Repeat xxx links to Statement | |
Label xxx links to Statement | |
Operator xxx links to Statement | |
Keyword xxx links to Statement | |
Exception xxx links to Statement | |
Include xxx links to PreProc | |
Define xxx links to PreProc | |
Macro xxx links to PreProc | |
PreCondit xxx links to PreProc | |
StorageClass xxx links to Type | |
Structure xxx links to Type | |
Typedef xxx links to Type | |
EOF | |
for(split /\n/, $colors) { | |
if(/(\w+).*(?:links to (.*)|ctermfg=(\d+))/) { | |
if($2) { # link | |
$color{$1} = $color{$2}; | |
} else { | |
$color{$1} = $3; | |
} | |
} | |
} | |
my $syntax = Text::VimColor->new( | |
file => $ARGV[0] | |
); | |
my $marked = $syntax->marked; | |
for(@$marked) { | |
if(my $color = $color{$_->[0]}) { | |
$color += 30; | |
print "\e[01;${color}m", $_->[1], "\e[0m" | |
} else { | |
print $_->[1]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment