xonecas.io
314
Vc

vim-colors-256 / files

vim-colors-256 / colors / desert256v2.vim

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