jellybeans.vim (10269B)
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 " Maintainer: NanoTech <http://nanotech.nanotechcorp.net/> 14 " Version: 1.2 15 " Last Change: May 26th, 2009 16 " Contributors: Daniel Herbert <http://pocket-ninja.com>, 17 " Henry So, Jr. <henryso@panix.com>, 18 " David Liang <bmdavll at gmail dot com> 19 " 20 " Copyright (c) 2009 NanoTech 21 " 22 " Permission is hereby granted, free of charge, to any person obtaining a copy 23 " of this software and associated documentation files (the "Software"), to deal 24 " in the Software without restriction, including without limitation the rights 25 " to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 26 " copies of the Software, and to permit persons to whom the Software is 27 " furnished to do so, subject to the following conditions: 28 " 29 " The above copyright notice and this permission notice shall be included in 30 " all copies or substantial portions of the Software. 31 " 32 " THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 33 " IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 34 " FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 35 " AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 36 " LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 37 " OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 38 " THE SOFTWARE. 39 40 set background=dark 41 42 hi clear 43 44 if exists("syntax_on") 45 syntax reset 46 endif 47 48 let colors_name = "jellybeans" 49 50 if has("gui_running") || &t_Co == 88 || &t_Co == 256 51 let s:low_color = 0 52 else 53 let s:low_color = 1 54 endif 55 56 " Color approximation functions by Henry So, Jr. and David Liang {{{ 57 " Added to jellybeans.vim by Daniel Herbert 58 59 " returns an approximate grey index for the given grey level 60 fun! s:grey_number(x) 61 if &t_Co == 88 62 if a:x < 23 63 return 0 64 elseif a:x < 69 65 return 1 66 elseif a:x < 103 67 return 2 68 elseif a:x < 127 69 return 3 70 elseif a:x < 150 71 return 4 72 elseif a:x < 173 73 return 5 74 elseif a:x < 196 75 return 6 76 elseif a:x < 219 77 return 7 78 elseif a:x < 243 79 return 8 80 else 81 return 9 82 endif 83 else 84 if a:x < 14 85 return 0 86 else 87 let l:n = (a:x - 8) / 10 88 let l:m = (a:x - 8) % 10 89 if l:m < 5 90 return l:n 91 else 92 return l:n + 1 93 endif 94 endif 95 endif 96 endfun 97 98 " returns the actual grey level represented by the grey index 99 fun! s:grey_level(n) 100 if &t_Co == 88 101 if a:n == 0 102 return 0 103 elseif a:n == 1 104 return 46 105 elseif a:n == 2 106 return 92 107 elseif a:n == 3 108 return 115 109 elseif a:n == 4 110 return 139 111 elseif a:n == 5 112 return 162 113 elseif a:n == 6 114 return 185 115 elseif a:n == 7 116 return 208 117 elseif a:n == 8 118 return 231 119 else 120 return 255 121 endif 122 else 123 if a:n == 0 124 return 0 125 else 126 return 8 + (a:n * 10) 127 endif 128 endif 129 endfun 130 131 " returns the palette index for the given grey index 132 fun! s:grey_color(n) 133 if &t_Co == 88 134 if a:n == 0 135 return 16 136 elseif a:n == 9 137 return 79 138 else 139 return 79 + a:n 140 endif 141 else 142 if a:n == 0 143 return 16 144 elseif a:n == 25 145 return 231 146 else 147 return 231 + a:n 148 endif 149 endif 150 endfun 151 152 " returns an approximate color index for the given color level 153 fun! s:rgb_number(x) 154 if &t_Co == 88 155 if a:x < 69 156 return 0 157 elseif a:x < 172 158 return 1 159 elseif a:x < 230 160 return 2 161 else 162 return 3 163 endif 164 else 165 if a:x < 75 166 return 0 167 else 168 let l:n = (a:x - 55) / 40 169 let l:m = (a:x - 55) % 40 170 if l:m < 20 171 return l:n 172 else 173 return l:n + 1 174 endif 175 endif 176 endif 177 endfun 178 179 " returns the actual color level for the given color index 180 fun! s:rgb_level(n) 181 if &t_Co == 88 182 if a:n == 0 183 return 0 184 elseif a:n == 1 185 return 139 186 elseif a:n == 2 187 return 205 188 else 189 return 255 190 endif 191 else 192 if a:n == 0 193 return 0 194 else 195 return 55 + (a:n * 40) 196 endif 197 endif 198 endfun 199 200 " returns the palette index for the given R/G/B color indices 201 fun! s:rgb_color(x, y, z) 202 if &t_Co == 88 203 return 16 + (a:x * 16) + (a:y * 4) + a:z 204 else 205 return 16 + (a:x * 36) + (a:y * 6) + a:z 206 endif 207 endfun 208 209 " returns the palette index to approximate the given R/G/B color levels 210 fun! s:color(r, g, b) 211 " get the closest grey 212 let l:gx = s:grey_number(a:r) 213 let l:gy = s:grey_number(a:g) 214 let l:gz = s:grey_number(a:b) 215 216 " get the closest color 217 let l:x = s:rgb_number(a:r) 218 let l:y = s:rgb_number(a:g) 219 let l:z = s:rgb_number(a:b) 220 221 if l:gx == l:gy && l:gy == l:gz 222 " there are two possibilities 223 let l:dgr = s:grey_level(l:gx) - a:r 224 let l:dgg = s:grey_level(l:gy) - a:g 225 let l:dgb = s:grey_level(l:gz) - a:b 226 let l:dgrey = (l:dgr * l:dgr) + (l:dgg * l:dgg) + (l:dgb * l:dgb) 227 let l:dr = s:rgb_level(l:gx) - a:r 228 let l:dg = s:rgb_level(l:gy) - a:g 229 let l:db = s:rgb_level(l:gz) - a:b 230 let l:drgb = (l:dr * l:dr) + (l:dg * l:dg) + (l:db * l:db) 231 if l:dgrey < l:drgb 232 " use the grey 233 return s:grey_color(l:gx) 234 else 235 " use the color 236 return s:rgb_color(l:x, l:y, l:z) 237 endif 238 else 239 " only one possibility 240 return s:rgb_color(l:x, l:y, l:z) 241 endif 242 endfun 243 244 " returns the palette index to approximate the 'rrggbb' hex string 245 fun! s:rgb(rgb) 246 let l:r = ("0x" . strpart(a:rgb, 0, 2)) + 0 247 let l:g = ("0x" . strpart(a:rgb, 2, 2)) + 0 248 let l:b = ("0x" . strpart(a:rgb, 4, 2)) + 0 249 return s:color(l:r, l:g, l:b) 250 endfun 251 252 " sets the highlighting for the given group 253 fun! s:X(group, fg, bg, attr, lcfg, lcbg) 254 if s:low_color 255 let l:fge = empty(a:lcfg) 256 let l:bge = empty(a:lcbg) 257 258 if !l:fge && !l:bge 259 exec "hi ".a:group." ctermfg=".a:lcfg." ctermbg=".a:lcbg 260 elseif !l:fge && l:bge 261 exec "hi ".a:group." ctermfg=".a:lcfg." ctermbg=NONE" 262 elseif l:fge && !l:bge 263 exec "hi ".a:group." ctermfg=NONE ctermbg=".a:lcbg 264 endif 265 else 266 let l:fge = empty(a:fg) 267 let l:bge = empty(a:bg) 268 269 if !l:fge && !l:bge 270 exec "hi ".a:group." guifg=#".a:fg." guibg=#".a:bg." ctermfg=".s:rgb(a:fg)." ctermbg=".s:rgb(a:bg) 271 elseif !l:fge && l:bge 272 exec "hi ".a:group." guifg=#".a:fg." guibg=NONE ctermfg=".s:rgb(a:fg) 273 elseif l:fge && !l:bge 274 exec "hi ".a:group." guifg=NONE guibg=#".a:bg." ctermbg=".s:rgb(a:bg) 275 endif 276 endif 277 278 if a:attr == "" 279 exec "hi ".a:group." gui=none cterm=none" 280 else 281 if a:attr == 'italic' 282 exec "hi ".a:group." gui=".a:attr." cterm=none" 283 else 284 exec "hi ".a:group." gui=".a:attr." cterm=".a:attr 285 endif 286 endif 287 endfun 288 " }}} 289 290 if version >= 700 291 call s:X("CursorLine","","1c1c1c","","","") 292 call s:X("CursorColumn","","1c1c1c","","","") 293 call s:X("MatchParen","ffffff","80a090","bold","","") 294 295 call s:X("TabLine","000000","b0b8c0","italic","","Black") 296 call s:X("TabLineFill","9098a0","","","","") 297 call s:X("TabLineSel","000000","f0f0f0","italic,bold","","") 298 299 " Auto-completion 300 call s:X("Pmenu","ffffff","000000","","","") 301 call s:X("PmenuSel","101010","eeeeee","","","") 302 endif 303 304 call s:X("Visual","","404040","","","") 305 call s:X("Cursor","","b0d0f0","","","") 306 307 call s:X("Normal","e8e8d3","151515","","White","") 308 call s:X("LineNr","605958","151515","none","Black","") 309 call s:X("Comment","888888","","italic","Grey","") 310 call s:X("Todo","808080","","bold","","") 311 312 call s:X("StatusLine","f0f0f0","101010","italic","","") 313 call s:X("StatusLineNC","a0a0a0","181818","italic","","") 314 call s:X("VertSplit","181818","181818","italic","","") 315 316 call s:X("Folded","a0a8b0","384048","italic","black","") 317 call s:X("FoldColumn","a0a8b0","384048","","","") 318 call s:X("SignColumn","a0a8b0","384048","","","") 319 320 call s:X("Title","70b950","","bold","","") 321 322 call s:X("Constant","cf6a4c","","","Red","") 323 call s:X("Special","799d6a","","","Green","") 324 call s:X("Delimiter","668799","","","Grey","") 325 326 call s:X("String","99ad6a","","","Green","") 327 call s:X("StringDelimiter","556633","","","DarkGreen","") 328 329 call s:X("Identifier","c6b6ee","","","LightCyan","") 330 call s:X("Structure","8fbfdc","","","LightCyan","") 331 call s:X("Function","fad07a","","","Yellow","") 332 call s:X("Statement","8197bf","","","DarkBlue","") 333 call s:X("PreProc","8fbfdc","","","LightBlue","") 334 335 hi link Operator Normal 336 337 call s:X("Type","ffb964","","","Yellow","") 338 call s:X("NonText","808080","151515","","","") 339 340 call s:X("SpecialKey","808080","343434","","","") 341 342 call s:X("Search","f0a0c0","302028","underline","Magenta","") 343 344 call s:X("Directory","dad085","","","","") 345 call s:X("ErrorMsg","","902020","","","") 346 hi link Error ErrorMsg 347 348 " Diff 349 350 hi link diffRemoved Constant 351 hi link diffAdded String 352 353 " VimDiff 354 355 call s:X("DiffAdd","","032218","","Black","DarkGreen") 356 call s:X("DiffChange","","100920","","Black","DarkMagenta") 357 call s:X("DiffDelete","220000","220000","","DarkRed","DarkRed") 358 call s:X("DiffText","","000940","","","DarkRed") 359 360 " PHP 361 362 hi link phpFunctions Function 363 call s:X("StorageClass","c59f6f","","","Red","") 364 hi link phpSuperglobal Identifier 365 hi link phpQuoteSingle StringDelimiter 366 hi link phpQuoteDouble StringDelimiter 367 hi link phpBoolean Constant 368 hi link phpNull Constant 369 hi link phpArrayPair Operator 370 371 " Ruby 372 373 hi link rubySharpBang Comment 374 call s:X("rubyClass","447799","","","DarkBlue","") 375 call s:X("rubyIdentifier","c6b6fe","","","","") 376 377 call s:X("rubyInstanceVariable","c6b6fe","","","Cyan","") 378 call s:X("rubySymbol","7697d6","","","Blue","") 379 hi link rubyGlobalVariable rubyInstanceVariable 380 hi link rubyModule rubyClass 381 call s:X("rubyControl","7597c6","","","","") 382 383 hi link rubyString String 384 hi link rubyStringDelimiter StringDelimiter 385 hi link rubyInterpolationDelimiter Identifier 386 387 call s:X("rubyRegexpDelimiter","540063","","","Magenta","") 388 call s:X("rubyRegexp","dd0093","","","DarkMagenta","") 389 call s:X("rubyRegexpSpecial","a40073","","","Magenta","") 390 391 call s:X("rubyPredefinedIdentifier","de5577","","","Red","") 392 393 " JavaScript 394 hi link javaScriptValue Constant 395 hi link javaScriptRegexpString rubyRegexp 396 397 " Tag list 398 hi link TagListFileName Directory 399 400 " delete functions {{{ 401 delf s:X 402 delf s:rgb 403 delf s:color 404 delf s:rgb_color 405 delf s:rgb_level 406 delf s:rgb_number 407 delf s:grey_color 408 delf s:grey_level 409 delf s:grey_number 410 " }}}