desert256-transparent.vim (10566B)
1 " Vim color file 2 " Maintainer: Henry So, Jr. <henryso@panix.com> 3 " Modifications by Evan Klitkze <eklitzke@gmail.com> 4 5 " These are the colors of the "desert" theme by Hans Fugal with a few small 6 " modifications (namely that I lowered the intensity of the normal white and 7 " made the normal and nontext backgrounds black), modified to work with 88- 8 " and 256-color xterms. 9 " 10 " The original "desert" theme is available as part of the vim distribution or 11 " at http://hans.fugal.net/vim/colors/. 12 " 13 " The real feature of this color scheme, with a wink to the "inkpot" theme, is 14 " the programmatic approximation of the gui colors to the palettes of 88- and 15 " 256- color xterms. The functions that do this (folded away, for 16 " readability) are calibrated to the colors used for Thomas E. Dickey's xterm 17 " (version 200), which is available at http://dickey.his.com/xterm/xterm.html. 18 " 19 " I struggled with trying to parse the rgb.txt file to avoid the necessity of 20 " converting color names to #rrggbb form, but decided it was just not worth 21 " the effort. Maybe someone seeing this may decide otherwise... 22 23 set background=dark 24 if version > 580 25 " no guarantees for version 5.8 and below, but this makes it stop 26 " complaining 27 hi clear 28 if exists("syntax_on") 29 syntax reset 30 endif 31 endif 32 let g:colors_name="desert256" 33 34 if has("gui_running") || &t_Co == 88 || &t_Co == 256 35 " functions {{{ 36 " returns an approximate grey index for the given grey level 37 fun <SID>grey_number(x) 38 if &t_Co == 88 39 if a:x < 23 40 return 0 41 elseif a:x < 69 42 return 1 43 elseif a:x < 103 44 return 2 45 elseif a:x < 127 46 return 3 47 elseif a:x < 150 48 return 4 49 elseif a:x < 173 50 return 5 51 elseif a:x < 196 52 return 6 53 elseif a:x < 219 54 return 7 55 elseif a:x < 243 56 return 8 57 else 58 return 9 59 endif 60 else 61 if a:x < 14 62 return 0 63 else 64 let l:n = (a:x - 8) / 10 65 let l:m = (a:x - 8) % 10 66 if l:m < 5 67 return l:n 68 else 69 return l:n + 1 70 endif 71 endif 72 endif 73 endfun 74 75 " returns the actual grey level represented by the grey index 76 fun <SID>grey_level(n) 77 if &t_Co == 88 78 if a:n == 0 79 return 0 80 elseif a:n == 1 81 return 46 82 elseif a:n == 2 83 return 92 84 elseif a:n == 3 85 return 115 86 elseif a:n == 4 87 return 139 88 elseif a:n == 5 89 return 162 90 elseif a:n == 6 91 return 185 92 elseif a:n == 7 93 return 208 94 elseif a:n == 8 95 return 231 96 else 97 return 255 98 endif 99 else 100 if a:n == 0 101 return 0 102 else 103 return 8 + (a:n * 10) 104 endif 105 endif 106 endfun 107 108 " returns the palette index for the given grey index 109 fun <SID>grey_color(n) 110 if &t_Co == 88 111 if a:n == 0 112 return 16 113 elseif a:n == 9 114 return 79 115 else 116 return 79 + a:n 117 endif 118 else 119 if a:n == 0 120 return 16 121 elseif a:n == 25 122 return 231 123 else 124 return 231 + a:n 125 endif 126 endif 127 endfun 128 129 " returns an approximate color index for the given color level 130 fun <SID>rgb_number(x) 131 if &t_Co == 88 132 if a:x < 69 133 return 0 134 elseif a:x < 172 135 return 1 136 elseif a:x < 230 137 return 2 138 else 139 return 3 140 endif 141 else 142 if a:x < 75 143 return 0 144 else 145 let l:n = (a:x - 55) / 40 146 let l:m = (a:x - 55) % 40 147 if l:m < 20 148 return l:n 149 else 150 return l:n + 1 151 endif 152 endif 153 endif 154 endfun 155 156 " returns the actual color level for the given color index 157 fun <SID>rgb_level(n) 158 if &t_Co == 88 159 if a:n == 0 160 return 0 161 elseif a:n == 1 162 return 139 163 elseif a:n == 2 164 return 205 165 else 166 return 255 167 endif 168 else 169 if a:n == 0 170 return 0 171 else 172 return 55 + (a:n * 40) 173 endif 174 endif 175 endfun 176 177 " returns the palette index for the given R/G/B color indices 178 fun <SID>rgb_color(x, y, z) 179 if &t_Co == 88 180 return 16 + (a:x * 16) + (a:y * 4) + a:z 181 else 182 return 16 + (a:x * 36) + (a:y * 6) + a:z 183 endif 184 endfun 185 186 " returns the palette index to approximate the given R/G/B color levels 187 fun <SID>color(r, g, b) 188 " get the closest grey 189 let l:gx = <SID>grey_number(a:r) 190 let l:gy = <SID>grey_number(a:g) 191 let l:gz = <SID>grey_number(a:b) 192 193 " get the closest color 194 let l:x = <SID>rgb_number(a:r) 195 let l:y = <SID>rgb_number(a:g) 196 let l:z = <SID>rgb_number(a:b) 197 198 if l:gx == l:gy && l:gy == l:gz 199 " there are two possibilities 200 let l:dgr = <SID>grey_level(l:gx) - a:r 201 let l:dgg = <SID>grey_level(l:gy) - a:g 202 let l:dgb = <SID>grey_level(l:gz) - a:b 203 let l:dgrey = (l:dgr * l:dgr) + (l:dgg * l:dgg) + (l:dgb * l:dgb) 204 let l:dr = <SID>rgb_level(l:gx) - a:r 205 let l:dg = <SID>rgb_level(l:gy) - a:g 206 let l:db = <SID>rgb_level(l:gz) - a:b 207 let l:drgb = (l:dr * l:dr) + (l:dg * l:dg) + (l:db * l:db) 208 if l:dgrey < l:drgb 209 " use the grey 210 return <SID>grey_color(l:gx) 211 else 212 " use the color 213 return <SID>rgb_color(l:x, l:y, l:z) 214 endif 215 else 216 " only one possibility 217 return <SID>rgb_color(l:x, l:y, l:z) 218 endif 219 endfun 220 221 " returns the palette index to approximate the 'rrggbb' hex string 222 fun <SID>rgb(rgb) 223 let l:r = ("0x" . strpart(a:rgb, 0, 2)) + 0 224 let l:g = ("0x" . strpart(a:rgb, 2, 2)) + 0 225 let l:b = ("0x" . strpart(a:rgb, 4, 2)) + 0 226 227 return <SID>color(l:r, l:g, l:b) 228 endfun 229 230 " sets the highlighting for the given group 231 fun <SID>X(group, fg, bg, attr) 232 if a:fg != "" 233 exec "hi " . a:group . " guifg=#" . a:fg . " ctermfg=" . <SID>rgb(a:fg) 234 endif 235 if a:bg != "" && a:bg != "000000" 236 exec "hi " . a:group . " guibg=#" . a:bg . " ctermbg=" . <SID>rgb(a:bg) 237 elseif a:bg == "000000" 238 exec "hi " . a:group . " guibg=#" . a:bg . " ctermbg=none" 239 endif 240 if a:attr != "" 241 exec "hi " . a:group . " gui=" . a:attr . " cterm=" . a:attr 242 endif 243 endfun 244 " }}} 245 246 call <SID>X("Normal", "cccccc", "000000", "") 247 248 " highlight groups 249 call <SID>X("Cursor", "708090", "f0e68c", "") 250 "CursorIM 251 "Directory 252 "DiffAdd 253 "DiffChange 254 "DiffDelete 255 "DiffText 256 "ErrorMsg 257 call <SID>X("VertSplit", "c2bfa5", "7f7f7f", "reverse") 258 call <SID>X("Folded", "ffd700", "4d4d4d", "") 259 call <SID>X("FoldColumn", "d2b48c", "4d4d4d", "") 260 call <SID>X("IncSearch", "708090", "f0e68c", "") 261 "LineNr 262 call <SID>X("ModeMsg", "daa520", "", "") 263 call <SID>X("MoreMsg", "2e8b57", "", "") 264 call <SID>X("NonText", "addbe7", "000000", "bold") 265 call <SID>X("Question", "00ff7f", "", "") 266 call <SID>X("Search", "f5deb3", "cd853f", "") 267 call <SID>X("SpecialKey", "9acd32", "", "") 268 call <SID>X("StatusLine", "c2bfa5", "000000", "reverse") 269 call <SID>X("StatusLineNC", "c2bfa5", "7f7f7f", "reverse") 270 call <SID>X("Title", "cd5c5c", "", "") 271 call <SID>X("Visual", "6b8e23", "f0e68c", "reverse") 272 "VisualNOS 273 call <SID>X("WarningMsg", "fa8072", "", "") 274 "WildMenu 275 "Menu 276 "Scrollbar 277 "Tooltip 278 279 " syntax highlighting groups 280 call <SID>X("Comment", "87ceeb", "", "") 281 call <SID>X("Constant", "ffa0a0", "", "") 282 call <SID>X("Identifier", "98fb98", "", "none") 283 call <SID>X("Statement", "f0e68c", "", "bold") 284 call <SID>X("PreProc", "cd5c5c", "", "") 285 call <SID>X("Type", "bdb76b", "", "bold") 286 call <SID>X("Special", "ffdead", "", "") 287 "Underlined 288 call <SID>X("Ignore", "666666", "", "") 289 "Error 290 call <SID>X("Todo", "ff4500", "eeee00", "") 291 292 " delete functions {{{ 293 delf <SID>X 294 delf <SID>rgb 295 delf <SID>color 296 delf <SID>rgb_color 297 delf <SID>rgb_level 298 delf <SID>rgb_number 299 delf <SID>grey_color 300 delf <SID>grey_level 301 delf <SID>grey_number 302 " }}} 303 else 304 " color terminal definitions 305 hi SpecialKey ctermfg=darkgreen 306 hi NonText cterm=bold ctermfg=darkblue 307 hi Directory ctermfg=darkcyan 308 hi ErrorMsg cterm=bold ctermfg=7 ctermbg=1 309 hi IncSearch cterm=NONE ctermfg=yellow ctermbg=green 310 hi Search cterm=NONE ctermfg=grey ctermbg=blue 311 hi MoreMsg ctermfg=darkgreen 312 hi ModeMsg cterm=NONE ctermfg=brown 313 hi LineNr ctermfg=3 314 hi Question ctermfg=green 315 hi StatusLine cterm=bold,reverse 316 hi StatusLineNC cterm=reverse 317 hi VertSplit cterm=reverse 318 hi Title ctermfg=5 319 hi Visual cterm=reverse 320 hi VisualNOS cterm=bold,underline 321 hi WarningMsg ctermfg=1 322 hi WildMenu ctermfg=0 ctermbg=3 323 hi Folded ctermfg=darkgrey ctermbg=NONE 324 hi FoldColumn ctermfg=darkgrey ctermbg=NONE 325 hi DiffAdd ctermbg=4 326 hi DiffChange ctermbg=5 327 hi DiffDelete cterm=bold ctermfg=4 ctermbg=6 328 hi DiffText cterm=bold ctermbg=1 329 hi Comment ctermfg=darkcyan 330 hi Constant ctermfg=brown 331 hi Special ctermfg=5 332 hi Identifier ctermfg=6 333 hi Statement ctermfg=3 334 hi PreProc ctermfg=5 335 hi Type ctermfg=2 336 hi Underlined cterm=underline ctermfg=5 337 hi Ignore ctermfg=darkgrey 338 hi Error cterm=bold ctermfg=7 ctermbg=1 339 endif 340 341 " vim: set fdl=0 fdm=marker: