CLI config/dotfiles
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

811 lines
35 KiB

  1. " xterm16-v2.43: Vim color scheme file
  2. " Maintainer: Gautam Iyer <gautam@math.uchicago.edu>
  3. " Created: Thu 16 Oct 2003 06:17:47 PM CDT
  4. " Modified: Tue 12 Sep 2006 11:19:35 AM PDT
  5. "
  6. " Adjustable color scheme for GUI/Terminal vim.
  7. let s:cpo_save = &cpo
  8. set cpo&vim " line continuation is used
  9. hi clear
  10. if exists('syntax_on')
  11. syntax reset
  12. endif
  13. let colors_name = 'xterm16'
  14. " {{{1 Local function definitions
  15. " {{{2 tohex(n): Convert a number to a 2 digit hex
  16. let s:hex = '0123456789abcdef'
  17. function s:tohex( n)
  18. return a:n > 255 ? 'ff' : s:hex[a:n / 16] . s:hex[a:n % 16]
  19. endfunction
  20. " {{{2 extractRGB( string): Extract r,g,b components from string into s:c1,2,3
  21. function s:extractRGB( string)
  22. if a:string =~ '^#[0-9a-f]\{6\}$'
  23. " Colors in hex values
  24. let s:c1 = '0x' . strpart(a:string, 1, 2)
  25. let s:c2 = '0x' . strpart(a:string, 3, 2)
  26. let s:c3 = '0x' . strpart(a:string, 5, 2)
  27. elseif a:string =~ '^\d\{3\}$'
  28. " Colors in cterm values
  29. let s:c1 = s:guilevel( a:string[0])
  30. let s:c2 = s:guilevel( a:string[1])
  31. let s:c3 = s:guilevel( a:string[2])
  32. elseif a:string =~ '^[lmh][0-9]\{6\}'
  33. " Colors in propotions of low / med / high
  34. if exists('s:'.a:string[0])
  35. let l:level = s:{a:string[0]}
  36. let s:c1 = l:level * strpart(a:string, 1, 2) / 50
  37. let s:c2 = l:level * strpart(a:string, 3, 2) / 50
  38. let s:c3 = l:level * strpart(a:string, 5, 2) / 50
  39. else
  40. throw 'xterm16 Error: Use of propotional intensities before absolute intensities'
  41. endif
  42. else
  43. throw 'xterm16 Error: Brightness / color "'. a:string . '" badly formed.'
  44. endif
  45. endfunction
  46. " {{{2 guilevel(n) : Get the gui intensity of a given cterm intensity
  47. function s:guilevel( n)
  48. return '0x'.s:ccube[2*a:n].s:ccube[2*a:n + 1]
  49. endfunction
  50. " {{{2 ctermlevel(n) : Get the cterm intensity of a given gui intensity
  51. function s:ctermlevel( n)
  52. " Xterm color cube intensities: 00, 5f, 87, af, d7, ff
  53. " Rxvt color cube: 00, 2a, 55, 7f, aa, d4
  54. " cinterval should have the terminal intervals.
  55. let l:terml = 0
  56. while l:terml < 5
  57. if a:n < '0x'.s:cinterval[2 * l:terml].s:cinterval[2 * l:terml + 1]
  58. return l:terml
  59. endif
  60. let l:terml = l:terml + 1
  61. endwhile
  62. return 5
  63. endfunction
  64. " {{{2 guicolor( r, g, b): Return the gui color with intensities r,g,b
  65. function s:guicolor( r, g, b)
  66. return '#' . s:tohex(a:r) . s:tohex(a:g) . s:tohex(a:b)
  67. endfunction
  68. " {{{2 ctermcolor( r, g, b): Return the xterm-256 color with intensities r, g, b
  69. function s:ctermcolor( r, g, b)
  70. if a:r == a:g && a:r == a:b
  71. " Use the greyscale ramp. The greyscale ramp starts from color 232
  72. " with grey 8, and procedes in increments of 10 upto grey 238 (0xee)
  73. if a:r <= 4
  74. return 16
  75. elseif a:r <= 243
  76. return (a:r - 4) / 10 + 232
  77. else
  78. " Let's check if the last color in ccube is large enough.
  79. " return (s:termtype == 'xterm' && a:r > 247) ? 231 : 255
  80. let l:l5 = s:guilevel(5)
  81. return ( l:l5 > 0xee && a:r > (l:l5 + 0xee)/2 ) ? 231 : 255
  82. endif
  83. else
  84. " Use the rgb cube.
  85. return s:ctermlevel(a:r) * 36 + s:ctermlevel(a:g) * 6 + s:ctermlevel(a:b) + 16
  86. endif
  87. endfunction
  88. " {{{2 setcolor( name, r, g, b): Set the script variables gui_name and cterm_name
  89. function s:setcolor( name, r, g, b)
  90. if exists('g:xterm16_'.a:name)
  91. " Use user-defined color settings (from global variable)
  92. call s:extractRGB( g:xterm16_{a:name})
  93. let s:gui_{a:name} = s:guicolor( s:c1, s:c2, s:c3)
  94. let s:cterm_{a:name} = s:ctermcolor( s:c1, s:c2, s:c3)
  95. else
  96. " Set the GUI / cterm color from r,g,b
  97. let s:gui_{a:name} = s:guicolor( a:r, a:g, a:b)
  98. let s:cterm_{a:name} = ( &t_Co == 256 || has('gui_running') )
  99. \ ? s:ctermcolor( a:r, a:g, a:b) : a:name
  100. endif
  101. " Add the color to palette
  102. let g:xterm16_palette = g:xterm16_palette . "\n" . s:gui_{a:name} . ', cterm ' . s:cterm_{a:name} . ' : ' . a:name
  103. endfunction
  104. " {{{2 getcolor( group, globalvar, colorname): if globvar exists, returns that
  105. " color. if not returns the color in cname
  106. function s:getcolor( globvar, cname)
  107. " hopefully someone set ctype before getting here. ctype should either be
  108. " "gui" or "cterm"
  109. if exists( a:globvar)
  110. if exists( 's:'.s:ctype.'_'.{a:globvar})
  111. return s:{s:ctype}_{{a:globvar}}
  112. else
  113. call s:extractRGB( {a:globvar})
  114. return s:{s:ctype}color( s:c1, s:c2, s:c3)
  115. endif
  116. else
  117. return s:{s:ctype}_{a:cname}
  118. endif
  119. endfunction
  120. " {{{2 use_guiattr( nattrs, n ): Should s:hi use the n'th attr for GUI hl.
  121. function s:use_guiattr( nattrs, n )
  122. " If guisp is specified in vim6, then don't use any GUI attributes.
  123. " Otherwise use GUI attributes if GUI is running and they are specified.
  124. if !has('gui_running') ||
  125. \ a:nattrs < a:n ||
  126. \ ( v:version < 700 && a:nattrs >= 4 )
  127. " Don't use GUI attributes
  128. return 0
  129. else
  130. " Use GUI attributes
  131. return 1
  132. endif
  133. endfunction
  134. " {{{2 hi( group, attr, fg, bg): Set the gui/cterm highlighting groups
  135. "
  136. " group - groupname.
  137. " attr - attributes.
  138. " fg/bg color name.
  139. "
  140. " Optionally can call it as
  141. "
  142. " hi( group, attr, fg, bg, guiattr, guifg, guibg, guisp )
  143. "
  144. " where all the gui options are optional. If provided, they override the term
  145. " colors.
  146. function s:hi( group, attr, fg, bg, ...)
  147. if has('gui_running') || &t_Co == 256
  148. " For gui's and 256 color terminals
  149. let l:fg = s:getcolor( 'g:xterm16fg_'.a:group,
  150. \ s:use_guiattr( a:0, 2) ? a:2 : a:fg)
  151. let l:bg = s:getcolor( 'g:xterm16bg_'.a:group,
  152. \ s:use_guiattr( a:0, 3) ? a:3 : a:bg)
  153. if exists('g:xterm16attr_' . a:group)
  154. let l:attr = g:xterm16attr_{a:group}
  155. else
  156. let l:attr = s:use_guiattr( a:0, 1) ? a:1 : a:attr
  157. endif
  158. exec 'hi' a:group
  159. \ s:ctype.'='.l:attr
  160. \ s:ctype.'fg='.l:fg
  161. \ s:ctype.'bg='.l:bg
  162. " Define guisp if specified for the gui (Vim7 upwards only).
  163. if v:version >= 700 && has('gui_running') && a:0 >= 4
  164. let l:sp = s:getcolor( 'g:xterm16sp_'.a:group, a:4 )
  165. exec 'hi' a:group s:ctype.'sp='.l:sp
  166. endif
  167. else
  168. " for consoles / 16 color junkies
  169. exec 'hi' a:group 'cterm='.a:attr 'ctermfg='.a:fg 'ctermbg='.a:bg
  170. endif
  171. endfunction
  172. " {{{2 set_brightness( default): Set s:brightness based on default
  173. function s:set_brightness( default)
  174. let s:brightness = ( exists('g:xterm16_brightness')
  175. \ && g:xterm16_brightness != 'default') ?
  176. \ g:xterm16_brightness : a:default
  177. if s:colormap == 'allblue'
  178. if s:brightness == 'high'
  179. let s:brightness = '#afafff' " 335
  180. elseif s:brightness == 'med'
  181. let s:brightness = '#8787d7' " 224
  182. elseif s:brightness == 'low'
  183. let s:brightness = '#5f5faf' " 113
  184. endif
  185. elseif s:colormap == 'softlight'
  186. if s:brightness == 'high'
  187. let s:brightness = '#ff87af' " 523
  188. elseif s:brightness == 'med'
  189. let s:brightness = '#d75f87' " 412
  190. elseif s:brightness == 'low'
  191. let s:brightness = '#af5f87' " 312
  192. endif
  193. else
  194. if s:brightness == 'high'
  195. let s:brightness = '#afd7ff' " 345
  196. elseif s:brightness == 'med'
  197. let s:brightness = '#87afd7' " 234
  198. elseif s:brightness == 'low'
  199. let s:brightness = '#5f87af' " 123
  200. endif
  201. endif
  202. endfunction
  203. " {{{1 Global functions and initialisations.
  204. command! -nargs=* Brightness
  205. \ if Brightness(<f-args>) <bar>
  206. \ colo xterm16 <bar>
  207. \ endif
  208. " {{{2 Brightness( brightness, colormap)
  209. function! Brightness(...)
  210. if a:0 == 0
  211. echo "Brightness: ".s:brightness.", Colormap: ".s:colormap
  212. return 0
  213. elseif a:0 > 2
  214. echoerr 'Too many arguements.'
  215. return 0
  216. endif
  217. let g:xterm16_brightness = a:1
  218. if a:0 == 2
  219. let g:xterm16_colormap = a:2
  220. endif
  221. return 1
  222. endfunction
  223. " }}}1
  224. try
  225. " {{{1 Setup defaults
  226. " {{{2 set ctype (to cterm / gui) to be the color type
  227. let s:ctype = has('gui_running') ? 'gui' : 'cterm'
  228. " {{{2 Obtain intensity levels of the 6 terminal colors in s:ccube
  229. " The 2ith and 2i+1th charecters in ccube are the hex digits of the
  230. " intensity of the ith (0-5) term level. xterm and rxvt set up the default
  231. " color cube differently, so we have to consider them separately.
  232. " First check for a user specified color cube.
  233. if exists('g:xterm16_ccube')
  234. let s:ccube = g:xterm16_ccube
  235. " No user specified color cube given. Try and guess from xterm16_termtype
  236. elseif ( exists('g:xterm16_termtype') && g:xterm16_termtype == 'rxvt') ||
  237. \ ( !exists('g:xterm16_termtype')
  238. \ && &term =~ '^rxvt'
  239. \ && $MRXVT_TABTITLE == "" )
  240. " color cube for "rxvt". Make sure we're not running mrxvt (by
  241. " checking that the MRXVT_TABTITLE variable is empty).
  242. let s:ccube = "002a557faad4"
  243. else
  244. " default to xterm if nothing else is specified.
  245. let s:ccube ="005f87afd7ff"
  246. endif
  247. " s:cinterval will be the intervals of intensities which get mapped to
  248. " term color i. i.e. colors between 0 -- cinterval(0) have level 0.
  249. " between cinterval(0) -- cinterval(1) have level 1, etc. max level is 5,
  250. " so anything higher than cinterval(4) has level 5.
  251. let s:cinterval = ""
  252. let s:lower = "00"
  253. let s:i = 1
  254. while s:i < 6
  255. let s:upper = s:ccube[2*s:i] . s:ccube[2*s:i + 1]
  256. let s:cinterval = s:cinterval . s:tohex( (('0x'.s:lower) + ('0x'.s:upper))/2 )
  257. let s:lower = s:upper
  258. let s:i = s:i + 1
  259. endwhile
  260. " {{{2 Get colormap defaults in "s:colormap"
  261. " On a terminal (without 256 colors), use "standard" colormap. Otherwise
  262. " use value from "g:xterm16_colormap" if exists, or "soft" as default.
  263. if !has('gui_running') && &t_Co != 256
  264. let s:colormap = 'standard'
  265. elseif exists('g:xterm16_colormap')
  266. let s:colormap = g:xterm16_colormap
  267. else
  268. " "soft" used to be the default, but "allblue" is much better.
  269. let s:colormap = 'allblue'
  270. endif
  271. " {{{2 Redefine a few colors for CRT monitors and set brightness
  272. if s:colormap == 'allblue'
  273. call s:set_brightness( '#8787d7' ) " 224
  274. elseif s:colormap == 'softlight'
  275. call s:set_brightness( '#d75f87' ) " 412
  276. elseif exists('g:xterm16_CRTColors')
  277. " "standard" or "soft" colormaps
  278. if s:colormap == 'standard'
  279. let g:xterm16_darkblue = 'h000050'
  280. let g:xterm16_blue = 'h002550'
  281. let g:xterm16_grey = 'm474747'
  282. unlet! g:xterm16_skyblue g:xterm16_green g:xterm16_bluegreen
  283. " give the original xterm16 feel
  284. call s:set_brightness( '#80cdff')
  285. else
  286. " "soft" colormap
  287. let g:xterm16_skyblue = 'h003850'
  288. let g:xterm16_green = 'm315000'
  289. let g:xterm16_bluegreen = 'm005031'
  290. unlet! g:xterm16_darkblue g:xterm16_blue g:xterm16_grey
  291. " call s:set_brightness ( '245')
  292. " call s:set_brightness('high')
  293. call s:set_brightness('#87d7ff') " 245
  294. endif
  295. else
  296. " "standard" or "soft" colormaps with LCD colors
  297. call s:set_brightness( '#5fafd7') " 134
  298. endif
  299. unlet! s:c1 s:c2 s:c3
  300. call s:extractRGB(s:brightness)
  301. let s:l = s:c1
  302. let s:m = s:c2
  303. let s:h = s:c3
  304. " {{{2 Set a bright green cursor on all colormaps except softlight
  305. if !exists('g:xterm16bg_Cursor')
  306. if s:colormap == 'softlight'
  307. let g:xterm16fg_Cursor = '#ffffff'
  308. else
  309. let g:xterm16bg_Cursor = '#00ff00'
  310. endif
  311. endif
  312. " {{{2 Set the current pallete:
  313. let g:xterm16_palette = 'Current palette (Brightness: '.s:brightness. ', Colormap: '.s:colormap.')'
  314. " {{{1 Define colors and highlighting groups based on "s:colormap"
  315. let s:cterm_none = 'NONE'
  316. let s:gui_none = 'NONE'
  317. " Set the background based on the colormap. 'softlight' is the only
  318. " colormap with a light background
  319. if s:colormap == 'softlight'
  320. set bg=light
  321. else
  322. set bg=dark
  323. endif
  324. if s:colormap == 'standard'
  325. " {{{2 Original colormap. 8 standard colors, and 8 brighter ones.
  326. call s:setcolor( 'black', 0 , 0 , 0 )
  327. call s:setcolor( 'darkred', s:m , 0 , 0 )
  328. call s:setcolor( 'darkgreen', 0 , s:m , 0 )
  329. call s:setcolor( 'darkyellow', s:m , s:m , 0 )
  330. call s:setcolor( 'darkblue', 0 , 0 , s:m )
  331. call s:setcolor( 'darkmagenta', s:m , 0 , s:m )
  332. call s:setcolor( 'darkcyan', 0 , s:m , s:m )
  333. call s:setcolor( 'grey', s:m*44/50, s:m*44/50, s:m*44/50)
  334. call s:setcolor( 'darkgrey', s:l , s:l , s:l )
  335. call s:setcolor( 'red', s:h , 0 , 0 )
  336. call s:setcolor( 'green', 0 , s:h , 0 )
  337. call s:setcolor( 'yellow', s:h , s:h , 0 )
  338. call s:setcolor( 'blue', 0 , 0 , s:h )
  339. call s:setcolor( 'magenta', s:h , 0 , s:h )
  340. call s:setcolor( 'cyan', 0 , s:h , s:h )
  341. call s:setcolor( 'white', s:h , s:h , s:h )
  342. " {{{2 Highlighting groups for standard colors
  343. call s:hi( 'Normal' , 'none' , 'grey' , 'black' )
  344. call s:hi( 'Cursor' , 'none' , 'black' , 'green' )
  345. call s:hi( 'CursorColumn', 'none' , 'none' , 'darkgrey' )
  346. call s:hi( 'CursorLine' , 'none' , 'none' , 'darkgrey' )
  347. call s:hi( 'DiffAdd' , 'none' , 'darkblue' , 'darkgreen' )
  348. call s:hi( 'DiffChange' , 'none' , 'black' , 'darkyellow')
  349. call s:hi( 'DiffDelete' , 'none' , 'darkblue' , 'none' )
  350. call s:hi( 'DiffText' , 'none' , 'darkred' , 'darkyellow')
  351. call s:hi( 'Directory' , 'none' , 'cyan' , 'none' )
  352. call s:hi( 'ErrorMsg' , 'none' , 'white' , 'darkred' )
  353. call s:hi( 'FoldColumn' , 'none' , 'yellow' , 'darkblue' )
  354. call s:hi( 'Folded' , 'none' , 'yellow' , 'darkblue' )
  355. call s:hi( 'IncSearch' , 'none' , 'grey' , 'darkblue' )
  356. call s:hi( 'LineNr' , 'none' , 'yellow' , 'none' )
  357. call s:hi( 'MatchParen' , 'bold' , 'none' , 'none' )
  358. call s:hi( 'MoreMsg' , 'bold' , 'green' , 'none' )
  359. call s:hi( 'NonText' , 'none' , 'blue' , 'none' )
  360. call s:hi( 'Pmenu' , 'none' , 'black' , 'grey' )
  361. call s:hi( 'PmenuSel' , 'none' , 'none' , 'darkblue' )
  362. call s:hi( 'PmenuSbar' , 'none' , 'none' , 'darkgrey' )
  363. call s:hi( 'PmenuThumb' , 'none' , 'none' , 'white' )
  364. call s:hi( 'Question' , 'none' , 'green' , 'none' )
  365. call s:hi( 'Search' , 'none' , 'black' , 'darkcyan' )
  366. call s:hi( 'SignColumn' , 'none' , 'darkmagenta', 'darkgrey' )
  367. call s:hi( 'SpecialKey' , 'none' , 'blue' , 'none' )
  368. call s:hi( 'StatusLine' , 'none' , 'darkblue' , 'grey' )
  369. call s:hi( 'StatusLineNC', 'reverse', 'none' , 'none' )
  370. call s:hi( 'TabLineFill' , 'none' , 'black' , 'darkgrey' )
  371. call s:hi( 'TabLine' , 'none' , 'black' , 'darkgrey' )
  372. call s:hi( 'TabLineSel' , 'bold' , 'none' , 'none' )
  373. call s:hi( 'Title' , 'none' , 'magenta' , 'none' )
  374. call s:hi( 'Visual' , 'none' , 'none' , 'darkblue' )
  375. call s:hi( 'VisualNOS' , 'none' , 'none' , 'darkgrey' )
  376. call s:hi( 'WarningMsg' , 'bold' , 'red' , 'none' )
  377. call s:hi( 'WildMenu' , 'none' , 'darkmagenta', 'darkyellow')
  378. call s:hi( 'Comment' , 'none' , 'darkred' , 'none' )
  379. call s:hi( 'Constant' , 'none' , 'darkyellow' , 'none' )
  380. call s:hi( 'Error' , 'none' , 'white' , 'red' )
  381. call s:hi( 'Identifier' , 'none' , 'darkcyan' , 'none' )
  382. call s:hi( 'Ignore' , 'none' , 'darkgrey' , 'none' )
  383. call s:hi( 'PreProc' , 'none' , 'blue' , 'none' )
  384. call s:hi( 'Special' , 'none' , 'darkgreen' , 'none' )
  385. call s:hi( 'Statement' , 'none' , 'cyan' , 'none' )
  386. call s:hi( 'Todo' , 'none' , 'black' , 'yellow' )
  387. call s:hi( 'Type' , 'none' , 'green' , 'none' )
  388. call s:hi( 'Underlined' , 'none' , 'darkmagenta', 'none' )
  389. " {{{2 Spelling highlighting groups.
  390. call s:hi( 'SpellBad' , 'bold,underline', 'none', 'none' ,
  391. \ 'undercurl' , 'none', 'none' ,
  392. \ 'darkred' )
  393. call s:hi( 'SpellCap' , 'bold' , 'none', 'none' ,
  394. \ 'undercurl' , 'none', 'none' ,
  395. \ 'blue' )
  396. call s:hi( 'SpellLocal', 'underline' , 'none', 'none' ,
  397. \ 'undercurl' , 'none', 'none' ,
  398. \ 'cyan' )
  399. call s:hi( 'SpellRare' ,'underline' , 'none', 'none' ,
  400. \ 'undercurl' , 'none', 'none' ,
  401. \ 'darkyellow' )
  402. " {{{2 Define html highlighting groups for standard colors.
  403. if !exists("g:xterm16_NoHtmlColors")
  404. call s:hi( 'htmlBold', 'none', 'white', 'none', 'bold', 'none')
  405. call s:hi( 'htmlItalic', 'none', 'yellow', 'none', 'italic', 'none')
  406. call s:hi( 'htmlUnderline', 'none', 'darkmagenta', 'none', 'underline', 'none')
  407. call s:hi( 'htmlBoldItalic', 'bold', 'yellow', 'none', 'bold,italic', 'none')
  408. call s:hi( 'htmlBoldUnderline', 'bold', 'magenta', 'none', 'bold,underline', 'none')
  409. call s:hi( 'htmlUnderlineItalic', 'none', 'magenta', 'none', 'underline,italic', 'none')
  410. call s:hi( 'htmlBoldUnderlineItalic', 'bold', 'white', 'none', 'bold,underline,italic', 'none')
  411. hi! link htmlLink PreProc
  412. endif
  413. " {{{2 Remap darkblue on linux consoles
  414. if !exists("g:xterm16_NoRemap") && &term =~# (exists("g:xterm16_TermRegexp") ? xterm16_TermRegexp : "linux")
  415. hi! link PreProc Underlined
  416. endif
  417. " }}}2
  418. elseif s:colormap == 'soft' || s:colormap == 'softlight'
  419. " {{{2 "soft" / "softlight" colormap.
  420. " Mix and use similar intensity colors. Only drawback is a slightly
  421. " gaudy appearance (which is why I switched to the "allblue"
  422. " colormap).
  423. "
  424. " The "softlight" colormap is a colormap with a whiteish background
  425. " for web hosting or when there's a strong glare ...
  426. " Background colors common to softlight / soft colormaps
  427. call s:setcolor( 'black' , 0 , 0 , 0 )
  428. " call s:setcolor( 'grey' , s:l/2 , s:l/2 , s:l/2 )
  429. " call s:setcolor( 'lightgrey' , 2*s:l/3 , 2*s:l/3 , 2*s:l/3 )
  430. " Foreground colors common to softlight / soft colormaps
  431. call s:setcolor( 'lightbrown' , s:h , s:h/2 , 0 )
  432. call s:setcolor( 'magenta' , s:h*3/4 , 0 , s:h )
  433. call s:setcolor( 'red' , s:h , 0 , 0 )
  434. call s:setcolor( 'yellow' , s:m , s:m , 0 )
  435. if s:colormap == "soft"
  436. " Background colors for colormap with a dark background
  437. call s:setcolor( 'darkblue' , 0 , 0 , s:l )
  438. call s:setcolor( 'darkcyan' , 0 , s:l , s:l )
  439. call s:setcolor( 'darkred' , s:l , 0 , 0 )
  440. call s:setcolor( 'darkyellow', s:l , s:l , 0 )
  441. call s:setcolor( 'darkgrey' , s:l/3 , s:l/3 , s:l/3 )
  442. call s:setcolor( 'grey' , s:l/2 , s:l/2 , s:l/2 )
  443. call s:setcolor( 'lightgrey' , s:l , s:l , s:l )
  444. " Foreground colors for colormap with a dark background
  445. call s:setcolor( 'bluegreen' , 0 , s:m , s:m*38/50 )
  446. call s:setcolor( 'cyan' , 0 , s:m , s:m )
  447. call s:setcolor( 'green' , s:m*38/50 , s:m , 0 )
  448. call s:setcolor( 'purple' , s:h*27/50 , s:h*27/50 , s:h )
  449. call s:setcolor( 'skyblue' , 0 , s:h*27/50 , s:h )
  450. call s:setcolor( 'white' , s:m*44/50 , s:m*44/50 , s:m*44/50 )
  451. else
  452. " Background colors for colormap with a light background
  453. call s:setcolor( 'darkblue' , s:l*27/50 , s:l*27/50 , s:l )
  454. call s:setcolor( 'darkcyan' , s:l*27/50 , s:l*38/50 , s:l )
  455. call s:setcolor( 'darkred' , s:l , s:l*27/50 , s:l*27/50 )
  456. call s:setcolor( 'darkyellow', s:l , s:l , s:l*27/50 )
  457. call s:setcolor( 'darkgrey' , s:l*40/50 , s:l*40/50 , s:l*40/50 )
  458. call s:setcolor( 'grey' , s:l*35/50 , s:l*35/50 , s:l*35/50 )
  459. call s:setcolor( 'lightgrey' , s:l*30/50 , s:l*30/50 , s:l*30/50 )
  460. call s:setcolor( 'white' , s:l*45/50 , s:l*45/50 , s:l*45/50 )
  461. " Foreground colors for colormap with a light background
  462. call s:setcolor( 'bluegreen' , 0 , s:h , 0 )
  463. call s:setcolor( 'cyan' , 0 , s:h*38/50 , s:h )
  464. call s:setcolor( 'green' , 0 , s:m , 0 )
  465. call s:setcolor( 'purple' , s:h*38/50 , 0 , s:h )
  466. call s:setcolor( 'skyblue' , 0 , 0 , s:h )
  467. endif
  468. " {{{2 Highlighting groups for "soft" / "softlight" colors.
  469. if s:colormap == 'soft'
  470. " Highlighting groups for dark background
  471. call s:hi( 'Normal' , 'none', 'white' , 'black' )
  472. call s:hi( 'Cursor' , 'none', 'black' , 'green' )
  473. call s:hi( 'DiffText' , 'none', 'darkred' , 'darkyellow')
  474. call s:hi( 'Error' , 'none', 'white' , 'darkred' )
  475. call s:hi( 'ErrorMsg' , 'none', 'white' , 'darkred' )
  476. call s:hi( 'FoldColumn' , 'none', 'purple' , 'darkgrey' )
  477. call s:hi( 'Folded' , 'none', 'purple' , 'darkgrey' )
  478. call s:hi( 'IncSearch' , 'none', 'yellow' , 'darkblue' )
  479. call s:hi( 'StatusLine' , 'none', 'darkblue' , 'lightgrey' )
  480. call s:hi( 'VisualNOS' , 'none', 'black' , 'darkgrey' )
  481. else
  482. " Highlighting groups for light background
  483. call s:hi( 'Normal' , 'none', 'black' , 'white' )
  484. call s:hi( 'Cursor' , 'none', 'white' , 'bluegreen' )
  485. call s:hi( 'DiffText' , 'none', 'red' , 'darkyellow')
  486. call s:hi( 'Error' , 'none', 'black' , 'darkred' )
  487. call s:hi( 'ErrorMsg' , 'none', 'white' , 'red' )
  488. call s:hi( 'FoldColumn' , 'none', 'lightgrey', 'darkgrey' )
  489. call s:hi( 'Folded' , 'none', 'black' , 'darkgrey' )
  490. call s:hi( 'IncSearch' , 'none', 'black' , 'darkblue' )
  491. call s:hi( 'StatusLine' , 'none', 'skyblue' , 'lightgrey' )
  492. call s:hi( 'VisualNOS' , 'none', 'white' , 'darkgrey' )
  493. endif
  494. " Highlighting groups for light / dark background.
  495. call s:hi( 'CursorColumn', 'none', 'none' , 'grey' )
  496. call s:hi( 'CursorLine' , 'none', 'none' , 'grey' )
  497. call s:hi( 'DiffAdd' , 'none', 'lightbrown', 'darkblue' )
  498. call s:hi( 'DiffChange' , 'none', 'black' , 'darkyellow')
  499. call s:hi( 'DiffDelete' , 'none', 'purple' , 'darkblue' )
  500. call s:hi( 'Directory' , 'none', 'cyan' , 'none' )
  501. call s:hi( 'LineNr' , 'none', 'yellow' , 'none' )
  502. call s:hi( 'MatchParen' , 'bold', 'none' , 'none' )
  503. call s:hi( 'MoreMsg' , 'none', 'green' , 'none' )
  504. call s:hi( 'NonText' , 'none', 'yellow' , 'none' )
  505. call s:hi( 'Pmenu' , 'none', 'none' , 'grey' )
  506. call s:hi( 'PmenuSbar' , 'none', 'none' , 'darkgrey' )
  507. call s:hi( 'PmenuSel' , 'none', 'none' , 'darkblue' )
  508. call s:hi( 'PmenuThumb' , 'none', 'none' , 'lightgrey' )
  509. call s:hi( 'Question' , 'none', 'green' , 'none' )
  510. call s:hi( 'Search' , 'none', 'black' , 'darkcyan' )
  511. call s:hi( 'SignColumn' , 'none', 'yellow' , 'darkgrey' )
  512. call s:hi( 'SpecialKey' , 'none', 'yellow' , 'none' )
  513. call s:hi( 'StatusLineNC', 'none', 'black' , 'grey' )
  514. call s:hi( 'TabLineFill' , 'none', 'none' , 'grey' )
  515. call s:hi( 'TabLine' , 'none', 'none' , 'grey' )
  516. call s:hi( 'TabLineSel' , 'bold', 'none' , 'none' )
  517. call s:hi( 'Title' , 'none', 'yellow' , 'none' )
  518. call s:hi( 'VertSplit' , 'none', 'darkgrey' , 'darkgrey' )
  519. call s:hi( 'Visual' , 'none', 'none' , 'darkblue' )
  520. call s:hi( 'WarningMsg' , 'none', 'red' , 'none' )
  521. call s:hi( 'WildMenu' , 'none', 'yellow' , 'none' )
  522. call s:hi( 'Comment' , 'none', 'red' , 'none' )
  523. call s:hi( 'Constant' , 'none', 'lightbrown', 'none' )
  524. call s:hi( 'Identifier' , 'none', 'cyan' , 'none' )
  525. call s:hi( 'Ignore' , 'none', 'darkgrey' , 'none' )
  526. call s:hi( 'PreProc' , 'none', 'purple' , 'none' )
  527. call s:hi( 'Special' , 'none', 'green' , 'none' )
  528. call s:hi( 'Statement' , 'none', 'skyblue' , 'none' )
  529. call s:hi( 'Todo' , 'none', 'black' , 'darkyellow')
  530. call s:hi( 'Type' , 'none', 'bluegreen' , 'none' )
  531. call s:hi( 'Underlined' , 'none', 'magenta' , 'none' )
  532. " {{{2 Spelling highlighting groups.
  533. call s:hi( 'SpellBad' , 'bold,underline', 'none', 'darkgrey',
  534. \ 'undercurl' , 'none', 'none' ,
  535. \ 'red' )
  536. call s:hi( 'SpellCap' , 'bold' , 'none', 'darkgrey',
  537. \ 'undercurl' , 'none', 'none' ,
  538. \ 'skyblue' )
  539. call s:hi( 'SpellLocal', 'underline' , 'none', 'darkgrey',
  540. \ 'undercurl' , 'none', 'none' ,
  541. \ 'cyan' )
  542. call s:hi( 'SpellRare' ,'underline' , 'none', 'none' ,
  543. \ 'undercurl' , 'none', 'none' ,
  544. \ 'yellow' )
  545. " {{{2 Define html highlighting groups for soft colors.
  546. if !exists("g:xterm16_NoHtmlColors")
  547. call s:hi( 'htmlBold', 'none', 'yellow', 'none',
  548. \ 'bold', 'none')
  549. call s:hi( 'htmlItalic', 'none', 'yellow', 'none',
  550. \ 'italic', 'none')
  551. call s:hi( 'htmlUnderline', 'none', 'magenta', 'none',
  552. \ 'underline', 'none')
  553. call s:hi( 'htmlBoldItalic', 'bold', 'yellow', 'none',
  554. \ 'bold,italic', 'none')
  555. call s:hi( 'htmlBoldUnderline', 'bold', 'magenta', 'none',
  556. \ 'bold,underline', 'none')
  557. call s:hi( 'htmlUnderlineItalic', 'bold', 'magenta', 'none',
  558. \ 'underline,italic', 'none')
  559. call s:hi( 'htmlBoldUnderlineItalic', 'bold', 'white', 'none',
  560. \ 'bold,underline,italic', 'none')
  561. endif
  562. " }}}2
  563. elseif s:colormap == 'allblue'
  564. " {{{2 "allblue" colormap. All shades of blue.
  565. " Background colors
  566. call s:setcolor( 'black' , 0 , 0 , 0 )
  567. call s:setcolor( 'darkred' , s:l , 0 , 0 )
  568. call s:setcolor( 'darkcyan' , 0 , s:l , s:l )
  569. call s:setcolor( 'darkblue' , 0 , 0 , s:l )
  570. call s:setcolor( 'darkyellow' , s:l , s:l , 0 )
  571. " cterm's can do grey's with better accuracy, so use many shades of
  572. " grey for backgrounds instead of the gaudy yellow's etc.
  573. call s:setcolor( 'grey1' , s:l/8 , s:l/8 , s:l/8 )
  574. call s:setcolor( 'grey2' , 2*s:l/8 , 2*s:l/8 , 2*s:l/8 )
  575. call s:setcolor( 'grey3' , 3*s:l/8 , 3*s:l/8 , 3*s:l/8 )
  576. call s:setcolor( 'grey4' , 4*s:l/8 , 4*s:l/8 , 4*s:l/8 )
  577. call s:setcolor( 'grey5' , 5*s:l/8 , 5*s:l/8 , 5*s:l/8 )
  578. " call s:setcolor( 'grey6' , 6*s:l/8 , 6*s:l/8 , 6*s:l/8 )
  579. " call s:setcolor( 'grey7' , 7*s:l/8 , 7*s:l/8 , 7*s:l/8 )
  580. call s:setcolor( 'grey' , s:l , s:l , s:l )
  581. " Foreground colors:
  582. "
  583. " s:m -- lowest intensity level for fg colors
  584. " s:h -- highest intensity level.
  585. " s:M -- medium intensity (average of the above two)
  586. let s:M = (s:m + s:h) / 2
  587. call s:setcolor( 'red' , s:h , 0 , 0 )
  588. call s:setcolor( 'lightbrown' , s:M , s:m , 0 )
  589. call s:setcolor( 'yellow' , s:M , s:M , s:m )
  590. call s:setcolor( 'dirtygreen' , s:m , s:m , 0 )
  591. call s:setcolor( 'green' , s:m , s:M , s:m )
  592. call s:setcolor( 'bluegreen' , 0 , s:M , s:m )
  593. call s:setcolor( 'yellowgreen', s:m , s:M , 0 )
  594. call s:setcolor( 'skyblue' , 0 , s:m , s:M )
  595. call s:setcolor( 'lightblue' , 0 , s:m , s:h )
  596. call s:setcolor( 'cyan' , 0 , s:M , s:M )
  597. call s:setcolor( 'lightcyan' , s:m , s:M , s:M )
  598. call s:setcolor( 'darkpurple' , s:m , 0 , s:h )
  599. call s:setcolor( 'purple' , s:m , s:m , s:M )
  600. " Unused colors that are pretty reasonable
  601. " call s:setcolor( 'lightred' , s:M , s:m , s:m )
  602. " call s:setcolor( 'bluewhite' , s:M , s:M , s:h )
  603. " call s:setcolor( 'lightpurple', s:m , s:m , s:h )
  604. " Greys can be done with better accurcy on cterms!
  605. call s:setcolor( 'white' , 48*s:M/50 , 48*s:M/50 , 48*s:M/50 )
  606. call s:setcolor( 'white1' , 40*s:M/50 , 40*s:M/50 , 40*s:M/ 50 )
  607. unlet s:M
  608. " {{{2 Highlighting groups for "allblue" colors.
  609. call s:hi( 'Normal' , 'none' , 'white' , 'black' )
  610. call s:hi( 'Cursor' , 'none' , 'black' , 'green' )
  611. call s:hi( 'CursorColumn' , 'none' , 'none' , 'grey4' )
  612. call s:hi( 'CursorLine' , 'none' , 'none' , 'grey4' )
  613. call s:hi( 'DiffAdd' , 'none' , 'lightbrown' , 'grey2' )
  614. call s:hi( 'DiffChange' , 'none' , 'yellow' , 'grey2' )
  615. call s:hi( 'DiffDelete' , 'none' , 'dirtygreen' , 'grey2' )
  616. call s:hi( 'DiffText' , 'none' , 'yellowgreen' , 'grey2' )
  617. call s:hi( 'Directory' , 'none' , 'lightblue' , 'none' )
  618. call s:hi( 'ErrorMsg' , 'none' , 'white' , 'darkred' )
  619. call s:hi( 'FoldColumn' , 'none' , 'grey4' , 'none' )
  620. call s:hi( 'Folded' , 'none' , 'white1' , 'grey2' )
  621. call s:hi( 'IncSearch' , 'none' , 'white' , 'darkblue' )
  622. call s:hi( 'LineNr' , 'none' , 'yellow' , 'none' )
  623. call s:hi( 'MatchParen' , 'bold' , 'none' , 'none' )
  624. call s:hi( 'ModeMsg' , 'bold' , 'none' , 'none' )
  625. call s:hi( 'MoreMsg' , 'none' , 'green' , 'none' )
  626. call s:hi( 'NonText' , 'none' , 'lightbrown' , 'none' )
  627. call s:hi( 'Pmenu' , 'none' , 'none' , 'grey3' )
  628. call s:hi( 'PmenuSel' , 'none' , 'none' , 'darkblue' )
  629. call s:hi( 'PmenuSbar' , 'none' , 'none' , 'grey2' )
  630. call s:hi( 'PmenuThumb' , 'none' , 'none' , 'grey4' )
  631. call s:hi( 'Question' , 'none' , 'green' , 'none' )
  632. call s:hi( 'Search' , 'none' , 'black' , 'darkcyan' )
  633. call s:hi( 'SignColumn' , 'none' , 'yellow' , 'grey1' )
  634. call s:hi( 'SpecialKey' , 'none' , 'yellow' , 'none' )
  635. call s:hi( 'StatusLineNC' , 'none' , 'grey' , 'grey3' )
  636. call s:hi( 'StatusLine' , 'none' , 'white' , 'grey5' )
  637. call s:hi( 'TabLine' , 'none' , 'none' , 'grey3' )
  638. call s:hi( 'TabLineFill' , 'none' , 'none' , 'grey3' )
  639. call s:hi( 'TabLineSel' , 'bold' , 'none' , 'none' )
  640. call s:hi( 'Title' , 'none' , 'yellow' , 'none' )
  641. call s:hi( 'VertSplit' , 'none' , 'grey3' , 'grey3' )
  642. call s:hi( 'Visual' , 'none' , 'none' , 'darkblue' )
  643. call s:hi( 'VisualNOS' , 'none' , 'none' , 'grey2' )
  644. call s:hi( 'WarningMsg' , 'none' , 'red' , 'none' )
  645. call s:hi( 'WildMenu' , 'none' , 'yellow' , 'none' )
  646. call s:hi( 'Comment' , 'none' , 'purple' , 'none' )
  647. call s:hi( 'Constant' , 'none' , 'lightcyan' , 'none' )
  648. call s:hi( 'Error' , 'none' , 'red' , 'none' )
  649. call s:hi( 'Identifier' , 'none' , 'cyan' , 'none' )
  650. call s:hi( 'Ignore' , 'none' , 'grey3' , 'none' )
  651. call s:hi( 'PreProc' , 'none' , 'darkpurple' , 'none' )
  652. call s:hi( 'Special' , 'none' , 'bluegreen' , 'none' )
  653. call s:hi( 'Statement' , 'none' , 'skyblue' , 'none' )
  654. call s:hi( 'Todo' , 'none' , 'lightbrown' , 'none' )
  655. call s:hi( 'Type' , 'none' , 'green' , 'none' )
  656. call s:hi( 'Underlined' , 'none' , 'darkpurple' , 'none' )
  657. " {{{2 Spelling highlighting groups.
  658. "
  659. " The undercurl looks great in gui, so let's use that. For cterm use
  660. " some crappy grey background + bold / etc. Not something that stands
  661. " out too much because there are invariably numerous spelling mistakes
  662. " highlighted in most code.
  663. "
  664. call s:hi( 'SpellBad' , 'bold,underline' , 'none', 'grey2',
  665. \ 'undercurl' , 'none', 'none' , 'red' )
  666. call s:hi( 'SpellCap' , 'bold' , 'none', 'grey2',
  667. \ 'undercurl' , 'none', 'none' , 'skyblue' )
  668. call s:hi( 'SpellLocal' , 'underline' , 'none', 'grey2',
  669. \ 'undercurl' , 'none', 'none' , 'lightcyan' )
  670. call s:hi( 'SpellRare' , 'underline' , 'none', 'none' ,
  671. \ 'undercurl' , 'none', 'none' , 'yellow' )
  672. " {{{2 Highlighting groups for email.
  673. "
  674. " mailURL links to Constant, which is light cyan. This does not stand
  675. " out well in quoted emails (which is cyan), or regular text. Better
  676. " to use light brown (like the soft colormap).
  677. hi link mailURL Todo
  678. " {{{2 Define html highlighting groups for "allblue" colors
  679. if !exists("g:xterm16_NoHtmlColors")
  680. call s:hi( 'htmlBold', 'none', 'yellow', 'none', 'bold', 'none')
  681. call s:hi( 'htmlItalic', 'none', 'yellow', 'none', 'italic', 'none')
  682. call s:hi( 'htmlUnderline', 'none', 'darkpurple', 'none', 'underline', 'none')
  683. call s:hi( 'htmlBoldItalic', 'bold', 'yellow', 'none', 'bold,italic', 'none')
  684. call s:hi( 'htmlBoldUnderline', 'bold', 'darkpurple', 'none', 'bold,underline', 'none')
  685. call s:hi( 'htmlUnderlineItalic', 'bold', 'darkpurple', 'none', 'underline,italic', 'none')
  686. call s:hi( 'htmlBoldUnderlineItalic', 'bold', 'white', 'none', 'bold,underline,italic', 'none')
  687. endif
  688. " }}}2
  689. else
  690. throw 'xterm16 Error: Unrecognised colormap "' . s:colormap . '"'
  691. endif
  692. " }}}1
  693. catch /^xterm16 Error:/
  694. " {{{1 Handle internal exceptions.
  695. unlet colors_name
  696. echohl ErrorMsg
  697. echomsg v:exception
  698. echohl None
  699. " }}}1
  700. finally
  701. " {{{1 Unlet script variables and functions
  702. " Restore compatibility options
  703. let &cpo = s:cpo_save
  704. unlet! s:c1 s:c2 s:c3
  705. unlet! s:i s:lower s:upper s:ccube s:cinterval
  706. unlet! s:cpo_save s:hex s:l s:m s:h s:cterm_none s:gui_none
  707. " Delete colors of "standard" colormap
  708. unlet! s:gui_black s:gui_darkred s:gui_darkgreen s:gui_darkyellow s:gui_darkblue s:gui_darkmagenta s:gui_darkcyan s:gui_grey s:gui_darkgrey s:gui_red s:gui_green s:gui_yellow s:gui_blue s:gui_magenta s:gui_cyan s:gui_white
  709. unlet! s:cterm_black s:cterm_darkred s:cterm_darkgreen s:cterm_darkyellow s:cterm_darkblue s:cterm_darkmagenta s:cterm_darkcyan s:cterm_grey s:cterm_darkgrey s:cterm_red s:cterm_green s:cterm_yellow s:cterm_blue s:cterm_magenta s:cterm_cyan s:cterm_white
  710. " Delete extra colors of "soft" colormap
  711. unlet! s:gui_lightbrown s:gui_bluegreen s:gui_skyblue s:gui_purple
  712. unlet! s:cterm_lightbrown s:cterm_bluegreen s:cterm_skyblue s:cterm_purple
  713. " Delete extra colors from "allblue" colormap
  714. unlet! s:gui_darkcyan s:gui_darkblue s:gui_grey1 s:gui_grey2 s:gui_grey3 s:gui_grey4 s:gui_grey5 s:gui_white1 s:gui_dirtygreen s:gui_yellowgreen s:gui_lightblue s:gui_lightcyan s:gui_darkpurple
  715. unlet! s:cterm_darkcyan s:cterm_darkblue s:cterm_grey1 s:cterm_grey2 s:cterm_grey3 s:cterm_grey4 s:cterm_grey5 s:cterm_white1 s:cterm_dirtygreen s:cterm_yellowgreen s:cterm_lightblue s:cterm_lightcyan s:cterm_darkpurple
  716. delfunction s:tohex
  717. delfunction s:extractRGB
  718. delfunction s:guilevel
  719. delfunction s:ctermlevel
  720. delfunction s:guicolor
  721. delfunction s:ctermcolor
  722. delfunction s:setcolor
  723. delfunction s:getcolor
  724. delfunction s:use_guiattr
  725. delfunction s:hi
  726. delfunction s:set_brightness
  727. " }}}1
  728. endtry