314
Vc
vim-colors-256 / files
vim-colors-256 / colors / simple256.vim
8.1 KB
1" Vim color file 2" Maintainer: Alexander Rodin <rodin.alexander@gmail.com> 3" 4" This theme is based on "desert256" theme by Henry So, Jr. 5" 6" I struggled with trying to parse the rgb.txt file to avoid the necessity of 7" converting color names to #rrggbb form, but decided it was just not worth 8" the effort. Maybe someone seeing this may decide otherwise... 9 10set background=light 11if version > 580 12 " no guarantees for version 5.8 and below, but this makes it stop 13 " complaining 14 hi clear 15 if exists("syntax_on") 16 syntax reset 17 endif 18endif 19let g:colors_name="desert256" 20 21if has("gui_running") || &t_Co == 88 || &t_Co == 256 22 " functions {{{ 23 " returns an approximate grey index for the given grey level 24 fun <SID>grey_number(x) 25 if &t_Co == 88 26 if a:x < 23 27 return 0 28 elseif a:x < 69 29 return 1 30 elseif a:x < 103 31 return 2 32 elseif a:x < 127 33 return 3 34 elseif a:x < 150 35 return 4 36 elseif a:x < 173 37 return 5 38 elseif a:x < 196 39 return 6 40 elseif a:x < 219 41 return 7 42 elseif a:x < 243 43 return 8 44 else 45 return 9 46 endif 47 else 48 if a:x < 14 49 return 0 50 else 51 let l:n = (a:x - 8) / 10 52 let l:m = (a:x - 8) % 10 53 if l:m < 5 54 return l:n 55 else 56 return l:n + 1 57 endif 58 endif 59 endif 60 endfun 61 62 " returns the actual grey level represented by the grey index 63 fun <SID>grey_level(n) 64 if &t_Co == 88 65 if a:n == 0 66 return 0 67 elseif a:n == 1 68 return 46 69 elseif a:n == 2 70 return 92 71 elseif a:n == 3 72 return 115 73 elseif a:n == 4 74 return 139 75 elseif a:n == 5 76 return 162 77 elseif a:n == 6 78 return 185 79 elseif a:n == 7 80 return 208 81 elseif a:n == 8 82 return 231 83 else 84 return 255 85 endif 86 else 87 if a:n == 0 88 return 0 89 else 90 return 8 + (a:n * 10) 91 endif 92 endif 93 endfun 94 95 " returns the palette index for the given grey index 96 fun <SID>grey_color(n) 97 if &t_Co == 88 98 if a:n == 0 99 return 16 100 elseif a:n == 9 101 return 79 102 else 103 return 79 + a:n 104 endif 105 else 106 if a:n == 0 107 return 16 108 elseif a:n == 25 109 return 231 110 else 111 return 231 + a:n 112 endif 113 endif 114 endfun 115 116 " returns an approximate color index for the given color level 117 fun <SID>rgb_number(x) 118 if &t_Co == 88 119 if a:x < 69 120 return 0 121 elseif a:x < 172 122 return 1 123 elseif a:x < 230 124 return 2 125 else 126 return 3 127 endif 128 else 129 if a:x < 75 130 return 0 131 else 132 let l:n = (a:x - 55) / 40 133 let l:m = (a:x - 55) % 40 134 if l:m < 20 135 return l:n 136 else 137 return l:n + 1 138 endif 139 endif 140 endif 141 endfun 142 143 " returns the actual color level for the given color index 144 fun <SID>rgb_level(n) 145 if &t_Co == 88 146 if a:n == 0 147 return 0 148 elseif a:n == 1 149 return 139 150 elseif a:n == 2 151 return 205 152 else 153 return 255 154 endif 155 else 156 if a:n == 0 157 return 0 158 else 159 return 55 + (a:n * 40) 160 endif 161 endif 162 endfun 163 164 " returns the palette index for the given R/G/B color indices 165 fun <SID>rgb_color(x, y, z) 166 if &t_Co == 88 167 return 16 + (a:x * 16) + (a:y * 4) + a:z 168 else 169 return 16 + (a:x * 36) + (a:y * 6) + a:z 170 endif 171 endfun 172 173 " returns the palette index to approximate the given R/G/B color levels 174 fun <SID>color(r, g, b) 175 " get the closest grey 176 let l:gx = <SID>grey_number(a:r) 177 let l:gy = <SID>grey_number(a:g) 178 let l:gz = <SID>grey_number(a:b) 179 180 " get the closest color 181 let l:x = <SID>rgb_number(a:r) 182 let l:y = <SID>rgb_number(a:g) 183 let l:z = <SID>rgb_number(a:b) 184 185 if l:gx == l:gy && l:gy == l:gz 186 " there are two possibilities 187 let l:dgr = <SID>grey_level(l:gx) - a:r 188 let l:dgg = <SID>grey_level(l:gy) - a:g 189 let l:dgb = <SID>grey_level(l:gz) - a:b 190 let l:dgrey = (l:dgr * l:dgr) + (l:dgg * l:dgg) + (l:dgb * l:dgb) 191 let l:dr = <SID>rgb_level(l:gx) - a:r 192 let l:dg = <SID>rgb_level(l:gy) - a:g 193 let l:db = <SID>rgb_level(l:gz) - a:b 194 let l:drgb = (l:dr * l:dr) + (l:dg * l:dg) + (l:db * l:db) 195 if l:dgrey < l:drgb 196 " use the grey 197 return <SID>grey_color(l:gx) 198 else 199 " use the color 200 return <SID>rgb_color(l:x, l:y, l:z) 201 endif 202 else 203 " only one possibility 204 return <SID>rgb_color(l:x, l:y, l:z) 205 endif 206 endfun 207 208 " returns the palette index to approximate the 'rrggbb' hex string 209 fun <SID>rgb(rgb) 210 let l:r = ("0x" . strpart(a:rgb, 0, 2)) + 0 211 let l:g = ("0x" . strpart(a:rgb, 2, 2)) + 0 212 let l:b = ("0x" . strpart(a:rgb, 4, 2)) + 0 213 214 return <SID>color(l:r, l:g, l:b) 215 endfun 216 217 " sets the highlighting for the given group 218 fun <SID>X(group, fg, bg, attr) 219 if a:fg != "" 220 exec "hi " . a:group . " guifg=#" . a:fg . " ctermfg=" . <SID>rgb(a:fg) 221 endif 222 if a:bg != "" 223 exec "hi " . a:group . " guibg=#" . a:bg . " ctermbg=" . <SID>rgb(a:bg) 224 endif 225 if a:attr != "" 226 exec "hi " . a:group . " gui=" . a:attr . " cterm=" . a:attr 227 endif 228 endfun 229 " }}} 230 231 call <SID>X("VertSplit", "c2bfa5", "7f7f7f", "reverse") 232 call <SID>X("Folded", "9999cc", "f4f4f4", "") 233 call <SID>X("IncSearch", "708090", "f0e68c", "") 234 call <SID>X("Visual", "3888ff", "ffffff", "reverse") 235" call <SID>X("Comment", "1C9518", "", "") 236 call <SID>X("Comment", "20AD1B", "", "") 237 call <SID>X("Constant", "5500ff", "", "") 238 call <SID>X("String", "ff7777", "", "") 239 call <SID>X("Float", "ff7777", "", "") 240 call <SID>X("Boolean", "000080", "", "bold") 241" call <SID>X("Identifier", "98fb98", "", "none") 242 call <SID>X("Statement", "000080", "", "bold") 243 call <SID>X("PreProc", "20b5ff", "", "") 244 call <SID>X("Type", "000080", "", "bold") 245 call <SID>X("Special", "CDAB00", "", "") 246 call <SID>X("Underlined", "0000cc", "", "") 247 call <SID>X("Todo", "ff4500", "eeee00", "") 248 249 " delete functions {{{ 250 delf <SID>X 251 delf <SID>rgb 252 delf <SID>color 253 delf <SID>rgb_color 254 delf <SID>rgb_level 255 delf <SID>rgb_number 256 delf <SID>grey_color 257 delf <SID>grey_level 258 delf <SID>grey_number 259 " }}} 260else 261 " color terminal definitions 262 hi VertSplit ctermfg=lightgray ctermbg=gray cterm=reverse 263 hi Folded ctermfg=blue ctermbg=lightcyan 264 hi IncSearch ctermfg=lightgray ctermbg=yellow 265 hi Visual ctermfg=blue ctermbg=white cterm=reverse 266 hi Comment ctermfg=green 267 hi Constant ctermfg=blue 268 hi String ctermfg=red 269 hi Float ctermfg=red 270 hi Boolean ctermfg=darkblue cterm=bold 271 hi Statement ctermfg=darkblue cterm=bold 272 hi PreProc ctermfg=cyan 273 hi Type ctermfg=darkblue cterm=bold 274 hi Special ctermfg=brown 275 hi Underlined ctermfg=blue 276 hi Todo ctermfg=red ctermbg=yellow 277endif 278 279" vim: set fdl=0 fdm=marker: