PageRenderTime 24ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/vim/colors/Tomorrow-Night-Bright.vim

https://gitlab.com/turistpro/dotfiles
Vim Script | 378 lines | 313 code | 30 blank | 35 comment | 56 complexity | 9af1ba096caafe2bc5b9ebb1989356a4 MD5 | raw file
  1. " Tomorrow Night Bright - 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 = "eaeaea"
  7. let s:background = "000000"
  8. let s:selection = "424242"
  9. let s:line = "2a2a2a"
  10. let s:comment = "969896"
  11. let s:red = "d54e53"
  12. let s:orange = "e78c45"
  13. let s:yellow = "e7c547"
  14. let s:green = "b9ca4a"
  15. let s:aqua = "70c0b1"
  16. let s:blue = "7aa6da"
  17. let s:purple = "c397d8"
  18. let s:window = "4d5057"
  19. hi clear
  20. syntax reset
  21. let g:colors_name = "Tomorrow-Night-Bright"
  22. if has("gui_running") || &t_Co == 88 || &t_Co == 256
  23. " Returns an approximate grey index for the given grey level
  24. fun <SID>grey_number(x)
  25. if &t_Co == 88
  26. if a:x < 23
  27. return 0
  28. elseif a:x < 69
  29. return 1
  30. elseif a:x < 103
  31. return 2
  32. elseif a:x < 127
  33. return 3
  34. elseif a:x < 150
  35. return 4
  36. elseif a:x < 173
  37. return 5
  38. elseif a:x < 196
  39. return 6
  40. elseif a:x < 219
  41. return 7
  42. elseif a:x < 243
  43. return 8
  44. else
  45. return 9
  46. endif
  47. else
  48. if a:x < 14
  49. return 0
  50. else
  51. let l:n = (a:x - 8) / 10
  52. let l:m = (a:x - 8) % 10
  53. if l:m < 5
  54. return l:n
  55. else
  56. return l:n + 1
  57. endif
  58. endif
  59. endif
  60. endfun
  61. " Returns the actual grey level represented by the grey index
  62. fun <SID>grey_level(n)
  63. if &t_Co == 88
  64. if a:n == 0
  65. return 0
  66. elseif a:n == 1
  67. return 46
  68. elseif a:n == 2
  69. return 92
  70. elseif a:n == 3
  71. return 115
  72. elseif a:n == 4
  73. return 139
  74. elseif a:n == 5
  75. return 162
  76. elseif a:n == 6
  77. return 185
  78. elseif a:n == 7
  79. return 208
  80. elseif a:n == 8
  81. return 231
  82. else
  83. return 255
  84. endif
  85. else
  86. if a:n == 0
  87. return 0
  88. else
  89. return 8 + (a:n * 10)
  90. endif
  91. endif
  92. endfun
  93. " Returns the palette index for the given grey index
  94. fun <SID>grey_colour(n)
  95. if &t_Co == 88
  96. if a:n == 0
  97. return 16
  98. elseif a:n == 9
  99. return 79
  100. else
  101. return 79 + a:n
  102. endif
  103. else
  104. if a:n == 0
  105. return 16
  106. elseif a:n == 25
  107. return 231
  108. else
  109. return 231 + a:n
  110. endif
  111. endif
  112. endfun
  113. " Returns an approximate colour index for the given colour level
  114. fun <SID>rgb_number(x)
  115. if &t_Co == 88
  116. if a:x < 69
  117. return 0
  118. elseif a:x < 172
  119. return 1
  120. elseif a:x < 230
  121. return 2
  122. else
  123. return 3
  124. endif
  125. else
  126. if a:x < 75
  127. return 0
  128. else
  129. let l:n = (a:x - 55) / 40
  130. let l:m = (a:x - 55) % 40
  131. if l:m < 20
  132. return l:n
  133. else
  134. return l:n + 1
  135. endif
  136. endif
  137. endif
  138. endfun
  139. " Returns the actual colour level for the given colour index
  140. fun <SID>rgb_level(n)
  141. if &t_Co == 88
  142. if a:n == 0
  143. return 0
  144. elseif a:n == 1
  145. return 139
  146. elseif a:n == 2
  147. return 205
  148. else
  149. return 255
  150. endif
  151. else
  152. if a:n == 0
  153. return 0
  154. else
  155. return 55 + (a:n * 40)
  156. endif
  157. endif
  158. endfun
  159. " Returns the palette index for the given R/G/B colour indices
  160. fun <SID>rgb_colour(x, y, z)
  161. if &t_Co == 88
  162. return 16 + (a:x * 16) + (a:y * 4) + a:z
  163. else
  164. return 16 + (a:x * 36) + (a:y * 6) + a:z
  165. endif
  166. endfun
  167. " Returns the palette index to approximate the given R/G/B colour levels
  168. fun <SID>colour(r, g, b)
  169. " Get the closest grey
  170. let l:gx = <SID>grey_number(a:r)
  171. let l:gy = <SID>grey_number(a:g)
  172. let l:gz = <SID>grey_number(a:b)
  173. " Get the closest colour
  174. let l:x = <SID>rgb_number(a:r)
  175. let l:y = <SID>rgb_number(a:g)
  176. let l:z = <SID>rgb_number(a:b)
  177. if l:gx == l:gy && l:gy == l:gz
  178. " There are two possibilities
  179. let l:dgr = <SID>grey_level(l:gx) - a:r
  180. let l:dgg = <SID>grey_level(l:gy) - a:g
  181. let l:dgb = <SID>grey_level(l:gz) - a:b
  182. let l:dgrey = (l:dgr * l:dgr) + (l:dgg * l:dgg) + (l:dgb * l:dgb)
  183. let l:dr = <SID>rgb_level(l:gx) - a:r
  184. let l:dg = <SID>rgb_level(l:gy) - a:g
  185. let l:db = <SID>rgb_level(l:gz) - a:b
  186. let l:drgb = (l:dr * l:dr) + (l:dg * l:dg) + (l:db * l:db)
  187. if l:dgrey < l:drgb
  188. " Use the grey
  189. return <SID>grey_colour(l:gx)
  190. else
  191. " Use the colour
  192. return <SID>rgb_colour(l:x, l:y, l:z)
  193. endif
  194. else
  195. " Only one possibility
  196. return <SID>rgb_colour(l:x, l:y, l:z)
  197. endif
  198. endfun
  199. " Returns the palette index to approximate the 'rrggbb' hex string
  200. fun <SID>rgb(rgb)
  201. let l:r = ("0x" . strpart(a:rgb, 0, 2)) + 0
  202. let l:g = ("0x" . strpart(a:rgb, 2, 2)) + 0
  203. let l:b = ("0x" . strpart(a:rgb, 4, 2)) + 0
  204. return <SID>colour(l:r, l:g, l:b)
  205. endfun
  206. " Sets the highlighting for the given group
  207. fun <SID>X(group, fg, bg, attr)
  208. if a:fg != ""
  209. exec "hi " . a:group . " guifg=#" . a:fg . " ctermfg=" . <SID>rgb(a:fg)
  210. endif
  211. if a:bg != ""
  212. exec "hi " . a:group . " guibg=#" . a:bg . " ctermbg=" . <SID>rgb(a:bg)
  213. endif
  214. if a:attr != ""
  215. exec "hi " . a:group . " gui=" . a:attr . " cterm=" . a:attr
  216. endif
  217. endfun
  218. " Vim Highlighting
  219. call <SID>X("Normal", s:foreground, s:background, "")
  220. call <SID>X("LineNr", s:selection, "", "")
  221. call <SID>X("NonText", s:selection, "", "")
  222. call <SID>X("SpecialKey", s:selection, "", "")
  223. call <SID>X("Search", s:background, s:yellow, "")
  224. call <SID>X("TabLine", s:foreground, s:background, "reverse")
  225. call <SID>X("StatusLine", s:window, s:yellow, "reverse")
  226. call <SID>X("StatusLineNC", s:window, s:foreground, "reverse")
  227. call <SID>X("VertSplit", s:window, s:window, "none")
  228. call <SID>X("Visual", "", s:selection, "")
  229. call <SID>X("Directory", s:blue, "", "")
  230. call <SID>X("ModeMsg", s:green, "", "")
  231. call <SID>X("MoreMsg", s:green, "", "")
  232. call <SID>X("Question", s:green, "", "")
  233. call <SID>X("WarningMsg", s:red, "", "")
  234. call <SID>X("MatchParen", "", s:selection, "")
  235. call <SID>X("Folded", s:comment, s:background, "")
  236. call <SID>X("FoldColumn", "", s:background, "")
  237. if version >= 700
  238. call <SID>X("CursorLine", "", s:line, "none")
  239. call <SID>X("CursorColumn", "", s:line, "none")
  240. call <SID>X("PMenu", s:foreground, s:selection, "none")
  241. call <SID>X("PMenuSel", s:foreground, s:selection, "reverse")
  242. end
  243. if version >= 703
  244. call <SID>X("ColorColumn", "", s:line, "none")
  245. end
  246. " Standard Highlighting
  247. call <SID>X("Comment", s:comment, "", "")
  248. call <SID>X("Todo", s:comment, s:background, "")
  249. call <SID>X("Title", s:comment, "", "")
  250. call <SID>X("Identifier", s:red, "", "none")
  251. call <SID>X("Statement", s:foreground, "", "")
  252. call <SID>X("Conditional", s:foreground, "", "")
  253. call <SID>X("Repeat", s:foreground, "", "")
  254. call <SID>X("Structure", s:purple, "", "")
  255. call <SID>X("Function", s:blue, "", "")
  256. call <SID>X("Constant", s:orange, "", "")
  257. call <SID>X("String", s:green, "", "")
  258. call <SID>X("Special", s:foreground, "", "")
  259. call <SID>X("PreProc", s:purple, "", "")
  260. call <SID>X("Operator", s:aqua, "", "none")
  261. call <SID>X("Type", s:blue, "", "none")
  262. call <SID>X("Define", s:purple, "", "none")
  263. call <SID>X("Include", s:blue, "", "")
  264. "call <SID>X("Ignore", "666666", "", "")
  265. " Vim Highlighting
  266. call <SID>X("vimCommand", s:red, "", "none")
  267. " C Highlighting
  268. call <SID>X("cType", s:yellow, "", "")
  269. call <SID>X("cStorageClass", s:purple, "", "")
  270. call <SID>X("cConditional", s:purple, "", "")
  271. call <SID>X("cRepeat", s:purple, "", "")
  272. " PHP Highlighting
  273. call <SID>X("phpVarSelector", s:red, "", "")
  274. call <SID>X("phpKeyword", s:purple, "", "")
  275. call <SID>X("phpRepeat", s:purple, "", "")
  276. call <SID>X("phpConditional", s:purple, "", "")
  277. call <SID>X("phpStatement", s:purple, "", "")
  278. call <SID>X("phpMemberSelector", s:foreground, "", "")
  279. " Ruby Highlighting
  280. call <SID>X("rubySymbol", s:green, "", "")
  281. call <SID>X("rubyConstant", s:yellow, "", "")
  282. call <SID>X("rubyAccess", s:yellow, "", "")
  283. call <SID>X("rubyAttribute", s:blue, "", "")
  284. call <SID>X("rubyInclude", s:blue, "", "")
  285. call <SID>X("rubyLocalVariableOrMethod", s:orange, "", "")
  286. call <SID>X("rubyCurlyBlock", s:orange, "", "")
  287. call <SID>X("rubyStringDelimiter", s:green, "", "")
  288. call <SID>X("rubyInterpolationDelimiter", s:orange, "", "")
  289. call <SID>X("rubyConditional", s:purple, "", "")
  290. call <SID>X("rubyRepeat", s:purple, "", "")
  291. call <SID>X("rubyControl", s:purple, "", "")
  292. call <SID>X("rubyException", s:purple, "", "")
  293. " Python Highlighting
  294. call <SID>X("pythonInclude", s:purple, "", "")
  295. call <SID>X("pythonStatement", s:purple, "", "")
  296. call <SID>X("pythonConditional", s:purple, "", "")
  297. call <SID>X("pythonRepeat", s:purple, "", "")
  298. call <SID>X("pythonException", s:purple, "", "")
  299. call <SID>X("pythonFunction", s:blue, "", "")
  300. call <SID>X("pythonPreCondit", s:purple, "", "")
  301. call <SID>X("pythonRepeat", s:aqua, "", "")
  302. call <SID>X("pythonExClass", s:orange, "", "")
  303. " JavaScript Highlighting
  304. call <SID>X("javaScriptBraces", s:foreground, "", "")
  305. call <SID>X("javaScriptFunction", s:purple, "", "")
  306. call <SID>X("javaScriptConditional", s:purple, "", "")
  307. call <SID>X("javaScriptRepeat", s:purple, "", "")
  308. call <SID>X("javaScriptNumber", s:orange, "", "")
  309. call <SID>X("javaScriptMember", s:orange, "", "")
  310. " HTML Highlighting
  311. call <SID>X("htmlTag", s:red, "", "")
  312. call <SID>X("htmlTagName", s:red, "", "")
  313. call <SID>X("htmlArg", s:red, "", "")
  314. call <SID>X("htmlScriptTag", s:red, "", "")
  315. " Diff Highlighting
  316. call <SID>X("diffAdded", s:green, "", "")
  317. call <SID>X("diffRemoved", s:red, "", "")
  318. " Lua Highlighting
  319. call <SID>X("luaStatement", s:purple, "", "")
  320. call <SID>X("luaRepeat", s:purple, "", "")
  321. call <SID>X("luaCondStart", s:purple, "", "")
  322. call <SID>X("luaCondElseif", s:purple, "", "")
  323. call <SID>X("luaCond", s:purple, "", "")
  324. call <SID>X("luaCondEnd", s:purple, "", "")
  325. " Cucumber Highlighting
  326. call <SID>X("cucumberGiven", s:blue, "", "")
  327. call <SID>X("cucumberGivenAnd", s:blue, "", "")
  328. " Go Highlighting
  329. call <SID>X("goDirective", s:purple, "", "")
  330. call <SID>X("goDeclaration", s:purple, "", "")
  331. call <SID>X("goStatement", s:purple, "", "")
  332. call <SID>X("goConditional", s:purple, "", "")
  333. call <SID>X("goConstants", s:orange, "", "")
  334. call <SID>X("goTodo", s:yellow, "", "")
  335. call <SID>X("goDeclType", s:blue, "", "")
  336. call <SID>X("goBuiltins", s:purple, "", "")
  337. " Delete Functions
  338. delf <SID>X
  339. delf <SID>rgb
  340. delf <SID>colour
  341. delf <SID>rgb_colour
  342. delf <SID>rgb_level
  343. delf <SID>rgb_number
  344. delf <SID>grey_colour
  345. delf <SID>grey_level
  346. delf <SID>grey_number
  347. endif
  348. set background=dark