314
Vc
vim-colors-256 / files
vim-colors-256 / colors / twilight256.vim
8.6 KB
1" twilight256 color scheme file 2" Maintainer: Neal Milstein - neal dot milstein at gmail dot com 3" Last Change: 2011 Feb 1 4" 5" This theme copies the colors from the TextMate theme Twilight. 6" 7" The theme is designed to be used on a black background. I only tested it 8" using a 256-color terminal; I do not think it will work on much else (gvim, 9" 8-color terminal, etc.). 10" 11" The functions in this theme that convert hex color codes to the nearest 12" xterm-256 color number are from the theme desert2 (desert256), developed by Henry So, Jr. 13" 14" The colors of this theme are based on the TextMate Twilight theme 15" – www.macromates.com 16 17set background=dark 18if version > 580 19 " no guarantees for version 5.8 and below, but this makes it stop 20 " complaining 21 hi clear 22 if exists("syntax_on") 23 syntax reset 24 endif 25endif 26let g:colors_name="twilight256" 27 28if has("gui_running") || &t_Co == 88 || &t_Co == 256 29 " functions {{{ 30 " returns an approximate grey index for the given grey level 31 fun <SID>grey_number(x) 32 if &t_Co == 88 33 if a:x < 23 34 return 0 35 elseif a:x < 69 36 return 1 37 elseif a:x < 103 38 return 2 39 elseif a:x < 127 40 return 3 41 elseif a:x < 150 42 return 4 43 elseif a:x < 173 44 return 5 45 elseif a:x < 196 46 return 6 47 elseif a:x < 219 48 return 7 49 elseif a:x < 243 50 return 8 51 else 52 return 9 53 endif 54 else 55 if a:x < 14 56 return 0 57 else 58 let l:n = (a:x - 8) / 10 59 let l:m = (a:x - 8) % 10 60 if l:m < 5 61 return l:n 62 else 63 return l:n + 1 64 endif 65 endif 66 endif 67 endfun 68 69 " returns the actual grey level represented by the grey index 70 fun <SID>grey_level(n) 71 if &t_Co == 88 72 if a:n == 0 73 return 0 74 elseif a:n == 1 75 return 46 76 elseif a:n == 2 77 return 92 78 elseif a:n == 3 79 return 115 80 elseif a:n == 4 81 return 139 82 elseif a:n == 5 83 return 162 84 elseif a:n == 6 85 return 185 86 elseif a:n == 7 87 return 208 88 elseif a:n == 8 89 return 231 90 else 91 return 255 92 endif 93 else 94 if a:n == 0 95 return 0 96 else 97 return 8 + (a:n * 10) 98 endif 99 endif 100 endfun 101 102 " returns the palette index for the given grey index 103 fun <SID>grey_color(n) 104 if &t_Co == 88 105 if a:n == 0 106 return 16 107 elseif a:n == 9 108 return 79 109 else 110 return 79 + a:n 111 endif 112 else 113 if a:n == 0 114 return 16 115 elseif a:n == 25 116 return 231 117 else 118 return 231 + a:n 119 endif 120 endif 121 endfun 122 123 " returns an approximate color index for the given color level 124 fun <SID>rgb_number(x) 125 if &t_Co == 88 126 if a:x < 69 127 return 0 128 elseif a:x < 172 129 return 1 130 elseif a:x < 230 131 return 2 132 else 133 return 3 134 endif 135 else 136 if a:x < 75 137 return 0 138 else 139 let l:n = (a:x - 55) / 40 140 let l:m = (a:x - 55) % 40 141 if l:m < 20 142 return l:n 143 else 144 return l:n + 1 145 endif 146 endif 147 endif 148 endfun 149 150 " returns the actual color level for the given color index 151 fun <SID>rgb_level(n) 152 if &t_Co == 88 153 if a:n == 0 154 return 0 155 elseif a:n == 1 156 return 139 157 elseif a:n == 2 158 return 205 159 else 160 return 255 161 endif 162 else 163 if a:n == 0 164 return 0 165 else 166 return 55 + (a:n * 40) 167 endif 168 endif 169 endfun 170 171 " returns the palette index for the given R/G/B color indices 172 fun <SID>rgb_color(x, y, z) 173 if &t_Co == 88 174 return 16 + (a:x * 16) + (a:y * 4) + a:z 175 else 176 return 16 + (a:x * 36) + (a:y * 6) + a:z 177 endif 178 endfun 179 180 " returns the palette index to approximate the given R/G/B color levels 181 fun <SID>color(r, g, b) 182 " get the closest grey 183 let l:gx = <SID>grey_number(a:r) 184 let l:gy = <SID>grey_number(a:g) 185 let l:gz = <SID>grey_number(a:b) 186 187 " get the closest color 188 let l:x = <SID>rgb_number(a:r) 189 let l:y = <SID>rgb_number(a:g) 190 let l:z = <SID>rgb_number(a:b) 191 192 if l:gx == l:gy && l:gy == l:gz 193 " there are two possibilities 194 let l:dgr = <SID>grey_level(l:gx) - a:r 195 let l:dgg = <SID>grey_level(l:gy) - a:g 196 let l:dgb = <SID>grey_level(l:gz) - a:b 197 let l:dgrey = (l:dgr * l:dgr) + (l:dgg * l:dgg) + (l:dgb * l:dgb) 198 let l:dr = <SID>rgb_level(l:gx) - a:r 199 let l:dg = <SID>rgb_level(l:gy) - a:g 200 let l:db = <SID>rgb_level(l:gz) - a:b 201 let l:drgb = (l:dr * l:dr) + (l:dg * l:dg) + (l:db * l:db) 202 if l:dgrey < l:drgb 203 " use the grey 204 return <SID>grey_color(l:gx) 205 else 206 " use the color 207 return <SID>rgb_color(l:x, l:y, l:z) 208 endif 209 else 210 " only one possibility 211 return <SID>rgb_color(l:x, l:y, l:z) 212 endif 213 endfun 214 215 " returns the palette index to approximate the 'rrggbb' hex string 216 fun <SID>rgb(rgb) 217 let l:r = ("0x" . strpart(a:rgb, 0, 2)) + 0 218 let l:g = ("0x" . strpart(a:rgb, 2, 2)) + 0 219 let l:b = ("0x" . strpart(a:rgb, 4, 2)) + 0 220 221 return <SID>color(l:r, l:g, l:b) 222 endfun 223 224 " sets the highlighting for the given group 225 fun <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 exec "hi " . a:group . " gui=" . a:attr . " cterm=" . a:attr 234 endif 235 endfun 236 " }}} 237 238 call <SID>X("Normal", "ffffff", "", "") 239 240 " highlight groups 241 "call <SID>X("Cursor", "708090", "f0e68c", "") 242 "CursorIM 243 "Directory 244 "DiffAdd 245 "DiffChange 246 "DiffDelete 247 "DiffText 248 "ErrorMsg 249 "call <SID>X("VertSplit", "c2bfa5", "7f7f7f", "reverse") 250 "call <SID>X("Folded", "ffd700", "4d4d4d", "") 251 "call <SID>X("FoldColumn", "d2b48c", "4d4d4d", "") 252 "call <SID>X("IncSearch", "708090", "f0e68c", "") 253 call <SID>X("LineNr", "CCCCCC", "", "") 254 "call <SID>X("ModeMsg", "D4D4D4", "", "") 255 "call <SID>X("MoreMsg", "2e8b57", "", "") 256 "call <SID>X("NonText", "addbe7", "000000", "bold") 257 "call <SID>X("Question", "00ff7f", "", "") 258 "call <SID>X("Search", "f5deb3", "cd853f", "") 259 "call <SID>X("SpecialKey", "9acd32", "", "") 260 "call <SID>X("StatusLine", "c2bfa5", "000000", "reverse") 261 "call <SID>X("StatusLineNC", "c2bfa5", "7f7f7f", "reverse") 262 "call <SID>X("Title", "cd5c5c", "", "") 263 call <SID>X("Visual", "D3D3D3", "3E3E3E", "reverse") 264 "VisualNOS 265 "call <SID>X("WarningMsg", "fa8072", "", "") 266 "WildMenu 267 "Menu 268 "Scrollbar 269 "Tooltip 270 271 " syntax highlighting groups 272 call <SID>X("Comment", "828282", "", "") 273 call <SID>X("Constant", "CF6A4C", "", "") 274 call <SID>X("Identifier", "7587A6", "", "none") 275 call <SID>X("Function", "9B703F", "", "") 276 call <SID>X("Define", "CDA869", "", "none") 277 call <SID>X("Statement", "CDA869", "", "") 278 call <SID>X("String", "8F9D6A", "", "") 279 call <SID>X("PreProc", "AFC4DB", "", "") 280 call <SID>X("Type", "F9EE98", "", "") 281 call <SID>X("Special", "DAEFA3", "", "") 282 "Underlined 283 call <SID>X("Ignore", "666666", "", "") 284 "Error 285 call <SID>X("Todo", "ff4500", "eeee00", "") 286 287 " delete functions {{{ 288 delf <SID>X 289 delf <SID>rgb 290 delf <SID>color 291 delf <SID>rgb_color 292 delf <SID>rgb_level 293 delf <SID>rgb_number 294 delf <SID>grey_color 295 delf <SID>grey_level 296 delf <SID>grey_number 297 " }}} 298endif 299 300" vim: set fdl=0 fdm=marker: