1 " Mangling for terminal code ripped from desert256.
4 " no guarantees for version 5.8 and below, but this makes it stop
11 let g:colors_name="iain"
13 if has("gui_running") || &t_Co == 88 || &t_Co == 256
15 " returns an approximate grey index for the given grey level
16 fun! <SID>grey_number(x)
43 let l:n = (a:x - 8) / 10
44 let l:m = (a:x - 8) % 10
54 " returns the actual grey level represented by the grey index
55 fun! <SID>grey_level(n)
87 " returns the palette index for the given grey index
88 fun! <SID>grey_color(n)
108 " returns an approximate color index for the given color level
109 fun! <SID>rgb_number(x)
124 let l:n = (a:x - 55) / 40
125 let l:m = (a:x - 55) % 40
135 " returns the actual color level for the given color index
136 fun! <SID>rgb_level(n)
151 return 55 + (a:n * 40)
156 " returns the palette index for the given R/G/B color indices
157 fun! <SID>rgb_color(x, y, z)
159 return 16 + (a:x * 16) + (a:y * 4) + a:z
161 return 16 + (a:x * 36) + (a:y * 6) + a:z
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)
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)
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)
189 return <SID>grey_color(l:gx)
192 return <SID>rgb_color(l:x, l:y, l:z)
195 " only one possibility
196 return <SID>rgb_color(l:x, l:y, l:z)
200 " returns the palette index to approximate the 'rrggbb' hex string
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
206 return <SID>color(l:r, l:g, l:b)
209 " sets the highlighting for the given group
210 fun! <SID>X(group, fg, bg, attr)
211 " Our dark grey ends up being too light when Vim is run inside screen
212 " on an 88-colour urxvt.
213 let l:hackgrey = "#303030"
214 let l:hackterm = "^screen-256color"
219 let l:fg = <SID>rgb(substitute(a:fg, '^#', '', ''))
220 if a:fg == l:hackgrey && &term =~ l:hackterm && l:fg == l:hackbad
221 let l:fg = l:hackgood
226 exec "hi " . a:group . " guifg=" . a:fg . " ctermfg=" . l:fg
230 let l:bg = <SID>rgb(substitute(a:bg, '^#', '', ''))
231 if a:bg == l:hackgrey && &term =~ l:hackterm && l:bg == l:hackbad
232 let l:bg = l:hackgood
237 exec "hi " . a:group . " guibg=" . a:bg . " ctermbg=" . l:bg
240 exec "hi " . a:group . " gui=" . a:attr . " cterm=" . a:attr
245 call <SID>X("ErrorMsg", "#ffffff", "#287eff", "")
246 call <SID>X("Visual", "#ffffff", "#8080ff", "")
247 call <SID>X("VisualNOS", "", "#8080ff", "underline")
248 "call <SID>X("Todo", "#d14a14", "#1248d1", "")
249 call <SID>X("Search", "#ffffff", "#2050d0", "")
250 call <SID>X("IncSearch", "#b0ffff", "#2050d0", "")
251 "call <SID>X("SpecialKey", "#00ffff", "", "")
252 call <SID>X("Directory", "#008bff", "", "")
253 call <SID>X("Title", "#ff00ff", "", "none")
254 call <SID>X("WarningMsg", "#ff0000", "", "")
255 "call <SID>X("WildMenu", "#ffff00", "#000000", "")
256 call <SID>X("ModeMsg", "#22cce2", "", "")
257 call <SID>X("Question", "#00ff00", "", "none")
258 "call <SID>X("NonText", "#0030ff", "", "")
259 call <SID>X("VertSplit", "#000000", "#808080", "none")
260 call <SID>X("Folded", "#808080", "#303030", "")
261 call <SID>X("FoldColumn", "#808080", "#303030", "")
262 call <SID>X("LineNr", "#90f020", "#303030", "")
263 call <SID>X("CursorLineNr", "#303030", "#90f020", "none")
264 call <SID>X("DiffAdd", "", "#008bff", "")
265 call <SID>X("DiffChange", "", "#8b008b", "")
266 call <SID>X("DiffDelete", "#008b8b", "#303030", "")
267 call <SID>X("DiffText", "#ffffff", "#ff0000", "none")
268 call <SID>X("Cursor", "#000000", "#00ff00", "")
269 call <SID>X("CursorLine", "", "#2e2e2e", "none")
270 call <SID>X("ColorColumn", "", "#2e2e2e", "none")
271 call <SID>X("lCursor", "#000000", "#ffffff", "")
272 "call <SID>X("Comment", "#80a0ff", "", "")
273 "call <SID>X("Constant", "#ffa0a0", "", "")
274 "call <SID>X("Special", "#ffa500", "", "")
275 "call <SID>X("Identifier", "#40ffff", "", "")
276 "call <SID>X("Statement", "#ffff60", "", "none")
277 "call <SID>X("PreProc", "#ff80ff", "", "none")
278 "call <SID>X("Type", "#60ff60", "", "none")
279 call <SID>X("Ignore", "#ffffff", "", "")
282 hi def Normal guifg=#c0c0c0 guibg=#000020
284 call <SID>X("StatusLineNC", "black", "#808080", "none")
285 call <SID>X("StatusLine", "white", "#000080", "none")
286 call <SID>X("User1", "white", "#000080", "bold")
287 call <SID>X("WildMenu", "blue", "white", "bold")
288 call <SID>X("Todo", "black", "green", "bold")
289 call <SID>X("MoreMsg", "#00ff00", "", "none")
291 call <SID>X("Repeat", "yellow", "", "none")
292 call <SID>X("Label", "#90f020", "", "none")
293 call <SID>X("Conditional", "#ffff60", "", "none")
294 call <SID>X("Operator", "#e0e000", "", "none")
295 call <SID>X("Statement", "#ffff00", "", "none")
297 hi! link TabLineSel StatusLine
298 hi! link TabLine StatusLineNC
302 hi MatchParen ctermbg=blue
304 call <SID>X("Pmenu", "#ffffff", "#287eff", "")
306 hi Comment ctermfg=lightblue cterm=none guifg=#80a0ff gui=none
308 call <SID>X("Function", "darkgreen", "", "none")
309 call <SID>X("Identifier", "#40ffff", "", "none")
311 hi Character ctermfg=darkmagenta cterm=bold guifg=magenta gui=bold
312 hi String ctermfg=darkmagenta cterm=none guifg=magenta gui=none
313 call <SID>X("Float", "magenta", "", "none")
314 call <SID>X("Number", "magenta", "", "bold")
315 call <SID>X("Boolean", "darkred", "", "bold")
316 call <SID>X("Constant", "darkmagenta", "", "bold")
317 hi NonText ctermfg=blue cterm=none guifg=blue gui=none
319 call <SID>X("SpecialChar", "#ff0000", "", "none")
320 hi SpecialKey ctermfg=blue cterm=none guifg=blue gui=none
321 call <SID>X("Special", "#ff0000", "", "none")
323 call <SID>X("Include", "red", "", "none")
324 call <SID>X("Macro", "red", "", "none")
325 call <SID>X("PreCondit", "darkred", "", "none")
326 call <SID>X("PreProc", "darkred", "", "bold")
328 hi StorageClass ctermfg=green cterm=none guifg=lightgreen gui=none
329 hi Structure ctermfg=darkgreen cterm=bold guifg=green gui=bold
330 hi Type ctermfg=darkgreen cterm=none guifg=green gui=none
332 " Fix up shell stuff. XXX: Should this go in ~/.vim/after/syntax/sh.vim?
333 hi link shShellVariables Identifier
337 " Signs to highlight marks.
338 call <SID>X("MarkLine", "", "#303030", "")
339 call <SID>X("MarkDot", "red", "#303030", "")
340 call <SID>X("MarkSign", "lightblue", "#303030", "")
341 call <SID>X("MarkArrow", "#00ff00", "#303030", "")
342 hi! link SignColumn LineNr
344 " Fix up NERDTree stuff.
345 hi link treeExecFile Type
346 hi treeLink cterm=none ctermfg=cyan gui=none guifg=cyan
347 hi link treeOpenable treeDirSlash
348 hi link treeClosable treeDirSlash
349 hi link treePart treeDirSlash
350 hi link treePartFile treeDirSlash
352 " Fix up BufExplorer stuff.
353 hi link bufExplorerHelp Include
354 hi link bufExplorerSortBy Include
355 hi link bufExplorerMapping Identifier
356 hi link bufExplorerTitle Statement
357 hi link bufExplorerActBuf Directory
358 hi link bufExplorerAltBuf Type
359 hi link bufExplorerCurBuf Statement
360 hi link bufExplorerHidBuf Comment
361 hi link bufExplorerUnlBuf String
362 hi link bufExplorerBufNbr Normal
365 " vim: set fdl=0 fdm=marker: