jellybeans.vim 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  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. set background=dark
  40. hi clear
  41. if exists("syntax_on")
  42. syntax reset
  43. endif
  44. let colors_name = "jellybeans"
  45. if has("gui_running") || &t_Co == 88 || &t_Co == 256
  46. let s:low_color = 0
  47. else
  48. let s:low_color = 1
  49. endif
  50. " Color approximation functions by Henry So, Jr. and David Liang {{{
  51. " Added to jellybeans.vim by Daniel Herbert
  52. " returns an approximate grey index for the given grey level
  53. fun! s:grey_number(x)
  54. if &t_Co == 88
  55. if a:x < 23
  56. return 0
  57. elseif a:x < 69
  58. return 1
  59. elseif a:x < 103
  60. return 2
  61. elseif a:x < 127
  62. return 3
  63. elseif a:x < 150
  64. return 4
  65. elseif a:x < 173
  66. return 5
  67. elseif a:x < 196
  68. return 6
  69. elseif a:x < 219
  70. return 7
  71. elseif a:x < 243
  72. return 8
  73. else
  74. return 9
  75. endif
  76. else
  77. if a:x < 14
  78. return 0
  79. else
  80. let l:n = (a:x - 8) / 10
  81. let l:m = (a:x - 8) % 10
  82. if l:m < 5
  83. return l:n
  84. else
  85. return l:n + 1
  86. endif
  87. endif
  88. endif
  89. endfun
  90. " returns the actual grey level represented by the grey index
  91. fun! s:grey_level(n)
  92. if &t_Co == 88
  93. if a:n == 0
  94. return 0
  95. elseif a:n == 1
  96. return 46
  97. elseif a:n == 2
  98. return 92
  99. elseif a:n == 3
  100. return 115
  101. elseif a:n == 4
  102. return 139
  103. elseif a:n == 5
  104. return 162
  105. elseif a:n == 6
  106. return 185
  107. elseif a:n == 7
  108. return 208
  109. elseif a:n == 8
  110. return 231
  111. else
  112. return 255
  113. endif
  114. else
  115. if a:n == 0
  116. return 0
  117. else
  118. return 8 + (a:n * 10)
  119. endif
  120. endif
  121. endfun
  122. " returns the palette index for the given grey index
  123. fun! s:grey_color(n)
  124. if &t_Co == 88
  125. if a:n == 0
  126. return 16
  127. elseif a:n == 9
  128. return 79
  129. else
  130. return 79 + a:n
  131. endif
  132. else
  133. if a:n == 0
  134. return 16
  135. elseif a:n == 25
  136. return 231
  137. else
  138. return 231 + a:n
  139. endif
  140. endif
  141. endfun
  142. " returns an approximate color index for the given color level
  143. fun! s:rgb_number(x)
  144. if &t_Co == 88
  145. if a:x < 69
  146. return 0
  147. elseif a:x < 172
  148. return 1
  149. elseif a:x < 230
  150. return 2
  151. else
  152. return 3
  153. endif
  154. else
  155. if a:x < 75
  156. return 0
  157. else
  158. let l:n = (a:x - 55) / 40
  159. let l:m = (a:x - 55) % 40
  160. if l:m < 20
  161. return l:n
  162. else
  163. return l:n + 1
  164. endif
  165. endif
  166. endif
  167. endfun
  168. " returns the actual color level for the given color index
  169. fun! s:rgb_level(n)
  170. if &t_Co == 88
  171. if a:n == 0
  172. return 0
  173. elseif a:n == 1
  174. return 139
  175. elseif a:n == 2
  176. return 205
  177. else
  178. return 255
  179. endif
  180. else
  181. if a:n == 0
  182. return 0
  183. else
  184. return 55 + (a:n * 40)
  185. endif
  186. endif
  187. endfun
  188. " returns the palette index for the given R/G/B color indices
  189. fun! s:rgb_color(x, y, z)
  190. if &t_Co == 88
  191. return 16 + (a:x * 16) + (a:y * 4) + a:z
  192. else
  193. return 16 + (a:x * 36) + (a:y * 6) + a:z
  194. endif
  195. endfun
  196. " returns the palette index to approximate the given R/G/B color levels
  197. fun! s:color(r, g, b)
  198. " get the closest grey
  199. let l:gx = s:grey_number(a:r)
  200. let l:gy = s:grey_number(a:g)
  201. let l:gz = s:grey_number(a:b)
  202. " get the closest color
  203. let l:x = s:rgb_number(a:r)
  204. let l:y = s:rgb_number(a:g)
  205. let l:z = s:rgb_number(a:b)
  206. if l:gx == l:gy && l:gy == l:gz
  207. " there are two possibilities
  208. let l:dgr = s:grey_level(l:gx) - a:r
  209. let l:dgg = s:grey_level(l:gy) - a:g
  210. let l:dgb = s:grey_level(l:gz) - a:b
  211. let l:dgrey = (l:dgr * l:dgr) + (l:dgg * l:dgg) + (l:dgb * l:dgb)
  212. let l:dr = s:rgb_level(l:gx) - a:r
  213. let l:dg = s:rgb_level(l:gy) - a:g
  214. let l:db = s:rgb_level(l:gz) - a:b
  215. let l:drgb = (l:dr * l:dr) + (l:dg * l:dg) + (l:db * l:db)
  216. if l:dgrey < l:drgb
  217. " use the grey
  218. return s:grey_color(l:gx)
  219. else
  220. " use the color
  221. return s:rgb_color(l:x, l:y, l:z)
  222. endif
  223. else
  224. " only one possibility
  225. return s:rgb_color(l:x, l:y, l:z)
  226. endif
  227. endfun
  228. " returns the palette index to approximate the 'rrggbb' hex string
  229. fun! s:rgb(rgb)
  230. let l:r = ("0x" . strpart(a:rgb, 0, 2)) + 0
  231. let l:g = ("0x" . strpart(a:rgb, 2, 2)) + 0
  232. let l:b = ("0x" . strpart(a:rgb, 4, 2)) + 0
  233. return s:color(l:r, l:g, l:b)
  234. endfun
  235. " sets the highlighting for the given group
  236. fun! s:X(group, fg, bg, attr, lcfg, lcbg)
  237. if s:low_color
  238. let l:fge = empty(a:lcfg)
  239. let l:bge = empty(a:lcbg)
  240. if !l:fge && !l:bge
  241. exec "hi ".a:group." ctermfg=".a:lcfg." ctermbg=".a:lcbg
  242. elseif !l:fge && l:bge
  243. exec "hi ".a:group." ctermfg=".a:lcfg." ctermbg=NONE"
  244. elseif l:fge && !l:bge
  245. exec "hi ".a:group." ctermfg=NONE ctermbg=".a:lcbg
  246. endif
  247. else
  248. let l:fge = empty(a:fg)
  249. let l:bge = empty(a:bg)
  250. if !l:fge && !l:bge
  251. exec "hi ".a:group." guifg=#".a:fg." guibg=#".a:bg." ctermfg=".s:rgb(a:fg)." ctermbg=".s:rgb(a:bg)
  252. elseif !l:fge && l:bge
  253. exec "hi ".a:group." guifg=#".a:fg." guibg=NONE ctermfg=".s:rgb(a:fg)
  254. elseif l:fge && !l:bge
  255. exec "hi ".a:group." guifg=NONE guibg=#".a:bg." ctermbg=".s:rgb(a:bg)
  256. endif
  257. endif
  258. if a:attr == ""
  259. exec "hi ".a:group." gui=none cterm=none"
  260. else
  261. if a:attr == 'italic'
  262. exec "hi ".a:group." gui=".a:attr." cterm=none"
  263. else
  264. exec "hi ".a:group." gui=".a:attr." cterm=".a:attr
  265. endif
  266. endif
  267. endfun
  268. " }}}
  269. if version >= 700
  270. call s:X("CursorLine","","1c1c1c","","","")
  271. call s:X("CursorColumn","","1c1c1c","","","")
  272. call s:X("MatchParen","ffffff","80a090","bold","","")
  273. call s:X("TabLine","000000","b0b8c0","italic","","Black")
  274. call s:X("TabLineFill","9098a0","","","","")
  275. call s:X("TabLineSel","000000","f0f0f0","italic,bold","","")
  276. " Auto-completion
  277. call s:X("Pmenu","ffffff","000000","","","")
  278. call s:X("PmenuSel","101010","eeeeee","","","")
  279. endif
  280. call s:X("Visual","","404040","","","")
  281. call s:X("Cursor","","b0d0f0","","","")
  282. call s:X("Normal","e8e8d3","151515","","White","")
  283. call s:X("LineNr","605958","151515","none","Black","")
  284. call s:X("Comment","888888","","italic","Grey","")
  285. call s:X("Todo","808080","","bold","","")
  286. call s:X("StatusLine","f0f0f0","101010","italic","","")
  287. call s:X("StatusLineNC","a0a0a0","181818","italic","","")
  288. call s:X("VertSplit","181818","181818","italic","","")
  289. call s:X("Folded","a0a8b0","384048","italic","black","")
  290. call s:X("FoldColumn","a0a8b0","384048","","","")
  291. call s:X("SignColumn","a0a8b0","384048","","","")
  292. call s:X("Title","70b950","","bold","","")
  293. call s:X("Constant","cf6a4c","","","Red","")
  294. call s:X("Special","799d6a","","","Green","")
  295. call s:X("Delimiter","668799","","","Grey","")
  296. call s:X("String","99ad6a","","","Green","")
  297. call s:X("StringDelimiter","556633","","","DarkGreen","")
  298. call s:X("Identifier","c6b6ee","","","LightCyan","")
  299. call s:X("Structure","8fbfdc","","","LightCyan","")
  300. call s:X("Function","fad07a","","","Yellow","")
  301. call s:X("Statement","8197bf","","","DarkBlue","")
  302. call s:X("PreProc","8fbfdc","","","LightBlue","")
  303. hi link Operator Normal
  304. call s:X("Type","ffb964","","","Yellow","")
  305. call s:X("NonText","808080","151515","","","")
  306. call s:X("SpecialKey","808080","343434","","","")
  307. call s:X("Search","f0a0c0","302028","underline","Magenta","")
  308. call s:X("Directory","dad085","","","","")
  309. call s:X("ErrorMsg","","902020","","","")
  310. hi link Error ErrorMsg
  311. " Diff
  312. hi link diffRemoved Constant
  313. hi link diffAdded String
  314. " VimDiff
  315. call s:X("DiffAdd","","032218","","Black","DarkGreen")
  316. call s:X("DiffChange","","100920","","Black","DarkMagenta")
  317. call s:X("DiffDelete","220000","220000","","DarkRed","DarkRed")
  318. call s:X("DiffText","","000940","","","DarkRed")
  319. " PHP
  320. hi link phpFunctions Function
  321. call s:X("StorageClass","c59f6f","","","Red","")
  322. hi link phpSuperglobal Identifier
  323. hi link phpQuoteSingle StringDelimiter
  324. hi link phpQuoteDouble StringDelimiter
  325. hi link phpBoolean Constant
  326. hi link phpNull Constant
  327. hi link phpArrayPair Operator
  328. " Ruby
  329. hi link rubySharpBang Comment
  330. call s:X("rubyClass","447799","","","DarkBlue","")
  331. call s:X("rubyIdentifier","c6b6fe","","","","")
  332. call s:X("rubyInstanceVariable","c6b6fe","","","Cyan","")
  333. call s:X("rubySymbol","7697d6","","","Blue","")
  334. hi link rubyGlobalVariable rubyInstanceVariable
  335. hi link rubyModule rubyClass
  336. call s:X("rubyControl","7597c6","","","","")
  337. hi link rubyString String
  338. hi link rubyStringDelimiter StringDelimiter
  339. hi link rubyInterpolationDelimiter Identifier
  340. call s:X("rubyRegexpDelimiter","540063","","","Magenta","")
  341. call s:X("rubyRegexp","dd0093","","","DarkMagenta","")
  342. call s:X("rubyRegexpSpecial","a40073","","","Magenta","")
  343. call s:X("rubyPredefinedIdentifier","de5577","","","Red","")
  344. " JavaScript
  345. hi link javaScriptValue Constant
  346. hi link javaScriptRegexpString rubyRegexp
  347. " Tag list
  348. hi link TagListFileName Directory
  349. " delete functions {{{
  350. delf s:X
  351. delf s:rgb
  352. delf s:color
  353. delf s:rgb_color
  354. delf s:rgb_level
  355. delf s:rgb_number
  356. delf s:grey_color
  357. delf s:grey_level
  358. delf s:grey_number
  359. " }}}