tomorrowNight.vim 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498
  1. " Tomorrow Night - Full Colour and 256 Colour
  2. " http://chriskempson.com
  3. "
  4. " Hex colour conversion functions borrowed from the theme "Desert256""
  5. " Default GUI Colours
  6. let s:foreground = "c5c8c6"
  7. let s:background = "1d1f21"
  8. let s:selection = "373b41"
  9. let s:line = "282a2e"
  10. let s:comment = "969896"
  11. let s:red = "cc6666"
  12. let s:orange = "de935f"
  13. let s:yellow = "f0c674"
  14. let s:green = "b5bd68"
  15. let s:aqua = "8abeb7"
  16. let s:blue = "81a2be"
  17. let s:purple = "b294bb"
  18. let s:window = "4d5057"
  19. " Console 256 Colours
  20. if !has("gui_running")
  21. let s:background = "303030"
  22. let s:window = "5e5e5e"
  23. let s:line = "3a3a3a"
  24. let s:selection = "585858"
  25. end
  26. hi clear
  27. syntax reset
  28. let g:colors_name = "Tomorrow-Night"
  29. if has("gui_running") || &t_Co == 88 || &t_Co == 256
  30. " Returns an approximate grey index for the given grey level
  31. fun <SID>grey_number(x)
  32. if &t_Co == 88
  33. if a:x < 23
  34. return 0
  35. elseif a:x < 69
  36. return 1
  37. elseif a:x < 103
  38. return 2
  39. elseif a:x < 127
  40. return 3
  41. elseif a:x < 150
  42. return 4
  43. elseif a:x < 173
  44. return 5
  45. elseif a:x < 196
  46. return 6
  47. elseif a:x < 219
  48. return 7
  49. elseif a:x < 243
  50. return 8
  51. else
  52. return 9
  53. endif
  54. else
  55. if a:x < 14
  56. return 0
  57. else
  58. let l:n = (a:x - 8) / 10
  59. let l:m = (a:x - 8) % 10
  60. if l:m < 5
  61. return l:n
  62. else
  63. return l:n + 1
  64. endif
  65. endif
  66. endif
  67. endfun
  68. " Returns the actual grey level represented by the grey index
  69. fun <SID>grey_level(n)
  70. if &t_Co == 88
  71. if a:n == 0
  72. return 0
  73. elseif a:n == 1
  74. return 46
  75. elseif a:n == 2
  76. return 92
  77. elseif a:n == 3
  78. return 115
  79. elseif a:n == 4
  80. return 139
  81. elseif a:n == 5
  82. return 162
  83. elseif a:n == 6
  84. return 185
  85. elseif a:n == 7
  86. return 208
  87. elseif a:n == 8
  88. return 231
  89. else
  90. return 255
  91. endif
  92. else
  93. if a:n == 0
  94. return 0
  95. else
  96. return 8 + (a:n * 10)
  97. endif
  98. endif
  99. endfun
  100. " Returns the palette index for the given grey index
  101. fun <SID>grey_colour(n)
  102. if &t_Co == 88
  103. if a:n == 0
  104. return 16
  105. elseif a:n == 9
  106. return 79
  107. else
  108. return 79 + a:n
  109. endif
  110. else
  111. if a:n == 0
  112. return 16
  113. elseif a:n == 25
  114. return 231
  115. else
  116. return 231 + a:n
  117. endif
  118. endif
  119. endfun
  120. " Returns an approximate colour index for the given colour level
  121. fun <SID>rgb_number(x)
  122. if &t_Co == 88
  123. if a:x < 69
  124. return 0
  125. elseif a:x < 172
  126. return 1
  127. elseif a:x < 230
  128. return 2
  129. else
  130. return 3
  131. endif
  132. else
  133. if a:x < 75
  134. return 0
  135. else
  136. let l:n = (a:x - 55) / 40
  137. let l:m = (a:x - 55) % 40
  138. if l:m < 20
  139. return l:n
  140. else
  141. return l:n + 1
  142. endif
  143. endif
  144. endif
  145. endfun
  146. " Returns the actual colour level for the given colour index
  147. fun <SID>rgb_level(n)
  148. if &t_Co == 88
  149. if a:n == 0
  150. return 0
  151. elseif a:n == 1
  152. return 139
  153. elseif a:n == 2
  154. return 205
  155. else
  156. return 255
  157. endif
  158. else
  159. if a:n == 0
  160. return 0
  161. else
  162. return 55 + (a:n * 40)
  163. endif
  164. endif
  165. endfun
  166. " Returns the palette index for the given R/G/B colour indices
  167. fun <SID>rgb_colour(x, y, z)
  168. if &t_Co == 88
  169. return 16 + (a:x * 16) + (a:y * 4) + a:z
  170. else
  171. return 16 + (a:x * 36) + (a:y * 6) + a:z
  172. endif
  173. endfun
  174. " Returns the palette index to approximate the given R/G/B colour levels
  175. fun <SID>colour(r, g, b)
  176. " Get the closest grey
  177. let l:gx = <SID>grey_number(a:r)
  178. let l:gy = <SID>grey_number(a:g)
  179. let l:gz = <SID>grey_number(a:b)
  180. " Get the closest colour
  181. let l:x = <SID>rgb_number(a:r)
  182. let l:y = <SID>rgb_number(a:g)
  183. let l:z = <SID>rgb_number(a:b)
  184. if l:gx == l:gy && l:gy == l:gz
  185. " There are two possibilities
  186. let l:dgr = <SID>grey_level(l:gx) - a:r
  187. let l:dgg = <SID>grey_level(l:gy) - a:g
  188. let l:dgb = <SID>grey_level(l:gz) - a:b
  189. let l:dgrey = (l:dgr * l:dgr) + (l:dgg * l:dgg) + (l:dgb * l:dgb)
  190. let l:dr = <SID>rgb_level(l:gx) - a:r
  191. let l:dg = <SID>rgb_level(l:gy) - a:g
  192. let l:db = <SID>rgb_level(l:gz) - a:b
  193. let l:drgb = (l:dr * l:dr) + (l:dg * l:dg) + (l:db * l:db)
  194. if l:dgrey < l:drgb
  195. " Use the grey
  196. return <SID>grey_colour(l:gx)
  197. else
  198. " Use the colour
  199. return <SID>rgb_colour(l:x, l:y, l:z)
  200. endif
  201. else
  202. " Only one possibility
  203. return <SID>rgb_colour(l:x, l:y, l:z)
  204. endif
  205. endfun
  206. " Returns the palette index to approximate the 'rrggbb' hex string
  207. fun <SID>rgb(rgb)
  208. let l:r = ("0x" . strpart(a:rgb, 0, 2)) + 0
  209. let l:g = ("0x" . strpart(a:rgb, 2, 2)) + 0
  210. let l:b = ("0x" . strpart(a:rgb, 4, 2)) + 0
  211. return <SID>colour(l:r, l:g, l:b)
  212. endfun
  213. " Sets the highlighting for the given group
  214. fun <SID>X(group, fg, bg, attr)
  215. if a:fg != ""
  216. exec "hi " . a:group . " guifg=#" . a:fg . " ctermfg=" . <SID>rgb(a:fg)
  217. endif
  218. if a:bg != ""
  219. exec "hi " . a:group . " guibg=#" . a:bg . " ctermbg=" . <SID>rgb(a:bg)
  220. endif
  221. if a:attr != ""
  222. exec "hi " . a:group . " gui=" . a:attr . " cterm=" . a:attr
  223. endif
  224. endfun
  225. " Vim Highlighting
  226. call <SID>X("Normal", s:foreground, s:background, "")
  227. call <SID>X("LineNr", s:selection, "", "")
  228. call <SID>X("NonText", s:selection, "", "")
  229. call <SID>X("SpecialKey", s:selection, "", "")
  230. call <SID>X("Search", s:background, s:yellow, "")
  231. call <SID>X("TabLine", s:window, s:foreground, "reverse")
  232. call <SID>X("TabLineFill", s:window, s:foreground, "reverse")
  233. call <SID>X("StatusLine", s:window, s:yellow, "reverse")
  234. call <SID>X("StatusLineNC", s:window, s:foreground, "reverse")
  235. call <SID>X("VertSplit", s:window, s:window, "none")
  236. call <SID>X("Visual", "", s:selection, "")
  237. call <SID>X("Directory", s:blue, "", "")
  238. call <SID>X("ModeMsg", s:green, "", "")
  239. call <SID>X("MoreMsg", s:green, "", "")
  240. call <SID>X("Question", s:green, "", "")
  241. call <SID>X("WarningMsg", s:red, "", "")
  242. call <SID>X("MatchParen", "", s:selection, "")
  243. call <SID>X("Folded", s:comment, s:background, "")
  244. call <SID>X("FoldColumn", "", s:background, "")
  245. if version >= 700
  246. call <SID>X("CursorLine", "", s:line, "none")
  247. call <SID>X("CursorColumn", "", s:line, "none")
  248. call <SID>X("PMenu", s:foreground, s:selection, "none")
  249. call <SID>X("PMenuSel", s:foreground, s:selection, "reverse")
  250. call <SID>X("SignColumn", "", s:background, "none")
  251. end
  252. if version >= 703
  253. call <SID>X("ColorColumn", "", s:line, "none")
  254. end
  255. " Standard Highlighting
  256. call <SID>X("Comment", s:comment, "", "")
  257. call <SID>X("Todo", s:comment, s:background, "")
  258. call <SID>X("Title", s:comment, "", "")
  259. call <SID>X("Identifier", s:red, "", "none")
  260. call <SID>X("Statement", s:foreground, "", "")
  261. call <SID>X("Conditional", s:foreground, "", "")
  262. call <SID>X("Repeat", s:foreground, "", "")
  263. call <SID>X("Structure", s:purple, "", "")
  264. call <SID>X("Function", s:blue, "", "")
  265. call <SID>X("Constant", s:orange, "", "")
  266. call <SID>X("Keyword", s:orange, "", "")
  267. call <SID>X("String", s:green, "", "")
  268. call <SID>X("Special", s:foreground, "", "")
  269. call <SID>X("PreProc", s:purple, "", "")
  270. call <SID>X("Operator", s:aqua, "", "none")
  271. call <SID>X("Type", s:blue, "", "none")
  272. call <SID>X("Define", s:purple, "", "none")
  273. call <SID>X("Include", s:blue, "", "")
  274. "call <SID>X("Ignore", "666666", "", "")
  275. " Vim Highlighting
  276. call <SID>X("vimCommand", s:red, "", "none")
  277. " C Highlighting
  278. call <SID>X("cType", s:yellow, "", "")
  279. call <SID>X("cStorageClass", s:purple, "", "")
  280. call <SID>X("cConditional", s:purple, "", "")
  281. call <SID>X("cRepeat", s:purple, "", "")
  282. " PHP Highlighting
  283. call <SID>X("phpVarSelector", s:red, "", "")
  284. call <SID>X("phpKeyword", s:purple, "", "")
  285. call <SID>X("phpRepeat", s:purple, "", "")
  286. call <SID>X("phpConditional", s:purple, "", "")
  287. call <SID>X("phpStatement", s:purple, "", "")
  288. call <SID>X("phpMemberSelector", s:foreground, "", "")
  289. " Ruby Highlighting
  290. call <SID>X("rubySymbol", s:green, "", "")
  291. call <SID>X("rubyConstant", s:yellow, "", "")
  292. call <SID>X("rubyAccess", s:yellow, "", "")
  293. call <SID>X("rubyAttribute", s:blue, "", "")
  294. call <SID>X("rubyInclude", s:blue, "", "")
  295. call <SID>X("rubyLocalVariableOrMethod", s:orange, "", "")
  296. call <SID>X("rubyCurlyBlock", s:orange, "", "")
  297. call <SID>X("rubyStringDelimiter", s:green, "", "")
  298. call <SID>X("rubyInterpolationDelimiter", s:orange, "", "")
  299. call <SID>X("rubyConditional", s:purple, "", "")
  300. call <SID>X("rubyRepeat", s:purple, "", "")
  301. call <SID>X("rubyControl", s:purple, "", "")
  302. call <SID>X("rubyException", s:purple, "", "")
  303. " Crystal Highlighting
  304. call <SID>X("crystalSymbol", s:green, "", "")
  305. call <SID>X("crystalConstant", s:yellow, "", "")
  306. call <SID>X("crystalAccess", s:yellow, "", "")
  307. call <SID>X("crystalAttribute", s:blue, "", "")
  308. call <SID>X("crystalInclude", s:blue, "", "")
  309. call <SID>X("crystalLocalVariableOrMethod", s:orange, "", "")
  310. call <SID>X("crystalCurlyBlock", s:orange, "", "")
  311. call <SID>X("crystalStringDelimiter", s:green, "", "")
  312. call <SID>X("crystalInterpolationDelimiter", s:orange, "", "")
  313. call <SID>X("crystalConditional", s:purple, "", "")
  314. call <SID>X("crystalRepeat", s:purple, "", "")
  315. call <SID>X("crystalControl", s:purple, "", "")
  316. call <SID>X("crystalException", s:purple, "", "")
  317. " Python Highlighting
  318. call <SID>X("pythonInclude", s:purple, "", "")
  319. call <SID>X("pythonStatement", s:purple, "", "")
  320. call <SID>X("pythonConditional", s:purple, "", "")
  321. call <SID>X("pythonRepeat", s:purple, "", "")
  322. call <SID>X("pythonException", s:purple, "", "")
  323. call <SID>X("pythonFunction", s:blue, "", "")
  324. call <SID>X("pythonPreCondit", s:purple, "", "")
  325. call <SID>X("pythonRepeat", s:aqua, "", "")
  326. call <SID>X("pythonExClass", s:orange, "", "")
  327. " JavaScript Highlighting
  328. call <SID>X("javaScriptBraces", s:foreground, "", "")
  329. call <SID>X("javaScriptFunction", s:purple, "", "")
  330. call <SID>X("javaScriptConditional", s:purple, "", "")
  331. call <SID>X("javaScriptRepeat", s:purple, "", "")
  332. call <SID>X("javaScriptNumber", s:orange, "", "")
  333. call <SID>X("javaScriptMember", s:orange, "", "")
  334. call <SID>X("javascriptNull", s:orange, "", "")
  335. call <SID>X("javascriptGlobal", s:blue, "", "")
  336. call <SID>X("javascriptStatement", s:red, "", "")
  337. " CoffeeScript Highlighting
  338. call <SID>X("coffeeRepeat", s:purple, "", "")
  339. call <SID>X("coffeeConditional", s:purple, "", "")
  340. call <SID>X("coffeeKeyword", s:purple, "", "")
  341. call <SID>X("coffeeObject", s:yellow, "", "")
  342. " HTML Highlighting
  343. call <SID>X("htmlTag", s:red, "", "")
  344. call <SID>X("htmlTagName", s:red, "", "")
  345. call <SID>X("htmlArg", s:red, "", "")
  346. call <SID>X("htmlScriptTag", s:red, "", "")
  347. " Diff Highlighting
  348. call <SID>X("diffAdd", "", "4c4e39", "")
  349. call <SID>X("diffDelete", s:background, s:red, "")
  350. call <SID>X("diffChange", "", "2B5B77", "")
  351. call <SID>X("diffText", s:line, s:blue, "")
  352. " ShowMarks Highlighting
  353. call <SID>X("ShowMarksHLl", s:orange, s:background, "none")
  354. call <SID>X("ShowMarksHLo", s:purple, s:background, "none")
  355. call <SID>X("ShowMarksHLu", s:yellow, s:background, "none")
  356. call <SID>X("ShowMarksHLm", s:aqua, s:background, "none")
  357. " Lua Highlighting
  358. call <SID>X("luaStatement", s:purple, "", "")
  359. call <SID>X("luaRepeat", s:purple, "", "")
  360. call <SID>X("luaCondStart", s:purple, "", "")
  361. call <SID>X("luaCondElseif", s:purple, "", "")
  362. call <SID>X("luaCond", s:purple, "", "")
  363. call <SID>X("luaCondEnd", s:purple, "", "")
  364. " Cucumber Highlighting
  365. call <SID>X("cucumberGiven", s:blue, "", "")
  366. call <SID>X("cucumberGivenAnd", s:blue, "", "")
  367. " Go Highlighting
  368. call <SID>X("goDirective", s:purple, "", "")
  369. call <SID>X("goDeclaration", s:purple, "", "")
  370. call <SID>X("goStatement", s:purple, "", "")
  371. call <SID>X("goConditional", s:purple, "", "")
  372. call <SID>X("goConstants", s:orange, "", "")
  373. call <SID>X("goTodo", s:yellow, "", "")
  374. call <SID>X("goDeclType", s:blue, "", "")
  375. call <SID>X("goBuiltins", s:purple, "", "")
  376. call <SID>X("goRepeat", s:purple, "", "")
  377. call <SID>X("goLabel", s:purple, "", "")
  378. " Clojure Highlighting
  379. call <SID>X("clojureConstant", s:orange, "", "")
  380. call <SID>X("clojureBoolean", s:orange, "", "")
  381. call <SID>X("clojureCharacter", s:orange, "", "")
  382. call <SID>X("clojureKeyword", s:green, "", "")
  383. call <SID>X("clojureNumber", s:orange, "", "")
  384. call <SID>X("clojureString", s:green, "", "")
  385. call <SID>X("clojureRegexp", s:green, "", "")
  386. call <SID>X("clojureParen", s:aqua, "", "")
  387. call <SID>X("clojureVariable", s:yellow, "", "")
  388. call <SID>X("clojureCond", s:blue, "", "")
  389. call <SID>X("clojureDefine", s:purple, "", "")
  390. call <SID>X("clojureException", s:red, "", "")
  391. call <SID>X("clojureFunc", s:blue, "", "")
  392. call <SID>X("clojureMacro", s:blue, "", "")
  393. call <SID>X("clojureRepeat", s:blue, "", "")
  394. call <SID>X("clojureSpecial", s:purple, "", "")
  395. call <SID>X("clojureQuote", s:blue, "", "")
  396. call <SID>X("clojureUnquote", s:blue, "", "")
  397. call <SID>X("clojureMeta", s:blue, "", "")
  398. call <SID>X("clojureDeref", s:blue, "", "")
  399. call <SID>X("clojureAnonArg", s:blue, "", "")
  400. call <SID>X("clojureRepeat", s:blue, "", "")
  401. call <SID>X("clojureDispatch", s:blue, "", "")
  402. " Scala Highlighting
  403. call <SID>X("scalaKeyword", s:purple, "", "")
  404. call <SID>X("scalaKeywordModifier", s:purple, "", "")
  405. call <SID>X("scalaOperator", s:blue, "", "")
  406. call <SID>X("scalaPackage", s:red, "", "")
  407. call <SID>X("scalaFqn", s:foreground, "", "")
  408. call <SID>X("scalaFqnSet", s:foreground, "", "")
  409. call <SID>X("scalaImport", s:purple, "", "")
  410. call <SID>X("scalaBoolean", s:orange, "", "")
  411. call <SID>X("scalaDef", s:purple, "", "")
  412. call <SID>X("scalaVal", s:purple, "", "")
  413. call <SID>X("scalaVar", s:aqua, "", "")
  414. call <SID>X("scalaClass", s:purple, "", "")
  415. call <SID>X("scalaObject", s:purple, "", "")
  416. call <SID>X("scalaTrait", s:purple, "", "")
  417. call <SID>X("scalaDefName", s:blue, "", "")
  418. call <SID>X("scalaValName", s:foreground, "", "")
  419. call <SID>X("scalaVarName", s:foreground, "", "")
  420. call <SID>X("scalaClassName", s:foreground, "", "")
  421. call <SID>X("scalaType", s:yellow, "", "")
  422. call <SID>X("scalaTypeSpecializer", s:yellow, "", "")
  423. call <SID>X("scalaAnnotation", s:orange, "", "")
  424. call <SID>X("scalaNumber", s:orange, "", "")
  425. call <SID>X("scalaDefSpecializer", s:yellow, "", "")
  426. call <SID>X("scalaClassSpecializer", s:yellow, "", "")
  427. call <SID>X("scalaBackTick", s:green, "", "")
  428. call <SID>X("scalaRoot", s:foreground, "", "")
  429. call <SID>X("scalaMethodCall", s:blue, "", "")
  430. call <SID>X("scalaCaseType", s:yellow, "", "")
  431. call <SID>X("scalaLineComment", s:comment, "", "")
  432. call <SID>X("scalaComment", s:comment, "", "")
  433. call <SID>X("scalaDocComment", s:comment, "", "")
  434. call <SID>X("scalaDocTags", s:comment, "", "")
  435. call <SID>X("scalaEmptyString", s:green, "", "")
  436. call <SID>X("scalaMultiLineString", s:green, "", "")
  437. call <SID>X("scalaUnicode", s:orange, "", "")
  438. call <SID>X("scalaString", s:green, "", "")
  439. call <SID>X("scalaStringEscape", s:green, "", "")
  440. call <SID>X("scalaSymbol", s:orange, "", "")
  441. call <SID>X("scalaChar", s:orange, "", "")
  442. call <SID>X("scalaXml", s:green, "", "")
  443. call <SID>X("scalaConstructorSpecializer", s:yellow, "", "")
  444. call <SID>X("scalaBackTick", s:blue, "", "")
  445. " Git
  446. call <SID>X("diffAdded", s:green, "", "")
  447. call <SID>X("diffRemoved", s:red, "", "")
  448. call <SID>X("gitcommitSummary", "", "", "bold")
  449. " Delete Functions
  450. delf <SID>X
  451. delf <SID>rgb
  452. delf <SID>colour
  453. delf <SID>rgb_colour
  454. delf <SID>rgb_level
  455. delf <SID>rgb_number
  456. delf <SID>grey_colour
  457. delf <SID>grey_level
  458. delf <SID>grey_number
  459. endif
  460. set background=dark