diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..1c2d6dc
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,39 @@
+[submodule ".vim/bundle/ack.vim"]
+ path = .vim/bundle/ack.vim
+ url = https://github.com/mileszs/ack.vim.git
+[submodule ".vim/bundle/syntastic"]
+ path = .vim/bundle/syntastic
+ url = https://github.com/scrooloose/syntastic.git
+[submodule ".vim/bundle/taglist.vim"]
+ path = .vim/bundle/taglist.vim
+ url = https://github.com/vim-scripts/taglist.vim.git
+[submodule ".vim/bundle/coffee-script"]
+ path = .vim/bundle/coffee-script
+ url = https://github.com/kchmck/vim-coffee-script.git
+[submodule ".vim/bundle/commentary"]
+ path = .vim/bundle/commentary
+ url = https://github.com/tpope/vim-commentary.git
+[submodule ".vim/bundle/endwise"]
+ path = .vim/bundle/endwise
+ url = https://github.com/tpope/vim-endwise.git
+[submodule ".vim/bundle/haml"]
+ path = .vim/bundle/haml
+ url = https://github.com/chriseppstein/vim-haml.git
+[submodule ".vim/bundle/jade"]
+ path = .vim/bundle/jade
+ url = https://github.com/digitaltoad/vim-jade.git
+[submodule ".vim/bundle/javascript"]
+ path = .vim/bundle/javascript
+ url = https://github.com/pangloss/vim-javascript.git
+[submodule ".vim/bundle/rails"]
+ path = .vim/bundle/rails
+ url = https://github.com/tpope/vim-rails.git
+[submodule ".vim/bundle/ruby"]
+ path = .vim/bundle/ruby
+ url = https://github.com/vim-ruby/vim-ruby.git
+[submodule ".vim/bundle/supertab"]
+ path = .vim/bundle/supertab
+ url = https://github.com/tsaleh/vim-supertab.git
+[submodule ".vim/bundle/surround"]
+ path = .vim/bundle/surround
+ url = https://github.com/tpope/vim-surround.git
diff --git a/.vim/autoload/pathogen.vim b/.vim/autoload/pathogen.vim
new file mode 100644
index 0000000..3accbe6
--- /dev/null
+++ b/.vim/autoload/pathogen.vim
@@ -0,0 +1,245 @@
+" pathogen.vim - path option manipulation
+" Maintainer: Tim Pope
+" Version: 2.0
+
+" Install in ~/.vim/autoload (or ~\vimfiles\autoload).
+"
+" For management of individually installed plugins in ~/.vim/bundle (or
+" ~\vimfiles\bundle), adding `call pathogen#infect()` to your .vimrc
+" prior to `filetype plugin indent on` is the only other setup necessary.
+"
+" The API is documented inline below. For maximum ease of reading,
+" :set foldmethod=marker
+
+if exists("g:loaded_pathogen") || &cp
+ finish
+endif
+let g:loaded_pathogen = 1
+
+" Point of entry for basic default usage. Give a directory name to invoke
+" pathogen#runtime_append_all_bundles() (defaults to "bundle"), or a full path
+" to invoke pathogen#runtime_prepend_subdirectories(). Afterwards,
+" pathogen#cycle_filetype() is invoked.
+function! pathogen#infect(...) abort " {{{1
+ let source_path = a:0 ? a:1 : 'bundle'
+ if source_path =~# '[\\/]'
+ call pathogen#runtime_prepend_subdirectories(source_path)
+ else
+ call pathogen#runtime_append_all_bundles(source_path)
+ endif
+ call pathogen#cycle_filetype()
+endfunction " }}}1
+
+" Split a path into a list.
+function! pathogen#split(path) abort " {{{1
+ if type(a:path) == type([]) | return a:path | endif
+ let split = split(a:path,'\\\@"),'!isdirectory(v:val)')) && (!filereadable(dir.sep.'doc'.sep.'tags') || filewritable(dir.sep.'doc'.sep.'tags'))
+ helptags `=dir.'/doc'`
+ endif
+ endfor
+endfunction " }}}1
+
+command! -bar Helptags :call pathogen#helptags()
+
+" Like findfile(), but hardcoded to use the runtimepath.
+function! pathogen#runtime_findfile(file,count) "{{{1
+ let rtp = pathogen#join(1,pathogen#split(&rtp))
+ return fnamemodify(findfile(a:file,rtp,a:count),':p')
+endfunction " }}}1
+
+" Backport of fnameescape().
+function! pathogen#fnameescape(string) " {{{1
+ if exists('*fnameescape')
+ return fnameescape(a:string)
+ elseif a:string ==# '-'
+ return '\-'
+ else
+ return substitute(escape(a:string," \t\n*?[{`$\\%#'\"|!<"),'^[+>]','\\&','')
+ endif
+endfunction " }}}1
+
+function! s:find(count,cmd,file,lcd) " {{{1
+ let rtp = pathogen#join(1,pathogen#split(&runtimepath))
+ let file = pathogen#runtime_findfile(a:file,a:count)
+ if file ==# ''
+ return "echoerr 'E345: Can''t find file \"".a:file."\" in runtimepath'"
+ elseif a:lcd
+ let path = file[0:-strlen(a:file)-2]
+ execute 'lcd `=path`'
+ return a:cmd.' '.pathogen#fnameescape(a:file)
+ else
+ return a:cmd.' '.pathogen#fnameescape(file)
+ endif
+endfunction " }}}1
+
+function! s:Findcomplete(A,L,P) " {{{1
+ let sep = pathogen#separator()
+ let cheats = {
+ \'a': 'autoload',
+ \'d': 'doc',
+ \'f': 'ftplugin',
+ \'i': 'indent',
+ \'p': 'plugin',
+ \'s': 'syntax'}
+ if a:A =~# '^\w[\\/]' && has_key(cheats,a:A[0])
+ let request = cheats[a:A[0]].a:A[1:-1]
+ else
+ let request = a:A
+ endif
+ let pattern = substitute(request,'\'.sep,'*'.sep,'g').'*'
+ let found = {}
+ for path in pathogen#split(&runtimepath)
+ let path = expand(path, ':p')
+ let matches = split(glob(path.sep.pattern),"\n")
+ call map(matches,'isdirectory(v:val) ? v:val.sep : v:val')
+ call map(matches,'expand(v:val, ":p")[strlen(path)+1:-1]')
+ for match in matches
+ let found[match] = 1
+ endfor
+ endfor
+ return sort(keys(found))
+endfunction " }}}1
+
+command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Ve :execute s:find(,'edit',,0)
+command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vedit :execute s:find(,'edit',,0)
+command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vopen :execute s:find(,'edit',,1)
+command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vsplit :execute s:find(,'split',,1)
+command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vvsplit :execute s:find(,'vsplit',,1)
+command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vtabedit :execute s:find(,'tabedit',,1)
+command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vpedit :execute s:find(,'pedit',,1)
+command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vread :execute s:find(,'read',,1)
+
+" vim:set ft=vim ts=8 sw=2 sts=2:
diff --git a/.vim/bundle/ack.vim b/.vim/bundle/ack.vim
new file mode 160000
index 0000000..9895285
--- /dev/null
+++ b/.vim/bundle/ack.vim
@@ -0,0 +1 @@
+Subproject commit 9895285042a2fd5691b2f6582aa979e4d1bdffea
diff --git a/.vim/bundle/coffee-script b/.vim/bundle/coffee-script
new file mode 160000
index 0000000..abac188
--- /dev/null
+++ b/.vim/bundle/coffee-script
@@ -0,0 +1 @@
+Subproject commit abac188893e615b5cbb7137ada691abd597be975
diff --git a/.vim/bundle/commentary b/.vim/bundle/commentary
new file mode 160000
index 0000000..50b0556
--- /dev/null
+++ b/.vim/bundle/commentary
@@ -0,0 +1 @@
+Subproject commit 50b055633580c65c381ebb310bc1786ff14e3340
diff --git a/.vim/bundle/endwise b/.vim/bundle/endwise
new file mode 160000
index 0000000..74306aa
--- /dev/null
+++ b/.vim/bundle/endwise
@@ -0,0 +1 @@
+Subproject commit 74306aa18c03ee2fdb044609e6f0bc866872711d
diff --git a/.vim/bundle/haml b/.vim/bundle/haml
new file mode 160000
index 0000000..0159bee
--- /dev/null
+++ b/.vim/bundle/haml
@@ -0,0 +1 @@
+Subproject commit 0159bee646cd8b1856acf2e4ae3f76c018dda25d
diff --git a/.vim/bundle/jade b/.vim/bundle/jade
new file mode 160000
index 0000000..d63c1ea
--- /dev/null
+++ b/.vim/bundle/jade
@@ -0,0 +1 @@
+Subproject commit d63c1eac60e367ba4914c3ea1f88612685499e99
diff --git a/.vim/bundle/javascript b/.vim/bundle/javascript
new file mode 160000
index 0000000..a8ce721
--- /dev/null
+++ b/.vim/bundle/javascript
@@ -0,0 +1 @@
+Subproject commit a8ce721701fdd015695406f7df315f48bb447ebb
diff --git a/.vim/bundle/rails b/.vim/bundle/rails
new file mode 160000
index 0000000..13b8bb5
--- /dev/null
+++ b/.vim/bundle/rails
@@ -0,0 +1 @@
+Subproject commit 13b8bb5afa7bc6c65c3d2401314bb1960f161f37
diff --git a/.vim/bundle/ruby b/.vim/bundle/ruby
new file mode 160000
index 0000000..90f3523
--- /dev/null
+++ b/.vim/bundle/ruby
@@ -0,0 +1 @@
+Subproject commit 90f352333e15342940394c780d70087f5bd65390
diff --git a/.vim/bundle/supertab b/.vim/bundle/supertab
new file mode 160000
index 0000000..096be34
--- /dev/null
+++ b/.vim/bundle/supertab
@@ -0,0 +1 @@
+Subproject commit 096be343f89c63fc086a55262f2f264d0d0524b0
diff --git a/.vim/bundle/surround b/.vim/bundle/surround
new file mode 160000
index 0000000..489a1e8
--- /dev/null
+++ b/.vim/bundle/surround
@@ -0,0 +1 @@
+Subproject commit 489a1e8c676ad47dd358dbf883bfaf492148d38b
diff --git a/.vim/bundle/syntastic b/.vim/bundle/syntastic
new file mode 160000
index 0000000..4b61f4b
--- /dev/null
+++ b/.vim/bundle/syntastic
@@ -0,0 +1 @@
+Subproject commit 4b61f4b2b9de642c054db9bcdbfa99480b2909aa
diff --git a/.vim/bundle/taglist.vim b/.vim/bundle/taglist.vim
new file mode 160000
index 0000000..53041fb
--- /dev/null
+++ b/.vim/bundle/taglist.vim
@@ -0,0 +1 @@
+Subproject commit 53041fbc45398a9af631a20657e109707a455339
diff --git a/.vim/colors/Tomorrow-Night.vim b/.vim/colors/Tomorrow-Night.vim
new file mode 100644
index 0000000..d019ace
--- /dev/null
+++ b/.vim/colors/Tomorrow-Night.vim
@@ -0,0 +1,356 @@
+" Tomorrow Night - Full Colour and 256 Colour
+" http://chriskempson.com
+"
+" Hex colour conversion functions borrowed from the theme "Desert256""
+
+" Default GUI Colours
+let s:foreground = "c5c8c6"
+let s:background = "1d1f21"
+let s:selection = "373b41"
+let s:line = "282a2e"
+let s:comment = "969896"
+let s:red = "cc6666"
+let s:orange = "de935f"
+let s:yellow = "f0c674"
+let s:green = "b5bd68"
+let s:aqua = "8abeb7"
+let s:blue = "81a2be"
+let s:purple = "b294bb"
+let s:window = "4d5057"
+
+" Console 256 Colours
+if !has("gui_running")
+ let s:background = "303030"
+ let s:window = "5e5e5e"
+ let s:line = "3a3a3a"
+ let s:selection = "585858"
+end
+
+set background=dark
+hi clear
+syntax reset
+
+let g:colors_name = "Tomorrow-Night"
+
+if has("gui_running") || &t_Co == 88 || &t_Co == 256
+ " Returns an approximate grey index for the given grey level
+ fun grey_number(x)
+ if &t_Co == 88
+ if a:x < 23
+ return 0
+ elseif a:x < 69
+ return 1
+ elseif a:x < 103
+ return 2
+ elseif a:x < 127
+ return 3
+ elseif a:x < 150
+ return 4
+ elseif a:x < 173
+ return 5
+ elseif a:x < 196
+ return 6
+ elseif a:x < 219
+ return 7
+ elseif a:x < 243
+ return 8
+ else
+ return 9
+ endif
+ else
+ if a:x < 14
+ return 0
+ else
+ let l:n = (a:x - 8) / 10
+ let l:m = (a:x - 8) % 10
+ if l:m < 5
+ return l:n
+ else
+ return l:n + 1
+ endif
+ endif
+ endif
+ endfun
+
+ " Returns the actual grey level represented by the grey index
+ fun grey_level(n)
+ if &t_Co == 88
+ if a:n == 0
+ return 0
+ elseif a:n == 1
+ return 46
+ elseif a:n == 2
+ return 92
+ elseif a:n == 3
+ return 115
+ elseif a:n == 4
+ return 139
+ elseif a:n == 5
+ return 162
+ elseif a:n == 6
+ return 185
+ elseif a:n == 7
+ return 208
+ elseif a:n == 8
+ return 231
+ else
+ return 255
+ endif
+ else
+ if a:n == 0
+ return 0
+ else
+ return 8 + (a:n * 10)
+ endif
+ endif
+ endfun
+
+ " Returns the palette index for the given grey index
+ fun grey_colour(n)
+ if &t_Co == 88
+ if a:n == 0
+ return 16
+ elseif a:n == 9
+ return 79
+ else
+ return 79 + a:n
+ endif
+ else
+ if a:n == 0
+ return 16
+ elseif a:n == 25
+ return 231
+ else
+ return 231 + a:n
+ endif
+ endif
+ endfun
+
+ " Returns an approximate colour index for the given colour level
+ fun rgb_number(x)
+ if &t_Co == 88
+ if a:x < 69
+ return 0
+ elseif a:x < 172
+ return 1
+ elseif a:x < 230
+ return 2
+ else
+ return 3
+ endif
+ else
+ if a:x < 75
+ return 0
+ else
+ let l:n = (a:x - 55) / 40
+ let l:m = (a:x - 55) % 40
+ if l:m < 20
+ return l:n
+ else
+ return l:n + 1
+ endif
+ endif
+ endif
+ endfun
+
+ " Returns the actual colour level for the given colour index
+ fun rgb_level(n)
+ if &t_Co == 88
+ if a:n == 0
+ return 0
+ elseif a:n == 1
+ return 139
+ elseif a:n == 2
+ return 205
+ else
+ return 255
+ endif
+ else
+ if a:n == 0
+ return 0
+ else
+ return 55 + (a:n * 40)
+ endif
+ endif
+ endfun
+
+ " Returns the palette index for the given R/G/B colour indices
+ fun rgb_colour(x, y, z)
+ if &t_Co == 88
+ return 16 + (a:x * 16) + (a:y * 4) + a:z
+ else
+ return 16 + (a:x * 36) + (a:y * 6) + a:z
+ endif
+ endfun
+
+ " Returns the palette index to approximate the given R/G/B colour levels
+ fun colour(r, g, b)
+ " Get the closest grey
+ let l:gx = grey_number(a:r)
+ let l:gy = grey_number(a:g)
+ let l:gz = grey_number(a:b)
+
+ " Get the closest colour
+ let l:x = rgb_number(a:r)
+ let l:y = rgb_number(a:g)
+ let l:z = rgb_number(a:b)
+
+ if l:gx == l:gy && l:gy == l:gz
+ " There are two possibilities
+ let l:dgr = grey_level(l:gx) - a:r
+ let l:dgg = grey_level(l:gy) - a:g
+ let l:dgb = grey_level(l:gz) - a:b
+ let l:dgrey = (l:dgr * l:dgr) + (l:dgg * l:dgg) + (l:dgb * l:dgb)
+ let l:dr = rgb_level(l:gx) - a:r
+ let l:dg = rgb_level(l:gy) - a:g
+ let l:db = rgb_level(l:gz) - a:b
+ let l:drgb = (l:dr * l:dr) + (l:dg * l:dg) + (l:db * l:db)
+ if l:dgrey < l:drgb
+ " Use the grey
+ return grey_colour(l:gx)
+ else
+ " Use the colour
+ return rgb_colour(l:x, l:y, l:z)
+ endif
+ else
+ " Only one possibility
+ return rgb_colour(l:x, l:y, l:z)
+ endif
+ endfun
+
+ " Returns the palette index to approximate the 'rrggbb' hex string
+ fun rgb(rgb)
+ let l:r = ("0x" . strpart(a:rgb, 0, 2)) + 0
+ let l:g = ("0x" . strpart(a:rgb, 2, 2)) + 0
+ let l:b = ("0x" . strpart(a:rgb, 4, 2)) + 0
+
+ return colour(l:r, l:g, l:b)
+ endfun
+
+ " Sets the highlighting for the given group
+ fun X(group, fg, bg, attr)
+ if a:fg != ""
+ exec "hi " . a:group . " guifg=#" . a:fg . " ctermfg=" . rgb(a:fg)
+ endif
+ if a:bg != ""
+ exec "hi " . a:group . " guibg=#" . a:bg . " ctermbg=" . rgb(a:bg)
+ endif
+ if a:attr != ""
+ exec "hi " . a:group . " gui=" . a:attr . " cterm=" . a:attr
+ endif
+ endfun
+
+ " Vim Highlighting
+ call X("Normal", s:foreground, s:background, "")
+ call X("LineNr", s:selection, "", "")
+ call X("NonText", s:selection, "", "")
+ call X("SpecialKey", s:selection, "", "")
+ call X("Search", s:background, s:yellow, "")
+ call X("TabLine", s:foreground, s:background, "reverse")
+ call X("StatusLine", s:window, s:yellow, "reverse")
+ call X("StatusLineNC", s:window, s:foreground, "reverse")
+ call X("VertSplit", s:window, s:window, "none")
+ call X("Visual", "", s:selection, "")
+ call X("Directory", s:blue, "", "")
+ call X("ModeMsg", s:green, "", "")
+ call X("MoreMsg", s:green, "", "")
+ call X("Question", s:green, "", "")
+ call X("WarningMsg", s:red, "", "")
+ call X("MatchParen", "", s:selection, "")
+ call X("Folded", s:comment, s:background, "")
+ call X("FoldColumn", "", s:background, "")
+ if version >= 700
+ call X("CursorLine", "", s:line, "none")
+ call X("CursorColumn", "", s:line, "none")
+ call X("PMenu", s:foreground, s:selection, "none")
+ call X("PMenuSel", s:foreground, s:selection, "reverse")
+ call X("SignColumn", "", s:background, "none")
+ end
+ if version >= 703
+ call X("ColorColumn", "", s:line, "none")
+ end
+
+ " Standard Highlighting
+ call X("Comment", s:comment, "", "")
+ call X("Todo", s:comment, s:background, "")
+ call X("Title", s:comment, "", "")
+ call X("Identifier", s:red, "", "none")
+ call X("Statement", s:foreground, "", "")
+ call X("Conditional", s:foreground, "", "")
+ call X("Repeat", s:foreground, "", "")
+ call X("Structure", s:purple, "", "")
+ call X("Function", s:blue, "", "")
+ call X("Constant", s:orange, "", "")
+ call X("String", s:green, "", "")
+ call X("Special", s:foreground, "", "")
+ call X("PreProc", s:purple, "", "")
+ call X("Operator", s:aqua, "", "none")
+ call X("Type", s:blue, "", "none")
+ call X("Define", s:purple, "", "none")
+ call X("Include", s:blue, "", "")
+ "call X("Ignore", "666666", "", "")
+
+ " Vim Highlighting
+ call X("vimCommand", s:red, "", "none")
+
+ " C Highlighting
+ call X("cType", s:yellow, "", "")
+ call X("cStorageClass", s:purple, "", "")
+ call X("cConditional", s:purple, "", "")
+ call X("cRepeat", s:purple, "", "")
+
+ " PHP Highlighting
+ call X("phpVarSelector", s:red, "", "")
+ call X("phpKeyword", s:purple, "", "")
+ call X("phpRepeat", s:purple, "", "")
+ call X("phpConditional", s:purple, "", "")
+ call X("phpStatement", s:purple, "", "")
+ call X("phpMemberSelector", s:foreground, "", "")
+
+ " Ruby Highlighting
+ call X("rubySymbol", s:green, "", "")
+ call X("rubyConstant", s:yellow, "", "")
+ call X("rubyAttribute", s:blue, "", "")
+ call X("rubyInclude", s:blue, "", "")
+ call X("rubyLocalVariableOrMethod", s:orange, "", "")
+ call X("rubyCurlyBlock", s:orange, "", "")
+ call X("rubyStringDelimiter", s:green, "", "")
+ call X("rubyInterpolationDelimiter", s:orange, "", "")
+ call X("rubyConditional", s:purple, "", "")
+ call X("rubyRepeat", s:purple, "", "")
+
+ " Python Highlighting
+ call X("pythonInclude", s:purple, "", "")
+ call X("pythonStatement", s:purple, "", "")
+ call X("pythonConditional", s:purple, "", "")
+ call X("pythonFunction", s:blue, "", "")
+
+ " JavaScript Highlighting
+ call X("javaScriptBraces", s:foreground, "", "")
+ call X("javaScriptFunction", s:purple, "", "")
+ call X("javaScriptConditional", s:purple, "", "")
+ call X("javaScriptRepeat", s:purple, "", "")
+ call X("javaScriptNumber", s:orange, "", "")
+ call X("javaScriptMember", s:orange, "", "")
+
+ " Diff Highlighting
+ call X("diffAdded", s:green, "", "")
+ call X("diffRemoved", s:red, "", "")
+
+ " ShowMarks Highlighting
+ call X("ShowMarksHLl", s:orange, s:background, "none")
+ call X("ShowMarksHLo", s:purple, s:background, "none")
+ call X("ShowMarksHLu", s:yellow, s:background, "none")
+ call X("ShowMarksHLm", s:aqua, s:background, "none")
+
+ " Delete Functions
+ delf X
+ delf rgb
+ delf colour
+ delf rgb_colour
+ delf rgb_level
+ delf rgb_number
+ delf grey_colour
+ delf grey_level
+ delf grey_number
+endif
diff --git a/.vim/colors/Tomorrow.vim b/.vim/colors/Tomorrow.vim
new file mode 100644
index 0000000..5aaffc4
--- /dev/null
+++ b/.vim/colors/Tomorrow.vim
@@ -0,0 +1,341 @@
+" Tomorrow - Full Colour and 256 Colour
+" http://chriskempson.com
+"
+" Hex colour conversion functions borrowed from the theme "Desert256""
+
+" Default GUI Colours
+let s:foreground = "4d4d4c"
+let s:background = "fafafafa"
+let s:selection = "d6d6d6"
+let s:line = "efefef"
+let s:comment = "8e908c"
+let s:red = "c82829"
+let s:orange = "f5871f"
+let s:yellow = "eab700"
+let s:green = "718c00"
+let s:aqua = "3e999f"
+let s:blue = "4271ae"
+let s:purple = "8959a8"
+let s:window = "efefef"
+
+set background=light
+hi clear
+syntax reset
+
+let g:colors_name = "Tomorrow"
+
+if has("gui_running") || &t_Co == 88 || &t_Co == 256
+ " Returns an approximate grey index for the given grey level
+ fun grey_number(x)
+ if &t_Co == 88
+ if a:x < 23
+ return 0
+ elseif a:x < 69
+ return 1
+ elseif a:x < 103
+ return 2
+ elseif a:x < 127
+ return 3
+ elseif a:x < 150
+ return 4
+ elseif a:x < 173
+ return 5
+ elseif a:x < 196
+ return 6
+ elseif a:x < 219
+ return 7
+ elseif a:x < 243
+ return 8
+ else
+ return 9
+ endif
+ else
+ if a:x < 14
+ return 0
+ else
+ let l:n = (a:x - 8) / 10
+ let l:m = (a:x - 8) % 10
+ if l:m < 5
+ return l:n
+ else
+ return l:n + 1
+ endif
+ endif
+ endif
+ endfun
+
+ " Returns the actual grey level represented by the grey index
+ fun grey_level(n)
+ if &t_Co == 88
+ if a:n == 0
+ return 0
+ elseif a:n == 1
+ return 46
+ elseif a:n == 2
+ return 92
+ elseif a:n == 3
+ return 115
+ elseif a:n == 4
+ return 139
+ elseif a:n == 5
+ return 162
+ elseif a:n == 6
+ return 185
+ elseif a:n == 7
+ return 208
+ elseif a:n == 8
+ return 231
+ else
+ return 255
+ endif
+ else
+ if a:n == 0
+ return 0
+ else
+ return 8 + (a:n * 10)
+ endif
+ endif
+ endfun
+
+ " Returns the palette index for the given grey index
+ fun grey_colour(n)
+ if &t_Co == 88
+ if a:n == 0
+ return 16
+ elseif a:n == 9
+ return 79
+ else
+ return 79 + a:n
+ endif
+ else
+ if a:n == 0
+ return 16
+ elseif a:n == 25
+ return 231
+ else
+ return 231 + a:n
+ endif
+ endif
+ endfun
+
+ " Returns an approximate colour index for the given colour level
+ fun rgb_number(x)
+ if &t_Co == 88
+ if a:x < 69
+ return 0
+ elseif a:x < 172
+ return 1
+ elseif a:x < 230
+ return 2
+ else
+ return 3
+ endif
+ else
+ if a:x < 75
+ return 0
+ else
+ let l:n = (a:x - 55) / 40
+ let l:m = (a:x - 55) % 40
+ if l:m < 20
+ return l:n
+ else
+ return l:n + 1
+ endif
+ endif
+ endif
+ endfun
+
+ " Returns the actual colour level for the given colour index
+ fun rgb_level(n)
+ if &t_Co == 88
+ if a:n == 0
+ return 0
+ elseif a:n == 1
+ return 139
+ elseif a:n == 2
+ return 205
+ else
+ return 255
+ endif
+ else
+ if a:n == 0
+ return 0
+ else
+ return 55 + (a:n * 40)
+ endif
+ endif
+ endfun
+
+ " Returns the palette index for the given R/G/B colour indices
+ fun rgb_colour(x, y, z)
+ if &t_Co == 88
+ return 16 + (a:x * 16) + (a:y * 4) + a:z
+ else
+ return 16 + (a:x * 36) + (a:y * 6) + a:z
+ endif
+ endfun
+
+ " Returns the palette index to approximate the given R/G/B colour levels
+ fun colour(r, g, b)
+ " Get the closest grey
+ let l:gx = grey_number(a:r)
+ let l:gy = grey_number(a:g)
+ let l:gz = grey_number(a:b)
+
+ " Get the closest colour
+ let l:x = rgb_number(a:r)
+ let l:y = rgb_number(a:g)
+ let l:z = rgb_number(a:b)
+
+ if l:gx == l:gy && l:gy == l:gz
+ " There are two possibilities
+ let l:dgr = grey_level(l:gx) - a:r
+ let l:dgg = grey_level(l:gy) - a:g
+ let l:dgb = grey_level(l:gz) - a:b
+ let l:dgrey = (l:dgr * l:dgr) + (l:dgg * l:dgg) + (l:dgb * l:dgb)
+ let l:dr = rgb_level(l:gx) - a:r
+ let l:dg = rgb_level(l:gy) - a:g
+ let l:db = rgb_level(l:gz) - a:b
+ let l:drgb = (l:dr * l:dr) + (l:dg * l:dg) + (l:db * l:db)
+ if l:dgrey < l:drgb
+ " Use the grey
+ return grey_colour(l:gx)
+ else
+ " Use the colour
+ return rgb_colour(l:x, l:y, l:z)
+ endif
+ else
+ " Only one possibility
+ return rgb_colour(l:x, l:y, l:z)
+ endif
+ endfun
+
+ " Returns the palette index to approximate the 'rrggbb' hex string
+ fun rgb(rgb)
+ let l:r = ("0x" . strpart(a:rgb, 0, 2)) + 0
+ let l:g = ("0x" . strpart(a:rgb, 2, 2)) + 0
+ let l:b = ("0x" . strpart(a:rgb, 4, 2)) + 0
+
+ return colour(l:r, l:g, l:b)
+ endfun
+
+ " Sets the highlighting for the given group
+ fun X(group, fg, bg, attr)
+ if a:fg != ""
+ exec "hi " . a:group . " guifg=#" . a:fg . " ctermfg=" . rgb(a:fg)
+ endif
+ if a:bg != ""
+ exec "hi " . a:group . " guibg=#" . a:bg . " ctermbg=" . rgb(a:bg)
+ endif
+ if a:attr != ""
+ exec "hi " . a:group . " gui=" . a:attr . " cterm=" . a:attr
+ endif
+ endfun
+
+ " Vim Highlighting
+ call X("Normal", s:foreground, s:background, "")
+ highlight LineNr term=bold cterm=NONE ctermfg=DarkGrey ctermbg=NONE gui=NONE guifg=DarkGrey guibg=NONE
+ call X("NonText", s:selection, "", "")
+ call X("SpecialKey", s:selection, "", "")
+ call X("Search", s:foreground, s:yellow, "")
+ call X("TabLine", s:foreground, s:background, "reverse")
+ call X("StatusLine", s:window, s:yellow, "reverse")
+ call X("StatusLineNC", s:window, s:foreground, "reverse")
+ call X("VertSplit", s:window, s:window, "none")
+ call X("Visual", "", s:selection, "")
+ call X("Directory", s:blue, "", "")
+ call X("ModeMsg", s:green, "", "")
+ call X("MoreMsg", s:green, "", "")
+ call X("Question", s:green, "", "")
+ call X("WarningMsg", s:red, "", "")
+ call X("MatchParen", "", s:selection, "")
+ call X("Folded", s:comment, s:background, "")
+ call X("FoldColumn", "", s:background, "")
+ if version >= 700
+ call X("CursorLine", "", s:line, "none")
+ call X("CursorColumn", "", s:line, "none")
+ call X("PMenu", s:foreground, s:selection, "none")
+ call X("PMenuSel", s:foreground, s:selection, "reverse")
+ end
+ if version >= 703
+ call X("ColorColumn", "", s:line, "none")
+ end
+
+ " Standard Highlighting
+ call X("Comment", s:comment, "", "")
+ call X("Todo", s:comment, s:background, "")
+ call X("Title", s:comment, "", "")
+ call X("Identifier", s:red, "", "none")
+ call X("Statement", s:foreground, "", "")
+ call X("Conditional", s:foreground, "", "")
+ call X("Repeat", s:foreground, "", "")
+ call X("Structure", s:purple, "", "")
+ call X("Function", s:blue, "", "")
+ call X("Constant", s:orange, "", "")
+ call X("String", s:green, "", "")
+ call X("Special", s:foreground, "", "")
+ call X("PreProc", s:purple, "", "")
+ call X("Operator", s:aqua, "", "none")
+ call X("Type", s:blue, "", "none")
+ call X("Define", s:purple, "", "none")
+ call X("Include", s:blue, "", "")
+ "call X("Ignore", "666666", "", "")
+
+ " Vim Highlighting
+ call X("vimCommand", s:red, "", "none")
+
+ " C Highlighting
+ call X("cType", s:yellow, "", "")
+ call X("cStorageClass", s:purple, "", "")
+ call X("cConditional", s:purple, "", "")
+ call X("cRepeat", s:purple, "", "")
+
+ " PHP Highlighting
+ call X("phpVarSelector", s:red, "", "")
+ call X("phpKeyword", s:purple, "", "")
+ call X("phpRepeat", s:purple, "", "")
+ call X("phpConditional", s:purple, "", "")
+ call X("phpStatement", s:purple, "", "")
+ call X("phpMemberSelector", s:foreground, "", "")
+
+ " Ruby Highlighting
+ call X("rubySymbol", s:green, "", "")
+ call X("rubyConstant", s:yellow, "", "")
+ call X("rubyAttribute", s:blue, "", "")
+ call X("rubyInclude", s:blue, "", "")
+ call X("rubyLocalVariableOrMethod", s:orange, "", "")
+ call X("rubyCurlyBlock", s:orange, "", "")
+ call X("rubyStringDelimiter", s:green, "", "")
+ call X("rubyInterpolationDelimiter", s:orange, "", "")
+ call X("rubyConditional", s:purple, "", "")
+ call X("rubyRepeat", s:purple, "", "")
+
+ " Python Highlighting
+ call X("pythonInclude", s:purple, "", "")
+ call X("pythonStatement", s:purple, "", "")
+ call X("pythonConditional", s:purple, "", "")
+ call X("pythonFunction", s:blue, "", "")
+
+ " JavaScript Highlighting
+ call X("javaScriptBraces", s:foreground, "", "")
+ call X("javaScriptFunction", s:purple, "", "")
+ call X("javaScriptConditional", s:purple, "", "")
+ call X("javaScriptRepeat", s:purple, "", "")
+ call X("javaScriptNumber", s:orange, "", "")
+ call X("javaScriptMember", s:orange, "", "")
+
+ " Diff Highlighting
+ call X("diffAdded", s:green, "", "")
+ call X("diffRemoved", s:red, "", "")
+
+ " Delete Functions
+ delf X
+ delf rgb
+ delf colour
+ delf rgb_colour
+ delf rgb_level
+ delf rgb_number
+ delf grey_colour
+ delf grey_level
+ delf grey_number
+endif