dotfiles

config files for my linux setup
git clone git://edryd.org/dotfiles
Log | Files | Refs | README

jellybeans.vim (14838B)


      1 " Vim color file
      2 "
      3 "  "    __       _ _       _                             "
      4 "  "    \ \  ___| | |_   _| |__   ___  __ _ _ __  ___    "
      5 "  "     \ \/ _ \ | | | | |  _ \ / _ \/ _  |  _ \/ __|   "
      6 "  "  /\_/ /  __/ | | |_| | |_| |  __/ |_| | | | \__ \   "
      7 "  "  \___/ \___|_|_|\__  |____/ \___|\____|_| |_|___/   "
      8 "  "                 \___/                               "
      9 "
     10 "         "A colorful, dark color scheme for Vim."
     11 "
     12 " File:         jellybeans.vim
     13 " URL:          github.com/nanotech/jellybeans.vim
     14 " Scripts URL:  vim.org/scripts/script.php?script_id=2555
     15 " Maintainer:   NanoTech (nanotech.nanotechcorp.net)
     16 " Version:      1.6~git
     17 " Last Change:  January 15th, 2012
     18 " License:      MIT
     19 " Contributors: Daniel Herbert (pocketninja)
     20 "               Henry So, Jr. <henryso@panix.com>
     21 "               David Liang <bmdavll at gmail dot com>
     22 "               Rich Healey (richo)
     23 "               Andrew Wong (w0ng)
     24 "
     25 " Copyright (c) 2009-2012 NanoTech
     26 "
     27 " Permission is hereby granted, free of charge, to any per‐
     28 " son obtaining a copy of this software and associated doc‐
     29 " umentation  files  (the “Software”), to deal in the Soft‐
     30 " ware without restriction,  including  without  limitation
     31 " the rights to use, copy, modify, merge, publish, distrib‐
     32 " ute, sublicense, and/or sell copies of the Software,  and
     33 " to permit persons to whom the Software is furnished to do
     34 " so, subject to the following conditions:
     35 "
     36 " The above copyright notice  and  this  permission  notice
     37 " shall  be  included in all copies or substantial portions
     38 " of the Software.
     39 "
     40 " THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY
     41 " KIND,  EXPRESS  OR  IMPLIED, INCLUDING BUT NOT LIMITED TO
     42 " THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICU‐
     43 " LAR  PURPOSE  AND  NONINFRINGEMENT. IN NO EVENT SHALL THE
     44 " AUTHORS OR COPYRIGHT HOLDERS BE  LIABLE  FOR  ANY  CLAIM,
     45 " DAMAGES  OR OTHER LIABILITY, WHETHER IN AN ACTION OF CON‐
     46 " TRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON‐
     47 " NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
     48 " THE SOFTWARE.
     49 
     50 set background=dark
     51 
     52 hi clear
     53 
     54 if exists("syntax_on")
     55   syntax reset
     56 endif
     57 
     58 let colors_name = "jellybeans"
     59 
     60 if has("gui_running") || &t_Co == 88 || &t_Co == 256
     61   let s:low_color = 0
     62 else
     63   let s:low_color = 1
     64 endif
     65 
     66 " Color approximation functions by Henry So, Jr. and David Liang {{{
     67 " Added to jellybeans.vim by Daniel Herbert
     68 
     69 " returns an approximate grey index for the given grey level
     70 fun! s:grey_number(x)
     71   if &t_Co == 88
     72     if a:x < 23
     73       return 0
     74     elseif a:x < 69
     75       return 1
     76     elseif a:x < 103
     77       return 2
     78     elseif a:x < 127
     79       return 3
     80     elseif a:x < 150
     81       return 4
     82     elseif a:x < 173
     83       return 5
     84     elseif a:x < 196
     85       return 6
     86     elseif a:x < 219
     87       return 7
     88     elseif a:x < 243
     89       return 8
     90     else
     91       return 9
     92     endif
     93   else
     94     if a:x < 14
     95       return 0
     96     else
     97       let l:n = (a:x - 8) / 10
     98       let l:m = (a:x - 8) % 10
     99       if l:m < 5
    100         return l:n
    101       else
    102         return l:n + 1
    103       endif
    104     endif
    105   endif
    106 endfun
    107 
    108 " returns the actual grey level represented by the grey index
    109 fun! s:grey_level(n)
    110   if &t_Co == 88
    111     if a:n == 0
    112       return 0
    113     elseif a:n == 1
    114       return 46
    115     elseif a:n == 2
    116       return 92
    117     elseif a:n == 3
    118       return 115
    119     elseif a:n == 4
    120       return 139
    121     elseif a:n == 5
    122       return 162
    123     elseif a:n == 6
    124       return 185
    125     elseif a:n == 7
    126       return 208
    127     elseif a:n == 8
    128       return 231
    129     else
    130       return 255
    131     endif
    132   else
    133     if a:n == 0
    134       return 0
    135     else
    136       return 8 + (a:n * 10)
    137     endif
    138   endif
    139 endfun
    140 
    141 " returns the palette index for the given grey index
    142 fun! s:grey_color(n)
    143   if &t_Co == 88
    144     if a:n == 0
    145       return 16
    146     elseif a:n == 9
    147       return 79
    148     else
    149       return 79 + a:n
    150     endif
    151   else
    152     if a:n == 0
    153       return 16
    154     elseif a:n == 25
    155       return 231
    156     else
    157       return 231 + a:n
    158     endif
    159   endif
    160 endfun
    161 
    162 " returns an approximate color index for the given color level
    163 fun! s:rgb_number(x)
    164   if &t_Co == 88
    165     if a:x < 69
    166       return 0
    167     elseif a:x < 172
    168       return 1
    169     elseif a:x < 230
    170       return 2
    171     else
    172       return 3
    173     endif
    174   else
    175     if a:x < 75
    176       return 0
    177     else
    178       let l:n = (a:x - 55) / 40
    179       let l:m = (a:x - 55) % 40
    180       if l:m < 20
    181         return l:n
    182       else
    183         return l:n + 1
    184       endif
    185     endif
    186   endif
    187 endfun
    188 
    189 " returns the actual color level for the given color index
    190 fun! s:rgb_level(n)
    191   if &t_Co == 88
    192     if a:n == 0
    193       return 0
    194     elseif a:n == 1
    195       return 139
    196     elseif a:n == 2
    197       return 205
    198     else
    199       return 255
    200     endif
    201   else
    202     if a:n == 0
    203       return 0
    204     else
    205       return 55 + (a:n * 40)
    206     endif
    207   endif
    208 endfun
    209 
    210 " returns the palette index for the given R/G/B color indices
    211 fun! s:rgb_color(x, y, z)
    212   if &t_Co == 88
    213     return 16 + (a:x * 16) + (a:y * 4) + a:z
    214   else
    215     return 16 + (a:x * 36) + (a:y * 6) + a:z
    216   endif
    217 endfun
    218 
    219 " returns the palette index to approximate the given R/G/B color levels
    220 fun! s:color(r, g, b)
    221   " get the closest grey
    222   let l:gx = s:grey_number(a:r)
    223   let l:gy = s:grey_number(a:g)
    224   let l:gz = s:grey_number(a:b)
    225 
    226   " get the closest color
    227   let l:x = s:rgb_number(a:r)
    228   let l:y = s:rgb_number(a:g)
    229   let l:z = s:rgb_number(a:b)
    230 
    231   if l:gx == l:gy && l:gy == l:gz
    232     " there are two possibilities
    233     let l:dgr = s:grey_level(l:gx) - a:r
    234     let l:dgg = s:grey_level(l:gy) - a:g
    235     let l:dgb = s:grey_level(l:gz) - a:b
    236     let l:dgrey = (l:dgr * l:dgr) + (l:dgg * l:dgg) + (l:dgb * l:dgb)
    237     let l:dr = s:rgb_level(l:gx) - a:r
    238     let l:dg = s:rgb_level(l:gy) - a:g
    239     let l:db = s:rgb_level(l:gz) - a:b
    240     let l:drgb = (l:dr * l:dr) + (l:dg * l:dg) + (l:db * l:db)
    241     if l:dgrey < l:drgb
    242       " use the grey
    243       return s:grey_color(l:gx)
    244     else
    245       " use the color
    246       return s:rgb_color(l:x, l:y, l:z)
    247     endif
    248   else
    249     " only one possibility
    250     return s:rgb_color(l:x, l:y, l:z)
    251   endif
    252 endfun
    253 
    254 " returns the palette index to approximate the 'rrggbb' hex string
    255 fun! s:rgb(rgb)
    256   let l:r = ("0x" . strpart(a:rgb, 0, 2)) + 0
    257   let l:g = ("0x" . strpart(a:rgb, 2, 2)) + 0
    258   let l:b = ("0x" . strpart(a:rgb, 4, 2)) + 0
    259   return s:color(l:r, l:g, l:b)
    260 endfun
    261 
    262 " sets the highlighting for the given group
    263 fun! s:X(group, fg, bg, attr, lcfg, lcbg)
    264   if s:low_color
    265     let l:fge = empty(a:lcfg)
    266     let l:bge = empty(a:lcbg)
    267 
    268     if !l:fge && !l:bge
    269       exec "hi ".a:group." ctermfg=".a:lcfg." ctermbg=".a:lcbg
    270     elseif !l:fge && l:bge
    271       exec "hi ".a:group." ctermfg=".a:lcfg." ctermbg=NONE"
    272     elseif l:fge && !l:bge
    273       exec "hi ".a:group." ctermfg=NONE ctermbg=".a:lcbg
    274     endif
    275   else
    276     let l:fge = empty(a:fg)
    277     let l:bge = empty(a:bg)
    278 
    279     if !l:fge && !l:bge
    280       exec "hi ".a:group." guifg=#".a:fg." guibg=#".a:bg." ctermfg=".s:rgb(a:fg)." ctermbg=".s:rgb(a:bg)
    281     elseif !l:fge && l:bge
    282       exec "hi ".a:group." guifg=#".a:fg." guibg=NONE ctermfg=".s:rgb(a:fg)." ctermbg=NONE"
    283     elseif l:fge && !l:bge
    284       exec "hi ".a:group." guifg=NONE guibg=#".a:bg." ctermfg=NONE ctermbg=".s:rgb(a:bg)
    285     endif
    286   endif
    287 
    288   if a:attr == ""
    289     exec "hi ".a:group." gui=none cterm=none"
    290   else
    291     let l:noitalic = join(filter(split(a:attr, ","), "v:val !=? 'italic'"), ",")
    292     if empty(l:noitalic)
    293       let l:noitalic = "none"
    294     endif
    295     exec "hi ".a:group." gui=".a:attr." cterm=".l:noitalic
    296   endif
    297 endfun
    298 " }}}
    299 
    300 if !exists("g:jellybeans_background_color")
    301   let g:jellybeans_background_color = "151515"
    302 end
    303 
    304 call s:X("Normal","e8e8d3",g:jellybeans_background_color,"","White","")
    305 set background=dark
    306 
    307 if !exists("g:jellybeans_use_lowcolor_black") || g:jellybeans_use_lowcolor_black
    308     let s:termBlack = "Black"
    309 else
    310     let s:termBlack = "Grey"
    311 endif
    312 
    313 if version >= 700
    314   call s:X("CursorLine","","1c1c1c","","",s:termBlack)
    315   call s:X("CursorColumn","","1c1c1c","","",s:termBlack)
    316   call s:X("MatchParen","ffffff","556779","bold","","DarkCyan")
    317 
    318   call s:X("TabLine","000000","b0b8c0","italic","",s:termBlack)
    319   call s:X("TabLineFill","9098a0","","","",s:termBlack)
    320   call s:X("TabLineSel","000000","f0f0f0","italic,bold",s:termBlack,"White")
    321 
    322   " Auto-completion
    323   call s:X("Pmenu","ffffff","606060","","White",s:termBlack)
    324   call s:X("PmenuSel","101010","eeeeee","",s:termBlack,"White")
    325 endif
    326 
    327 call s:X("Visual","","404040","","",s:termBlack)
    328 call s:X("Cursor",g:jellybeans_background_color,"b0d0f0","","","")
    329 
    330 call s:X("LineNr","605958",g:jellybeans_background_color,"none",s:termBlack,"")
    331 call s:X("CursorLineNr","ccc5c4","","none","White","")
    332 call s:X("Comment","888888","","italic","Grey","")
    333 call s:X("Todo","c7c7c7","","bold","White",s:termBlack)
    334 
    335 call s:X("StatusLine","000000","dddddd","italic","","White")
    336 call s:X("StatusLineNC","ffffff","403c41","italic","White","Black")
    337 call s:X("VertSplit","777777","403c41","",s:termBlack,s:termBlack)
    338 call s:X("WildMenu","f0a0c0","302028","","Magenta","")
    339 
    340 call s:X("Folded","a0a8b0","384048","italic",s:termBlack,"")
    341 call s:X("FoldColumn","535D66","1f1f1f","","",s:termBlack)
    342 call s:X("SignColumn","777777","333333","","",s:termBlack)
    343 call s:X("ColorColumn","","000000","","",s:termBlack)
    344 
    345 call s:X("Title","70b950","","bold","Green","")
    346 
    347 call s:X("Constant","cf6a4c","","","Red","")
    348 call s:X("Special","799d6a","","","Green","")
    349 call s:X("Delimiter","668799","","","Grey","")
    350 
    351 call s:X("String","99ad6a","","","Green","")
    352 call s:X("StringDelimiter","556633","","","DarkGreen","")
    353 
    354 call s:X("Identifier","c6b6ee","","","LightCyan","")
    355 call s:X("Structure","8fbfdc","","","LightCyan","")
    356 call s:X("Function","fad07a","","","Yellow","")
    357 call s:X("Statement","8197bf","","","DarkBlue","")
    358 call s:X("PreProc","8fbfdc","","","LightBlue","")
    359 
    360 hi! link Operator Structure
    361 
    362 call s:X("Type","ffb964","","","Yellow","")
    363 call s:X("NonText","606060",g:jellybeans_background_color,"",s:termBlack,"")
    364 
    365 call s:X("SpecialKey","444444","1c1c1c","",s:termBlack,"")
    366 
    367 call s:X("Search","f0a0c0","302028","underline","Magenta","")
    368 
    369 call s:X("Directory","dad085","","","Yellow","")
    370 call s:X("ErrorMsg","","902020","","","DarkRed")
    371 hi! link Error ErrorMsg
    372 hi! link MoreMsg Special
    373 call s:X("Question","65C254","","","Green","")
    374 
    375 
    376 " Spell Checking
    377 
    378 call s:X("SpellBad","","902020","underline","","DarkRed")
    379 call s:X("SpellCap","","0000df","underline","","Blue")
    380 call s:X("SpellRare","","540063","underline","","DarkMagenta")
    381 call s:X("SpellLocal","","2D7067","underline","","Green")
    382 
    383 " Diff
    384 
    385 hi! link diffRemoved Constant
    386 hi! link diffAdded String
    387 
    388 " VimDiff
    389 
    390 call s:X("DiffAdd","D2EBBE","437019","","White","DarkGreen")
    391 call s:X("DiffDelete","40000A","700009","","DarkRed","DarkRed")
    392 call s:X("DiffChange","","2B5B77","","White","DarkBlue")
    393 call s:X("DiffText","8fbfdc","000000","reverse","Yellow","")
    394 
    395 " PHP
    396 
    397 hi! link phpFunctions Function
    398 call s:X("StorageClass","c59f6f","","","Red","")
    399 hi! link phpSuperglobal Identifier
    400 hi! link phpQuoteSingle StringDelimiter
    401 hi! link phpQuoteDouble StringDelimiter
    402 hi! link phpBoolean Constant
    403 hi! link phpNull Constant
    404 hi! link phpArrayPair Operator
    405 hi! link phpOperator Normal
    406 hi! link phpRelation Normal
    407 hi! link phpVarSelector Identifier
    408 
    409 " Python
    410 
    411 hi! link pythonOperator Statement
    412 
    413 " Ruby
    414 
    415 hi! link rubySharpBang Comment
    416 call s:X("rubyClass","447799","","","DarkBlue","")
    417 call s:X("rubyIdentifier","c6b6fe","","","Cyan","")
    418 hi! link rubyConstant Type
    419 hi! link rubyFunction Function
    420 
    421 call s:X("rubyInstanceVariable","c6b6fe","","","Cyan","")
    422 call s:X("rubySymbol","7697d6","","","Blue","")
    423 hi! link rubyGlobalVariable rubyInstanceVariable
    424 hi! link rubyModule rubyClass
    425 call s:X("rubyControl","7597c6","","","Blue","")
    426 
    427 hi! link rubyString String
    428 hi! link rubyStringDelimiter StringDelimiter
    429 hi! link rubyInterpolationDelimiter Identifier
    430 
    431 call s:X("rubyRegexpDelimiter","540063","","","Magenta","")
    432 call s:X("rubyRegexp","dd0093","","","DarkMagenta","")
    433 call s:X("rubyRegexpSpecial","a40073","","","Magenta","")
    434 
    435 call s:X("rubyPredefinedIdentifier","de5577","","","Red","")
    436 
    437 " Erlang
    438 
    439 hi! link erlangAtom rubySymbol
    440 hi! link erlangBIF rubyPredefinedIdentifier
    441 hi! link erlangFunction rubyPredefinedIdentifier
    442 hi! link erlangDirective Statement
    443 hi! link erlangNode Identifier
    444 
    445 " JavaScript
    446 
    447 hi! link javaScriptValue Constant
    448 hi! link javaScriptRegexpString rubyRegexp
    449 
    450 " CoffeeScript
    451 
    452 hi! link coffeeRegExp javaScriptRegexpString
    453 
    454 " Lua
    455 
    456 hi! link luaOperator Conditional
    457 
    458 " C
    459 
    460 hi! link cFormat Identifier
    461 hi! link cOperator Constant
    462 
    463 " Objective-C/Cocoa
    464 
    465 hi! link objcClass Type
    466 hi! link cocoaClass objcClass
    467 hi! link objcSubclass objcClass
    468 hi! link objcSuperclass objcClass
    469 hi! link objcDirective rubyClass
    470 hi! link objcStatement Constant
    471 hi! link cocoaFunction Function
    472 hi! link objcMethodName Identifier
    473 hi! link objcMethodArg Normal
    474 hi! link objcMessageName Identifier
    475 
    476 " Vimscript
    477 
    478 hi! link vimOper Normal
    479 
    480 " Debugger.vim
    481 
    482 call s:X("DbgCurrent","DEEBFE","345FA8","","White","DarkBlue")
    483 call s:X("DbgBreakPt","","4F0037","","","DarkMagenta")
    484 
    485 " vim-indent-guides
    486 
    487 if !exists("g:indent_guides_auto_colors")
    488   let g:indent_guides_auto_colors = 0
    489 endif
    490 call s:X("IndentGuidesOdd","","232323","","","")
    491 call s:X("IndentGuidesEven","","1b1b1b","","","")
    492 
    493 " Plugins, etc.
    494 
    495 hi! link TagListFileName Directory
    496 call s:X("PreciseJumpTarget","B9ED67","405026","","White","Green")
    497 
    498 if !exists("g:jellybeans_background_color_256")
    499   let g:jellybeans_background_color_256=233
    500 end
    501 " Manual overrides for 256-color terminals. Dark colors auto-map badly.
    502 if !s:low_color
    503   hi StatusLineNC ctermbg=235
    504   hi Folded ctermbg=236
    505   hi FoldColumn ctermbg=234
    506   hi SignColumn ctermbg=236
    507   hi CursorColumn ctermbg=234
    508   hi CursorLine ctermbg=234
    509   hi SpecialKey ctermbg=234
    510   exec "hi NonText ctermbg=".g:jellybeans_background_color_256
    511   exec "hi LineNr ctermbg=".g:jellybeans_background_color_256
    512   hi DiffText ctermfg=81
    513   exec "hi Normal ctermbg=".g:jellybeans_background_color_256
    514   hi DbgBreakPt ctermbg=53
    515   hi IndentGuidesOdd ctermbg=235
    516   hi IndentGuidesEven ctermbg=234
    517 endif
    518 
    519 if exists("g:jellybeans_overrides")
    520   fun! s:load_colors(defs)
    521     for [l:group, l:v] in items(a:defs)
    522       call s:X(l:group, get(l:v, 'guifg', ''), get(l:v, 'guibg', ''),
    523       \                 get(l:v, 'attr', ''),
    524       \                 get(l:v, 'ctermfg', ''), get(l:v, 'ctermbg', ''))
    525       if !s:low_color
    526         for l:prop in ['ctermfg', 'ctermbg']
    527           let l:override_key = '256'.l:prop
    528           if has_key(l:v, l:override_key)
    529             exec "hi ".l:group." ".l:prop."=".l:v[l:override_key]
    530           endif
    531         endfor
    532       endif
    533       unlet l:group
    534       unlet l:v
    535     endfor
    536   endfun
    537   call s:load_colors(g:jellybeans_overrides)
    538   delf s:load_colors
    539 endif
    540 
    541 " delete functions {{{
    542 delf s:X
    543 delf s:rgb
    544 delf s:color
    545 delf s:rgb_color
    546 delf s:rgb_level
    547 delf s:rgb_number
    548 delf s:grey_color
    549 delf s:grey_level
    550 delf s:grey_number
    551 " }}}