citadel

My dotfiles, scripts and nix configs
git clone git://jb55.com/citadel
Log | Files | Refs | README | LICENSE

wombat256-trans.vim (6668B)


      1 " Vim color file
      2 " Maintainer:   David Liang (bmdavll at gmail dot com)
      3 " Last Change:  November 28 2008
      4 "
      5 " wombat256.vim - a modified version of Wombat by Lars Nielsen that also
      6 " works on xterms with 88 or 256 colors. The algorithm for approximating the
      7 " GUI colors with the xterm palette is from desert256.vim by Henry So Jr.
      8 
      9 set background=dark
     10 
     11 if version > 580
     12 	hi clear
     13 	if exists("syntax_on")
     14 		syntax reset
     15 	endif
     16 endif
     17 
     18 let g:colors_name = "wombat256"
     19 
     20 if !has("gui_running") && &t_Co != 88 && &t_Co != 256
     21 	finish
     22 endif
     23 
     24 " functions {{{
     25 " returns an approximate grey index for the given grey level
     26 fun <SID>grey_number(x)
     27 	if &t_Co == 88
     28 		if a:x < 23
     29 			return 0
     30 		elseif a:x < 69
     31 			return 1
     32 		elseif a:x < 103
     33 			return 2
     34 		elseif a:x < 127
     35 			return 3
     36 		elseif a:x < 150
     37 			return 4
     38 		elseif a:x < 173
     39 			return 5
     40 		elseif a:x < 196
     41 			return 6
     42 		elseif a:x < 219
     43 			return 7
     44 		elseif a:x < 243
     45 			return 8
     46 		else
     47 			return 9
     48 		endif
     49 	else
     50 		if a:x < 14
     51 			return 0
     52 		else
     53 			let l:n = (a:x - 8) / 10
     54 			let l:m = (a:x - 8) % 10
     55 			if l:m < 5
     56 				return l:n
     57 			else
     58 				return l:n + 1
     59 			endif
     60 		endif
     61 	endif
     62 endfun
     63 
     64 " returns the actual grey level represented by the grey index
     65 fun <SID>grey_level(n)
     66 	if &t_Co == 88
     67 		if a:n == 0
     68 			return 0
     69 		elseif a:n == 1
     70 			return 46
     71 		elseif a:n == 2
     72 			return 92
     73 		elseif a:n == 3
     74 			return 115
     75 		elseif a:n == 4
     76 			return 139
     77 		elseif a:n == 5
     78 			return 162
     79 		elseif a:n == 6
     80 			return 185
     81 		elseif a:n == 7
     82 			return 208
     83 		elseif a:n == 8
     84 			return 231
     85 		else
     86 			return 255
     87 		endif
     88 	else
     89 		if a:n == 0
     90 			return 0
     91 		else
     92 			return 8 + (a:n * 10)
     93 		endif
     94 	endif
     95 endfun
     96 
     97 " returns the palette index for the given grey index
     98 fun <SID>grey_color(n)
     99 	if &t_Co == 88
    100 		if a:n == 0
    101 			return 16
    102 		elseif a:n == 9
    103 			return 79
    104 		else
    105 			return 79 + a:n
    106 		endif
    107 	else
    108 		if a:n == 0
    109 			return 16
    110 		elseif a:n == 25
    111 			return 231
    112 		else
    113 			return 231 + a:n
    114 		endif
    115 	endif
    116 endfun
    117 
    118 " returns an approximate color index for the given color level
    119 fun <SID>rgb_number(x)
    120 	if &t_Co == 88
    121 		if a:x < 69
    122 			return 0
    123 		elseif a:x < 172
    124 			return 1
    125 		elseif a:x < 230
    126 			return 2
    127 		else
    128 			return 3
    129 		endif
    130 	else
    131 		if a:x < 75
    132 			return 0
    133 		else
    134 			let l:n = (a:x - 55) / 40
    135 			let l:m = (a:x - 55) % 40
    136 			if l:m < 20
    137 				return l:n
    138 			else
    139 				return l:n + 1
    140 			endif
    141 		endif
    142 	endif
    143 endfun
    144 
    145 " returns the actual color level for the given color index
    146 fun <SID>rgb_level(n)
    147 	if &t_Co == 88
    148 		if a:n == 0
    149 			return 0
    150 		elseif a:n == 1
    151 			return 139
    152 		elseif a:n == 2
    153 			return 205
    154 		else
    155 			return 255
    156 		endif
    157 	else
    158 		if a:n == 0
    159 			return 0
    160 		else
    161 			return 55 + (a:n * 40)
    162 		endif
    163 	endif
    164 endfun
    165 
    166 " returns the palette index for the given R/G/B color indices
    167 fun <SID>rgb_color(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 
    175 " returns the palette index to approximate the given R/G/B color levels
    176 fun <SID>color(r, g, b)
    177 	" get the closest grey
    178 	let l:gx = <SID>grey_number(a:r)
    179 	let l:gy = <SID>grey_number(a:g)
    180 	let l:gz = <SID>grey_number(a:b)
    181 
    182 	" get the closest color
    183 	let l:x = <SID>rgb_number(a:r)
    184 	let l:y = <SID>rgb_number(a:g)
    185 	let l:z = <SID>rgb_number(a:b)
    186 
    187 	if l:gx == l:gy && l:gy == l:gz
    188 		" there are two possibilities
    189 		let l:dgr = <SID>grey_level(l:gx) - a:r
    190 		let l:dgg = <SID>grey_level(l:gy) - a:g
    191 		let l:dgb = <SID>grey_level(l:gz) - a:b
    192 		let l:dgrey = (l:dgr * l:dgr) + (l:dgg * l:dgg) + (l:dgb * l:dgb)
    193 		let l:dr = <SID>rgb_level(l:gx) - a:r
    194 		let l:dg = <SID>rgb_level(l:gy) - a:g
    195 		let l:db = <SID>rgb_level(l:gz) - a:b
    196 		let l:drgb = (l:dr * l:dr) + (l:dg * l:dg) + (l:db * l:db)
    197 		if l:dgrey < l:drgb
    198 			" use the grey
    199 			return <SID>grey_color(l:gx)
    200 		else
    201 			" use the color
    202 			return <SID>rgb_color(l:x, l:y, l:z)
    203 		endif
    204 	else
    205 		" only one possibility
    206 		return <SID>rgb_color(l:x, l:y, l:z)
    207 	endif
    208 endfun
    209 
    210 " returns the palette index to approximate the 'rrggbb' hex string
    211 fun <SID>rgb(rgb)
    212 	let l:r = ("0x" . strpart(a:rgb, 0, 2)) + 0
    213 	let l:g = ("0x" . strpart(a:rgb, 2, 2)) + 0
    214 	let l:b = ("0x" . strpart(a:rgb, 4, 2)) + 0
    215 	return <SID>color(l:r, l:g, l:b)
    216 endfun
    217 
    218 " sets the highlighting for the given group
    219 fun <SID>X(group, fg, bg, attr)
    220 	if a:fg != ""
    221 		exec "hi ".a:group." guifg=#".a:fg." ctermfg=".<SID>rgb(a:fg)
    222 	endif
    223 	if a:bg != "" && a:bg != "242424"
    224 		exec "hi ".a:group." guibg=#".a:bg." ctermbg=".<SID>rgb(a:bg)
    225 	endif
    226 	if a:bg == "242424"
    227 		exec "hi ".a:group." guibg=#".a:bg." ctermbg=none"
    228 	endif
    229 	if a:attr != ""
    230 		if a:attr == 'italic'
    231 			exec "hi ".a:group." gui=".a:attr." cterm=none"
    232 		else
    233 			exec "hi ".a:group." gui=".a:attr." cterm=".a:attr
    234 		endif
    235 	endif
    236 endfun
    237 " }}}
    238 
    239 call <SID>X("Normal",		"cccccc",	"242424",	"none")
    240 call <SID>X("Cursor",		"222222",	"ecee90",	"none")
    241 call <SID>X("CursorLine",	"",			"32322e",	"none")
    242 call <SID>X("CursorColumn",	"",			"2d2d2d",	"")
    243 			"CursorIM
    244 			"Question
    245 			"IncSearch
    246 call <SID>X("Search",		"444444",	"af87d7",	"")
    247 call <SID>X("MatchParen",	"ecee90",	"857b6f",	"bold")
    248 call <SID>X("SpecialKey",	"6c6c6c",	"2d2d2d",	"none")
    249 call <SID>X("Visual",		"ecee90",	"597418",	"none")
    250 call <SID>X("LineNr",		"857b6f",	"121212",	"none")
    251 call <SID>X("Folded",		"a0a8b0",	"404048",	"none")
    252 call <SID>X("Title",		"f6f3e8",	"",			"bold")
    253 call <SID>X("VertSplit",	"444444",	"444444",	"none")
    254 call <SID>X("StatusLine",	"f6f3e8",	"444444",	"italic")
    255 call <SID>X("StatusLineNC",	"857b6f",	"444444",	"none")
    256 			"Scrollbar
    257 			"Tooltip
    258 			"Menu
    259 			"WildMenu
    260 call <SID>X("Pmenu",		"f6f3e8",	"444444",	"")
    261 call <SID>X("PmenuSel",		"121212",	"caeb82",	"")
    262 call <SID>X("WarningMsg",	"ff0000",	"",			"")
    263 			"ErrorMsg
    264 			"ModeMsg
    265 			"MoreMsg
    266 			"Directory
    267 			"DiffAdd
    268 			"DiffChange
    269 			"DiffDelete
    270 			"DiffText
    271 
    272 " syntax highlighting
    273 call <SID>X("Number",		"e5786d",	"",			"none")
    274 call <SID>X("Constant",		"e5786d",	"",			"none")
    275 call <SID>X("String",		"95e454",	"",			"italic")
    276 call <SID>X("Comment",		"c0bc6c",	"",			"italic")
    277 call <SID>X("Identifier",	"caeb82",	"",			"none")
    278 call <SID>X("Keyword",		"87afff",	"",			"none")
    279 call <SID>X("Statement",	"87afff",	"",			"none")
    280 call <SID>X("Function",		"caeb82",	"",			"none")
    281 call <SID>X("PreProc",		"e5786d",	"",			"none")
    282 call <SID>X("Type",			"caeb82",	"",			"none")
    283 call <SID>X("Special",		"ffdead",	"",			"none")
    284 call <SID>X("Todo",			"857b6f",	"",			"italic")
    285 			"Underlined
    286 			"Error
    287 			"Ignore
    288 
    289 hi! link VisualNOS	Visual
    290 hi! link NonText	LineNr
    291 hi! link FoldColumn	Folded
    292 
    293 " delete functions {{{
    294 delf <SID>X
    295 delf <SID>rgb
    296 delf <SID>color
    297 delf <SID>rgb_color
    298 delf <SID>rgb_level
    299 delf <SID>rgb_number
    300 delf <SID>grey_color
    301 delf <SID>grey_level
    302 delf <SID>grey_number
    303 " }}}
    304 
    305 " vim:set ts=4 sw=4 noet fdm=marker: