BufExplorer options.
[profile.git] / .vim / colors / iain.vim
1 " Mangling for terminal code ripped from desert256.
2
3 if version > 580
4     " no guarantees for version 5.8 and below, but this makes it stop
5     " complaining
6     "hi clear
7     if exists("syntax_on")
8         syntax reset
9     endif
10 endif
11 let g:colors_name="iain"
12
13 if has("gui_running") || &t_Co == 88 || &t_Co == 256
14     " functions {{{
15     " returns an approximate grey index for the given grey level
16     fun! <SID>grey_number(x)
17         if &t_Co == 88
18             if a:x < 23
19                 return 0
20             elseif a:x < 69
21                 return 1
22             elseif a:x < 103
23                 return 2
24             elseif a:x < 127
25                 return 3
26             elseif a:x < 150
27                 return 4
28             elseif a:x < 173
29                 return 5
30             elseif a:x < 196
31                 return 6
32             elseif a:x < 219
33                 return 7
34             elseif a:x < 243
35                 return 8
36             else
37                 return 9
38             endif
39         else
40             if a:x < 14
41                 return 0
42             else
43                 let l:n = (a:x - 8) / 10
44                 let l:m = (a:x - 8) % 10
45                 if l:m < 5
46                     return l:n
47                 else
48                     return l:n + 1
49                 endif
50             endif
51         endif
52     endfun
53
54     " returns the actual grey level represented by the grey index
55     fun! <SID>grey_level(n)
56         if &t_Co == 88
57             if a:n == 0
58                 return 0
59             elseif a:n == 1
60                 return 46
61             elseif a:n == 2
62                 return 92
63             elseif a:n == 3
64                 return 115
65             elseif a:n == 4
66                 return 139
67             elseif a:n == 5
68                 return 162
69             elseif a:n == 6
70                 return 185
71             elseif a:n == 7
72                 return 208
73             elseif a:n == 8
74                 return 231
75             else
76                 return 255
77             endif
78         else
79             if a:n == 0
80                 return 0
81             else
82                 return 8 + (a:n * 10)
83             endif
84         endif
85     endfun
86
87     " returns the palette index for the given grey index
88     fun! <SID>grey_color(n)
89         if &t_Co == 88
90             if a:n == 0
91                 return 16
92             elseif a:n == 9
93                 return 79
94             else
95                 return 79 + a:n
96             endif
97         else
98             if a:n == 0
99                 return 16
100             elseif a:n == 25
101                 return 231
102             else
103                 return 231 + a:n
104             endif
105         endif
106     endfun
107
108     " returns an approximate color index for the given color level
109     fun! <SID>rgb_number(x)
110         if &t_Co == 88
111             if a:x < 69
112                 return 0
113             elseif a:x < 172
114                 return 1
115             elseif a:x < 230
116                 return 2
117             else
118                 return 3
119             endif
120         else
121             if a:x < 75
122                 return 0
123             else
124                 let l:n = (a:x - 55) / 40
125                 let l:m = (a:x - 55) % 40
126                 if l:m < 20
127                     return l:n
128                 else
129                     return l:n + 1
130                 endif
131             endif
132         endif
133     endfun
134
135     " returns the actual color level for the given color index
136     fun! <SID>rgb_level(n)
137         if &t_Co == 88
138             if a:n == 0
139                 return 0
140             elseif a:n == 1
141                 return 139
142             elseif a:n == 2
143                 return 205
144             else
145                 return 255
146             endif
147         else
148             if a:n == 0
149                 return 0
150             else
151                 return 55 + (a:n * 40)
152             endif
153         endif
154     endfun
155
156     " returns the palette index for the given R/G/B color indices
157     fun! <SID>rgb_color(x, y, z)
158         if &t_Co == 88
159             return 16 + (a:x * 16) + (a:y * 4) + a:z
160         else
161             return 16 + (a:x * 36) + (a:y * 6) + a:z
162         endif
163     endfun
164
165     " returns the palette index to approximate the given R/G/B color levels
166     fun! <SID>color(r, g, b)
167         " get the closest grey
168         let l:gx = <SID>grey_number(a:r)
169         let l:gy = <SID>grey_number(a:g)
170         let l:gz = <SID>grey_number(a:b)
171
172         " get the closest color
173         let l:x = <SID>rgb_number(a:r)
174         let l:y = <SID>rgb_number(a:g)
175         let l:z = <SID>rgb_number(a:b)
176
177         if l:gx == l:gy && l:gy == l:gz
178             " there are two possibilities
179             let l:dgr = <SID>grey_level(l:gx) - a:r
180             let l:dgg = <SID>grey_level(l:gy) - a:g
181             let l:dgb = <SID>grey_level(l:gz) - a:b
182             let l:dgrey = (l:dgr * l:dgr) + (l:dgg * l:dgg) + (l:dgb * l:dgb)
183             let l:dr = <SID>rgb_level(l:gx) - a:r
184             let l:dg = <SID>rgb_level(l:gy) - a:g
185             let l:db = <SID>rgb_level(l:gz) - a:b
186             let l:drgb = (l:dr * l:dr) + (l:dg * l:dg) + (l:db * l:db)
187             if l:dgrey < l:drgb
188                 " use the grey
189                 return <SID>grey_color(l:gx)
190             else
191                 " use the color
192                 return <SID>rgb_color(l:x, l:y, l:z)
193             endif
194         else
195             " only one possibility
196             return <SID>rgb_color(l:x, l:y, l:z)
197         endif
198     endfun
199
200     " returns the palette index to approximate the 'rrggbb' hex string
201     fun! <SID>rgb(rgb)
202         let l:r = ("0x" . strpart(a:rgb, 0, 2)) + 0
203         let l:g = ("0x" . strpart(a:rgb, 2, 2)) + 0
204         let l:b = ("0x" . strpart(a:rgb, 4, 2)) + 0
205
206         return <SID>color(l:r, l:g, l:b)
207     endfun
208
209     " sets the highlighting for the given group
210     fun! <SID>X(group, fg, bg, attr)
211         if a:fg != ""
212             if a:fg =~ '^#'
213                 let l:fg = <SID>rgb(substitute(a:fg, '^#', '', ''))
214             else
215                 let l:fg=a:fg
216             endif
217             exec "hi " . a:group . " guifg=" . a:fg . " ctermfg=" . l:fg
218         endif
219         if a:bg != ""
220             if a:bg =~ '^#'
221                 let l:bg = <SID>rgb(substitute(a:bg, '^#', '', ''))
222             else
223                 let l:bg=a:bg
224             endif
225             exec "hi " . a:group . " guibg=" . a:bg . " ctermbg=" . l:bg
226         endif
227         if a:attr != ""
228             exec "hi " . a:group . " gui=" . a:attr . " cterm=" . a:attr
229         endif
230     endfun
231     " }}}
232     " From darkblue.
233     call <SID>X("ErrorMsg", "#ffffff", "#287eff", "")
234     call <SID>X("Visual", "#ffffff", "#8080ff", "")
235     call <SID>X("VisualNOS", "", "#8080ff", "underline")
236     "call <SID>X("Todo", "#d14a14", "#1248d1", "")
237     call <SID>X("Search", "#ffffff", "#2050d0", "")
238     call <SID>X("IncSearch", "#b0ffff", "#2050d0", "")
239     "call <SID>X("SpecialKey", "#00ffff", "", "")
240     call <SID>X("Directory", "#008bff", "", "")
241     call <SID>X("Title", "#ff00ff", "", "none")
242     call <SID>X("WarningMsg", "#ff0000", "", "")
243     "call <SID>X("WildMenu", "#ffff00", "#000000", "")
244     call <SID>X("ModeMsg", "#22cce2", "", "")
245     call <SID>X("Question", "#00ff00", "", "none")
246     "call <SID>X("NonText", "#0030ff", "", "")
247     call <SID>X("VertSplit", "#000000", "#808080", "none")
248     call <SID>X("Folded", "#808080", "#303030", "")
249     call <SID>X("FoldColumn", "#808080", "#303030", "")
250     call <SID>X("LineNr", "#90f020", "#303030", "")
251     call <SID>X("DiffAdd", "", "#008bff", "")
252     call <SID>X("DiffChange", "", "#8b008b", "")
253     call <SID>X("DiffDelete", "#008b8b", "#303030", "")
254     call <SID>X("DiffText", "#ffffff", "#ff0000", "none")
255     call <SID>X("Cursor", "#000000", "#00ff00", "")
256     call <SID>X("CursorLine", "", "#2e2e2e", "none")
257     call <SID>X("lCursor", "#000000", "#ffffff", "")
258     "call <SID>X("Comment", "#80a0ff", "", "")
259     "call <SID>X("Constant", "#ffa0a0", "", "")
260     "call <SID>X("Special", "#ffa500", "", "")
261     "call <SID>X("Identifier", "#40ffff", "", "")
262     "call <SID>X("Statement", "#ffff60", "", "none")
263     "call <SID>X("PreProc", "#ff80ff", "", "none")
264     "call <SID>X("Type", "#60ff60", "", "none")
265     call <SID>X("Ignore", "#ffffff", "", "")
266
267     " My stuff.
268     hi def Normal guifg=#c0c0c0 guibg=#000020
269
270     call <SID>X("StatusLineNC", "black", "#808080", "none")
271     call <SID>X("StatusLine", "white", "#000080", "none")
272     call <SID>X("User1", "white", "#000080", "bold")
273     call <SID>X("WildMenu", "blue", "white", "bold")
274     call <SID>X("Todo", "black", "green", "bold")
275     call <SID>X("MoreMsg", "#00ff00", "", "none")
276
277     call <SID>X("Repeat", "yellow", "", "none")
278     call <SID>X("Label", "#90f020", "", "none")
279     call <SID>X("Conditional", "#ffff60", "", "none")
280     call <SID>X("Operator", "#e0e000", "", "none")
281     call <SID>X("Statement", "#ffff00", "", "none")
282
283     hi! link TabLineSel StatusLine
284     hi! link TabLine StatusLineNC
285
286     hi MatchParen ctermbg=blue
287
288     call <SID>X("Pmenu", "#ffffff", "#287eff", "")
289
290     hi Comment ctermfg=lightblue cterm=none guifg=#80a0ff gui=none
291
292     call <SID>X("Function", "darkgreen", "", "none")
293     call <SID>X("Identifier", "#40ffff", "", "none")
294
295     hi Character ctermfg=darkmagenta cterm=bold guifg=magenta gui=bold
296     hi String ctermfg=darkmagenta cterm=none guifg=magenta gui=none
297     call <SID>X("Float", "magenta", "", "none")
298     call <SID>X("Number", "magenta", "", "bold")
299     call <SID>X("Boolean", "darkred", "", "bold")
300     call <SID>X("Constant", "darkmagenta", "", "bold")
301     hi NonText ctermfg=blue cterm=none guifg=blue gui=none
302
303     call <SID>X("SpecialChar", "#ff0000", "", "none")
304     hi SpecialKey ctermfg=blue cterm=none guifg=blue gui=none
305     call <SID>X("Special", "#ff0000", "", "none")
306
307     call <SID>X("Include", "red", "", "none")
308     call <SID>X("Macro", "red", "", "none")
309     call <SID>X("PreCondit", "darkred", "", "none")
310     call <SID>X("PreProc", "darkred", "", "bold")
311
312     hi StorageClass ctermfg=green cterm=none guifg=lightgreen gui=none
313     hi Structure ctermfg=darkgreen cterm=bold guifg=green gui=bold
314     hi Type ctermfg=darkgreen cterm=none guifg=green gui=none
315
316     " Fix up shell stuff. XXX: Should this go in ~/.vim/after/syntax/sh.vim?
317     hi link shShellVariables Identifier
318
319     " Fix up Perl stuff.
320
321     " Signs to highlight marks.
322     call <SID>X("MarkLine", "", "#303030", "")
323     call <SID>X("MarkDot", "red", "#303030", "")
324     call <SID>X("MarkSign", "lightblue", "#303030", "")
325     hi! link SignColumn LineNr
326
327     " Fix up NERDTree stuff.
328     hi link treeExecFile Type
329     hi treeLink cterm=none ctermfg=cyan gui=none guifg=cyan
330     hi link treeOpenable treeDirSlash
331     hi link treeClosable treeDirSlash
332     hi link treePart treeDirSlash
333     hi link treePartFile treeDirSlash
334
335     " Fix up BufExplorer stuff.
336     hi link bufExplorerHelp String
337     hi link bufExplorerSortBy Statement
338     hi link bufExplorerMapping Identifier
339     hi link bufExplorerTitle Statement
340     hi link bufExplorerActBuf Directory
341     hi link bufExplorerAltBuf String
342     hi link bufExplorerCurBuf Type
343     hi link bufExplorerUnlBuf Comment
344     hi link bufExplorerBufNbr Normal
345 endif
346
347 " vim: set fdl=0 fdm=marker: