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