2 " Maintainer: David Liang (bmdavll at gmail dot com)
3 " Last Change: November 28 2008
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.
13 if exists("syntax_on")
18 let g:colors_name = "wombat256"
20 if !has("gui_running") && &t_Co != 88 && &t_Co != 256
25 " returns an approximate grey index for the given grey level
26 fun <SID>grey_number(x)
53 let l:n = (a:x - 8) / 10
54 let l:m = (a:x - 8) % 10
64 " returns the actual grey level represented by the grey index
65 fun <SID>grey_level(n)
97 " returns the palette index for the given grey index
98 fun <SID>grey_color(n)
118 " returns an approximate color index for the given color level
119 fun <SID>rgb_number(x)
134 let l:n = (a:x - 55) / 40
135 let l:m = (a:x - 55) % 40
145 " returns the actual color level for the given color index
146 fun <SID>rgb_level(n)
161 return 55 + (a:n * 40)
166 " returns the palette index for the given R/G/B color indices
167 fun <SID>rgb_color(x, y, z)
169 return 16 + (a:x * 16) + (a:y * 4) + a:z
171 return 16 + (a:x * 36) + (a:y * 6) + a:z
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)
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)
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)
199 return <SID>grey_color(l:gx)
202 return <SID>rgb_color(l:x, l:y, l:z)
205 " only one possibility
206 return <SID>rgb_color(l:x, l:y, l:z)
210 " returns the palette index to approximate the 'rrggbb' hex string
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)
218 " sets the highlighting for the given group
219 fun <SID>X(group, fg, bg, attr)
221 exec "hi ".a:group." guifg=#".a:fg." ctermfg=".<SID>rgb(a:fg)
224 exec "hi ".a:group." guibg=#".a:bg." ctermbg=".<SID>rgb(a:bg)
227 if a:attr == 'italic'
228 exec "hi ".a:group." gui=".a:attr." cterm=none"
230 exec "hi ".a:group." gui=".a:attr." cterm=".a:attr
236 call <SID>X("Normal", "cccccc", "242424", "none")
237 call <SID>X("Cursor", "222222", "ecee90", "none")
238 call <SID>X("CursorLine", "", "32322e", "none")
239 call <SID>X("CursorColumn", "", "2d2d2d", "")
243 call <SID>X("Search", "444444", "af87d7", "")
244 call <SID>X("MatchParen", "ecee90", "857b6f", "bold")
245 call <SID>X("SpecialKey", "6c6c6c", "2d2d2d", "none")
246 call <SID>X("Visual", "ecee90", "597418", "none")
247 call <SID>X("LineNr", "857b6f", "121212", "none")
248 call <SID>X("Folded", "a0a8b0", "404048", "none")
249 call <SID>X("Title", "f6f3e8", "", "bold")
250 call <SID>X("VertSplit", "444444", "444444", "none")
251 call <SID>X("StatusLine", "f6f3e8", "444444", "italic")
252 call <SID>X("StatusLineNC", "857b6f", "444444", "none")
257 call <SID>X("Pmenu", "f6f3e8", "444444", "")
258 call <SID>X("PmenuSel", "121212", "caeb82", "")
259 call <SID>X("WarningMsg", "ff0000", "", "")
269 " syntax highlighting
270 call <SID>X("Number", "e5786d", "", "none")
271 call <SID>X("Constant", "e5786d", "", "none")
272 call <SID>X("String", "95e454", "", "italic")
273 call <SID>X("Comment", "c0bc6c", "", "italic")
274 call <SID>X("Identifier", "caeb82", "", "none")
275 call <SID>X("Keyword", "87afff", "", "none")
276 call <SID>X("Statement", "87afff", "", "none")
277 call <SID>X("Function", "caeb82", "", "none")
278 call <SID>X("PreProc", "e5786d", "", "none")
279 call <SID>X("Type", "caeb82", "", "none")
280 call <SID>X("Special", "ffdead", "", "none")
281 call <SID>X("Todo", "857b6f", "", "italic")
286 hi! link VisualNOS Visual
287 hi! link NonText LineNr
288 hi! link FoldColumn Folded
290 " delete functions {{{
299 delf <SID>grey_number
302 " vim:set ts=4 sw=4 noet fdm=marker: