Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix everything forever

  • Loading branch information...
commit f1bb361464e9a017c59a79d0d5214bf1bbce01a2 1 parent 9a5c62c
@tmcw authored
Showing with 4,214 additions and 212 deletions.
  1. +27 −0 .gitmodules
  2. +52 −80 .vimrc
  3. +1 −1  bundle/ack.vim
  4. +1 −0  bundle/atom
  5. +1 −0  bundle/badwolf
  6. +1 −1  bundle/ctrlp
  7. +1 −1  bundle/gist-vim
  8. +11 −0 bundle/hexHighlight/README
  9. +203 −0 bundle/hexHighlight/plugin/hexHighlight.vim
  10. +1 −1  bundle/neocomplcache
  11. +1 −1  bundle/nerdtree
  12. +4 −0 bundle/supertab/.gitignore
  13. +11 −0 bundle/supertab/Makefile
  14. +66 −0 bundle/supertab/README.rst
  15. +362 −0 bundle/supertab/doc/supertab.txt
  16. +923 −0 bundle/supertab/plugin/supertab.vim
  17. +1 −1  bundle/syntastic
  18. +1 −1  bundle/vim-coffee-script
  19. +1 −1  bundle/vim-fugitive
  20. +60 −0 bundle/vim-gitgutter/README.mkd
  21. +237 −0 bundle/vim-gitgutter/plugin/gitgutter.vim
  22. BIN  bundle/vim-gitgutter/screenshot.png
  23. +1 −1  bundle/vim-golang
  24. +7 −0 bundle/vim-literate-coffeescript/LICENSE
  25. +56 −0 bundle/vim-literate-coffeescript/README.md
  26. +7 −0 bundle/vim-literate-coffeescript/ftdetect/litcoffee.vim
  27. +22 −0 bundle/vim-literate-coffeescript/indent/litcoffee.vim
  28. +17 −0 bundle/vim-literate-coffeescript/syntax/litcoffee.vim
  29. +117 −0 bundle/vim-literate-coffeescript/test/test.litcoffee
  30. BIN  bundle/vim-literate-coffeescript/test/test.png
  31. +1 −1  bundle/vim-nodejs-complete
  32. +1 −1  bundle/vim-rhubarb
  33. +1 −1  bundle/vim-surround
  34. +1 −1  bundle/vim-unimpaired
  35. +1 −1  bundle/webapi-vim
  36. +85 −0 colors/cmyk.vim
  37. +4 −104 colors/kod.vim
  38. +343 −0 colors/mayansmoke.vim
  39. +490 −0 colors/northsky.vim
  40. +599 −0 colors/peaksea.vim
  41. +218 −0 colors/random.vim
  42. +182 −0 colors/superman.vim
  43. +60 −14 colors/tombat.vim
  44. +18 −0 colors/twokthirteen.vim
  45. +17 −0 spell/en.utf-8.add
  46. BIN  spell/en.utf-8.add.spl
View
27 .gitmodules
@@ -58,3 +58,30 @@
[submodule "bundle/neocomplcache"]
path = bundle/neocomplcache
url = https://github.com/Shougo/neocomplcache.git
+[submodule "bundle/supertab"]
+ path = bundle/supertab
+ url = https://github.com/ervandew/supertab.git
+[submodule "bundle/mediawiki.vim"]
+ path = bundle/mediawiki.vim
+ url = https://github.com/chikamichi/mediawiki.vim.git
+[submodule "bundle/tagbar"]
+ path = bundle/tagbar
+ url = https://github.com/majutsushi/tagbar.git
+[submodule "bundle/atom"]
+ path = bundle/atom
+ url = https://github.com/gregsexton/Atom.git
+[submodule "bundle/badwolf"]
+ path = bundle/badwolf
+ url = https://github.com/sjl/badwolf.git
+[submodule "bundle/rust"]
+ path = bundle/rust
+ url = https://github.com/reusee/vim.rust.git
+[submodule "bundle/hexHighlight"]
+ path = bundle/hexHighlight
+ url = https://github.com/yurifury/hexHighlight.git
+[submodule "bundle/vim-gitgutter"]
+ path = bundle/vim-gitgutter
+ url = git://github.com/airblade/vim-gitgutter.git
+[submodule "bundle/vim-literate-coffeescript"]
+ path = bundle/vim-literate-coffeescript
+ url = https://github.com/mintplant/vim-literate-coffeescript.git
View
132 .vimrc
@@ -1,77 +1,96 @@
-set t_Co=256
-set vb
+silent! call pathogen#infect()
-call pathogen#infect()
-set nocompatible
syntax enable
filetype plugin indent on
+set t_Co=256
+set vb
+set nocompatible
set showmatch
set ruler
set number
set nowrap
set hlsearch
set colorcolumn=80
-
-" Fast saving
-nmap <leader>. :tabnext<cr>
-nmap <leader>/ :tabnext<cr>
-
-" Default indentation
set tabstop=4
set shiftwidth=4
set autoindent
set expandtab
-let g:neocomplcache_enable_at_startup = 1
+set backupdir=/Users/tmcw/tmp/
+set directory=/Users/tmcw/tmp/
+set nobackup
+set nowritebackup
-autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
-autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
-autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
-autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
-autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
+nmap <leader>. :tabnext<cr>
+nmap <leader>/ :tabnext<cr>
-"SECTION: NERDTree Customization
-" \d will hide/show
-" \b will enter :NERDTreeFromBookmark and then
-" you can autocomplete the name of a bookmark
+inoremap <expr><TAB> pumvisible() ? "<C-n>" : "<TAB>"
nnoremap <leader>d :NERDTreeToggle<cr>
-map <leader>gu :GundoToggle<CR>
+nnoremap <leader>t :TagbarToggle<cr>
+nnoremap <leader>a :Ack
+
let NERDTreeDirArrows=1
let NERDTreeMinimalUI=1
let NERDTreeIgnore=['\.pyc$', 'CVS', '\~$']
+let NERDTreeHijackNetrw=1
-" Colorscheme
set background=dark
-colorscheme Tomorrow-Night
+colorscheme tombat
if has("gui_running")
set go-=T
- set guifont=M+_1m_light:h13
+ set guifont=M+_1mn_light:h13
set noballooneval
else
set mouse=a
endif
-" Javascript
+autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
+autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
+autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
+autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
+autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
+
autocmd BufNewFile,BufRead *.json set filetype=javascript
autocmd BufRead,BufNewFile *.mml set syntax=javascript
autocmd BufRead,BufNewFile *.bones set syntax=javascript
-
autocmd BufRead,BufNewFile *.result set syntax=xml
+autocmd BufRead,BufNewFile *.mss set syntax=carto
+autocmd BufRead,BufNewFile *.md set filetype=markdown
au BufNewFile,BufRead *._ set filetype=html
-autocmd BufRead,BufNewFile *.mss set syntax=carto
-autocmd BufRead,BufNewFile *.md set filetype=markdown
+" Show syntax highlighting groups for word under cursor
+nmap <C-S-A> :call <SID>SynStack()<CR>
+function! <SID>SynStack()
+ if !exists("*synstack")
+ return
+ endif
+ echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
+endfunc
+
+if has("eval")
+function! SL(function)
+ if exists('*'.a:function)
+ return call(a:function,[])
+ else
+ return ''
+ endif
+endfunction
+endif
+
+set statusline=[%n]\ %<%.99f\ %h%w%m%r%y%{SL('fugitive#statusline')}%{SL('SyntasticStatuslineFlag')}%*%=%-14.(%l,%c%V%)\ %P
-set statusline=[%n]\ %<%.99f\ %h%w%m%r%y%{exists('g:loaded_fugitive')?fugitive#statusline():''}
-set statusline+=\ %#warningmsg#
-set statusline+=%{SyntasticStatuslineFlag()}
let g:syntastic_enable_signs=1
let g:syntastic_disabled_filetypes = ['cpp']
let g:gist_clip_command = 'pbcopy'
let g:gist_detect_filetype = 1
+let g:ctrlp_extensions = ['line']
+let g:ackprg = 'ag --nogroup --nocolor --column'
+
+let g:solarized_contrast="low"
+
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
@@ -79,57 +98,10 @@ autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()
+map <leader>gu :GundoToggle<CR>
nnoremap <leader>w :! git pull origin master && git push origin master --tags<cr>
nnoremap <leader>e :! git pull origin gh-pages && git push origin gh-pages --tags<cr>
-
-set backupdir=/Users/tmcw/tmp/
-set directory=/Users/tmcw/tmp/
-set nobackup
-set nowritebackup
-
-function! HtmlEscape()
- silent s/&/\&amp;/eg
- silent s/</\&lt;/eg
- silent s/>/\&gt;/eg
-endfunction
-
-function! HtmlUnEscape()
- silent s/&lt;/</eg
- silent s/&gt;/>/eg
- silent s/&amp;/\&/eg
-endfunction
-
-noremap <silent> <c-h> :call HtmlEscape()<CR>
-noremap <silent> <c-u> :call HtmlUnEscape()<CR>
-
-nnoremap <silent> <c-o> :CtrlPMRU<Cr>
-
-" Show syntax highlighting groups for word under cursor
-function! <SID>SynStack ()
- if !exists("*synstack")
- return
- endif
- echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
-endfunc
-noremap <F3> :call <SID>SynStack()<CR>
-inoremap <F3> :call <SID>SynStack()<CR>
-
-function! DFW()
- colorscheme Tomorrow
- set background=light
- set lines=40 columns=100 " size of the editable area
- set fuoptions=background:#00f5f6f6 " macvim specific setting for editor's background color
- set guioptions-=r " remove right scrollbar
- set laststatus=0 " don't show status line
- set noruler " don't show ruler
- set fullscreen " go to fullscreen editing mode
- set linebreak " break the lines on words
- set colorcolumn=
- set nonumber
-endfunction
-
-let g:ctrlp_extensions = ['line']
-let g:ackprg = 'ag --nogroup --nocolor --column'
+vnoremap <C-E> ! node<cr>
" automatically open and close the popup menu / preview window
au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif
2  bundle/ack.vim
@@ -1 +1 @@
-Subproject commit 9895285042a2fd5691b2f6582aa979e4d1bdffea
+Subproject commit 34d0b2fbc182b31d926632d170bc07d6a6fc3f9b
1  bundle/atom
@@ -0,0 +1 @@
+Subproject commit b07c601305d4129b31536b0771984f94c04b7d4b
1  bundle/badwolf
@@ -0,0 +1 @@
+Subproject commit 627b4658ede59411d0b8dd1071548bb0f4e64d90
2  bundle/ctrlp
@@ -1 +1 @@
-Subproject commit f7561810bf259a1b44c409095e4af1ca7cec1288
+Subproject commit c1646e3c28d75bcc834af4836f4c6e12296ba891
2  bundle/gist-vim
@@ -1 +1 @@
-Subproject commit 30003a0c291d8379789d78240413952a9846b380
+Subproject commit f42ceff6b8eab96ddc917df020824370526e871b
View
11 bundle/hexHighlight/README
@@ -0,0 +1,11 @@
+description
+This plugin looks for hex codes of the format #ffffff or #fff and toggles a highlight in that color. It is useful for editing colorschemes, and generally any config file dealing with colors.
+
+Only works with the graphical version of vim.
+
+install details
+Put hexHighlight.vim into your .vim/plugins directory, or simply :source the file.
+
+The default keymapping to toggle hex code highlighting is <Leader>F2, and the default <Leader> bind is "\", so \F2 should work by default.
+
+The toggle can be called manually by :call HexHighlight()
View
203 bundle/hexHighlight/plugin/hexHighlight.vim
@@ -0,0 +1,203 @@
+"gvim plugin for highlighting hex codes to help with tweaking colors
+"Last Change: 2010 Dec 21
+"Maintainer: Yuri Feldman <yuri@tbqh.net>
+"License: WTFPL - Do What The Fuck You Want To Public License.
+"Email me if you'd like.
+if exists('g:loaded_hexHighlight') || v:version < 700
+ finish
+endif
+let s:HexColored = 0
+let s:HexColors = []
+
+nnoremap <Plug>HexHighlightToggle :<C-u>call <SID>HexHighlightToggle()<CR>
+if ! hasmapto('<Plug>HexHighlightToggle', 'n')
+ nmap <Leader><F2> <Plug>HexHighlightToggle
+endif
+
+nnoremap <Plug>HexHighlightRefresh :<C-u>call <SID>HexHighlightRefresh()<CR>
+if ! hasmapto('<Plug>HexHighlightRefresh', 'n')
+ nmap <Leader>[ <Plug>HexHighlightRefresh
+endif
+
+nnoremap <Plug>RefreshColorScheme :<C-u>call <SID>RefreshColorScheme()<CR>
+if ! hasmapto('<Plug>RefreshColorScheme', 'n')
+ nmap <Leader>p <Plug>RefreshColorScheme
+endif
+
+function! s:RefreshColorScheme()
+ exe 'w'
+ exe 'colorscheme ' . g:colors_name
+endfunction
+command! -nargs=? HCT call s:HighlightCTerms()
+command! -nargs=? HHC call s:HighlightHexCodes()
+command! -nargs=? RCS call s:RefreshColorScheme()
+
+function! s:HighlightHexCodes()
+ let lineNumber = 0
+ let matchno = 4
+ while lineNumber <= line("$")
+ let currentLine = getline(lineNumber)
+
+ if match(currentLine, '\v^\s*hi(light)?') != -1
+ let hiNameIndex = matchend(currentLine, '\v^\s*hi(light)?')
+ if hiNameIndex != -1
+ let hiNameMatch = matchstr(currentLine, '\v\w+', hiNameIndex)
+ endif
+
+ let guibgIndex = matchend(currentLine, 'guibg=')
+ if guibgIndex != -1
+ let guibgMatch = matchstr(currentLine, '\v\S+', guibgIndex)
+ else
+ let guibgMatch = 'NONE'
+ endif
+
+ let guifgIndex = matchend(currentLine, 'guifg=')
+ if guifgIndex != -1
+ let guifgMatch = matchstr(currentLine, '\v\S+', guifgIndex)
+ else
+ let guifgMatch = 'NONE'
+ endif
+
+ let guiIndex = matchend(currentLine, 'gui=')
+ if guiIndex != -1
+ let guiMatch = matchstr(currentLine, '\v\S+', guiIndex)
+ else
+ let guiMatch = 'none'
+ endif
+
+ let guispIndex = matchend(currentLine, 'guisp=')
+ if guispIndex != -1
+ let guispMatch = matchstr(currentLine, '\v\S+', guispIndex)
+ else
+ let guispMatch = 'NONE'
+ endif
+
+ if guifgMatch != 'NONE' || guibgMatch != 'NONE' || guiMatch != 'none' || guispMatch != 'NONE'
+ exec 'hi '.matchno.' guibg='.guibgMatch.' guifg='.guifgMatch.' gui='.guiMatch.' guisp='.guispMatch
+ let m = matchadd(matchno, hiNameMatch)
+ let matchno += 1
+ endif
+ endif
+ let lineNumber += 1
+ endwhile
+endfunction
+
+function! s:HighlightCTerms()
+ let s = clearmatches()
+
+ let lineNumber = 0
+ let matchno = 4
+ while lineNumber <= line("$")
+ let currentLine = getline(lineNumber)
+
+ if match(currentLine, '\v^\s*hi(light)?') != -1
+ let hiNameIndex = matchend(currentLine, '\v^\s*hi(light)?')
+ if hiNameIndex != -1
+ let hiNameMatch = matchstr(currentLine, '\v\w+', hiNameIndex)
+ endif
+
+ let ctermbgIndex = matchend(currentLine, 'ctermbg=')
+ if ctermbgIndex != -1
+ let ctermbgMatch = matchstr(currentLine, '\v\S+', ctermbgIndex)
+ else
+ let ctermbgMatch = 'none'
+ endif
+
+ let ctermfgIndex = matchend(currentLine, 'ctermfg=')
+ if ctermfgIndex != -1
+ let ctermfgMatch = matchstr(currentLine, '\v\S+', ctermfgIndex)
+ else
+ let ctermfgMatch = 'none'
+ endif
+
+ let ctermIndex = matchend(currentLine, 'cterm=')
+ if ctermIndex != -1
+ let ctermMatch = matchstr(currentLine, '\v\S+', ctermIndex)
+ else
+ let ctermMatch = 'none'
+ endif
+
+ if ctermfgMatch != 'none' || ctermbgMatch != 'none' || ctermMatch != 'none'
+ exec 'hi '.matchno.' ctermbg='.ctermbgMatch.' ctermfg='.ctermfgMatch.' cterm='.ctermMatch
+ let m = matchadd(matchno, hiNameMatch)
+ let matchno += 1
+ endif
+ endif
+ let lineNumber += 1
+ endwhile
+endfunction
+
+function! s:HexHighlightRefresh()
+ if ! has("gui_running")
+ echo "hexHighlight only works with a graphical version of vim"
+ return 0
+ endif
+ if s:HexColored == 0
+ let s:HexColored = s:HexColorize()
+ echo "Highlighting hex colors"
+ elseif s:HexColored == 1
+ call s:HexClear()
+ let s:HexColored = s:HexColorize()
+ echo "Refreshing hex colors"
+ endif
+endfunction
+
+function! s:HexHighlightToggle()
+ if ! has("gui_running")
+ echo "hexHighlight only works with a graphical version of vim"
+ return 0
+ endif
+ if s:HexColored == 0
+ let s:HexColored = s:HexColorize()
+ echo "Highlighting hex colors"
+ elseif s:HexColored == 1
+ let s:HexColored = s:HexClear()
+ echo "Unhighlighting hex colors"
+ endif
+endfunction
+
+function! s:HexClear()
+ for hexColor in s:HexColors
+ exe 'highlight clear '.hexColor
+ endfor
+ call clearmatches()
+ return 0
+endfunction
+
+function! s:HexColorize()
+ let hexGroup = 4
+ let lineNumber = 0
+ while lineNumber <= line("$")
+ let currentLine = getline(lineNumber)
+ let hexLineMatch = 1
+
+ while match(currentLine, '#\x\{6}\|#\x\{3}', 0, hexLineMatch) != -1
+ let hexMatch = matchstr(currentLine, '#\x\{6}\|#\x\{3}', 0, hexLineMatch)
+
+ let hexColor=hexMatch
+ if (strlen(hexMatch) == 4)
+ let hexColor = '#' . substitute(strpart(hexMatch, 1), '.', '&&', 'g')
+ endif
+
+ let rPart = str2nr(strpart(hexColor, 1, 2), 16)
+ let gPart = str2nr(strpart(hexColor, 3, 2), 16)
+ let bPart = str2nr(strpart(hexColor, 5, 2), 16)
+
+ if rPart > 127 || gPart > 127 || bPart > 127
+ let hexComplement = "#000000"
+ else
+ let hexComplement = "#FFFFFF"
+ end
+
+ exe 'hi hexColor'.hexGroup.' guifg='.hexComplement.' guibg='.hexColor
+ exe 'let m = matchadd("hexColor'.hexGroup.'", "'.hexColor.'", 25, '.hexGroup.')'
+ let s:HexColors += ['hexColor'.hexGroup]
+ let hexGroup += 1
+ let hexLineMatch += 1
+ endwhile
+
+ let lineNumber += 1
+ endwhile
+ unlet lineNumber hexGroup
+ return 1
+endfunction
2  bundle/neocomplcache
@@ -1 +1 @@
-Subproject commit a1f2a6ec60c632e4be962d2ecb91534526b51215
+Subproject commit c9eebc7557c07cad95c2c261ea8a0971c8a0afdb
2  bundle/nerdtree
@@ -1 +1 @@
-Subproject commit 2cb0fc78fb4c7a1db5f51c042a447cc50f09983d
+Subproject commit 40d05ace57fb51cc2c2b2e9eb81c4832ed291630
View
4 bundle/supertab/.gitignore
@@ -0,0 +1,4 @@
+*.swp
+*.vmb
+doc/tags
+/README.html
View
11 bundle/supertab/Makefile
@@ -0,0 +1,11 @@
+SHELL=/bin/bash
+
+all: dist
+
+dist:
+ @rm supertab.vmb 2> /dev/null || true
+ @vim -c 'r! git ls-files doc plugin' \
+ -c '$$,$$d _' -c '%MkVimball supertab .' -c 'q!'
+
+clean:
+ @rm -R build 2> /dev/null || true
View
66 bundle/supertab/README.rst
@@ -0,0 +1,66 @@
+.. Copyright (c) 2012, Eric Van Dewoestine
+ All rights reserved.
+
+ Redistribution and use of this software in source and binary forms, with
+ or without modification, are permitted provided that the following
+ conditions are met:
+
+ * Redistributions of source code must retain the above
+ copyright notice, this list of conditions and the
+ following disclaimer.
+
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the
+ following disclaimer in the documentation and/or other
+ materials provided with the distribution.
+
+ * Neither the name of Eric Van Dewoestine nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission of
+ Eric Van Dewoestine.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+.. _overview:
+
+==================
+Overview
+==================
+
+Supertab is a vim plugin which allows you to use <Tab> for all your insert
+completion needs (:help ins-completion).
+
+Features
+--------
+
+- Configurable to suit you needs:
+
+ - Default completion type to use.
+ - Prevent <Tab> from completing after/before defined patterns.
+ - Close vim's completion preview window when code completion is finished.
+ - When using other completion types, you can configure how long to 'remember'
+ the current completion type before returning to the default.
+ - Don't like using <Tab>? You can also configure a different pair of keys to
+ scroll forwards and backwards through completion results.
+
+- Optional improved 'longest' completion support (after typing some characters,
+ hitting <Tab> will highlight the next longest match).
+- Built in 'context' completion option which chooses the appropriate completion
+ type based on the text preceding the cursor.
+
+ - You can also plug in your own functions to determine which completion type
+ to use.
+
+- Support for simple completion chaining (falling back to a different
+ completion type, keyword completion for example, if omni or user completion
+ returns no results).
View
362 bundle/supertab/doc/supertab.txt
@@ -0,0 +1,362 @@
+*supertab.txt*
+
+Author: Eric Van Dewoestine <ervandew@gmail.com>
+ Original concept and versions up to 0.32 written by
+ Gergely Kontra <kgergely@mcl.hu>
+
+This plugin is licensed under the terms of the BSD License. Please see
+supertab.vim for the license in its entirety.
+
+==============================================================================
+Supertab *supertab*
+
+1. Introduction |supertab-intro|
+2. Supertab Usage |supertab-usage|
+3. Supertab Options |supertab-options|
+ Default completion type |supertab-defaultcompletion|
+ Secondary default completion type |supertab-contextdefault|
+ Completion contexts |supertab-completioncontexts|
+ Context text |supertab-contexttext|
+ Context Discover |supertab-contextdiscover|
+ Example |supertab-contextexample|
+ Completion Duration |supertab-duration|
+ Preventing Completion After/Before... |supertab-preventcomplete|
+ Changing default mapping |supertab-forwardbackward|
+ Inserting true tabs |supertab-mappingtabliteral|
+ Enhanced longest match support |supertab-longestenhanced|
+ Preselecting the first entry |supertab-longesthighlight|
+ Mapping <cr> to end completion |supertab-crmapping|
+ Auto close the preview window |supertab-closepreviewonpopupclose|
+ Completion Chaining |supertab-completionchaining|
+
+==============================================================================
+1. Introduction *supertab-intro*
+
+Supertab is a plugin which allows you to perform all your insert completion
+(|ins-completion|) using the tab key.
+
+Supertab requires Vim version 7.0 or above.
+
+==============================================================================
+2. Supertab usage *supertab-usage*
+
+Using Supertab is as easy as hitting <Tab> or <S-Tab> (shift+tab) while in
+insert mode, with at least one non whitespace character before the cursor, to
+start the completion and then <Tab> or <S-Tab> again to cycle forwards or
+backwards through the available completions.
+
+Example ('|' denotes the cursor location):
+
+bar
+baz
+b|<Tab> Hitting <Tab> here will start the completion, allowing you to
+ then cycle through the suggested words ('bar' and 'baz').
+
+==============================================================================
+3. Supertab Options *supertab-options*
+
+Supertab is configured via several global variables that you can set in your
+|vimrc| file according to your needs. Below is a comprehensive list of
+the variables available.
+
+
+Default Completion Type *supertab-defaultcompletion*
+ *g:SuperTabDefaultCompletionType*
+
+g:SuperTabDefaultCompletionType (default value: "<c-p>")
+
+Used to set the default completion type. There is no need to escape this
+value as that will be done for you when the type is set.
+
+ Example: setting the default completion to 'user' completion:
+
+ let g:SuperTabDefaultCompletionType = "<c-x><c-u>"
+
+Note: a special value of 'context' is supported which will result in
+super tab attempting to use the text preceding the cursor to decide which
+type of completion to attempt. Currently super tab can recognize method
+calls or attribute references via '.', '::' or '->', and file path
+references containing '/'.
+
+ let g:SuperTabDefaultCompletionType = "context"
+
+ /usr/l<tab> # will use filename completion
+ myvar.t<tab> # will use user completion if completefunc set,
+ # or omni completion if omnifunc set.
+ myvar-><tab> # same as above
+
+When using context completion, super tab will fall back to a secondary default
+completion type set by |g:SuperTabContextDefaultCompletionType|.
+
+Note: once the buffer has been initialized, changing the value of this setting
+will not change the default complete type used. If you want to change the
+default completion type for the current buffer after it has been set, perhaps
+in an ftplugin, you'll need to call SuperTabSetDefaultCompletionType like so,
+supplying the completion type you wish to switch to:
+
+ call SuperTabSetDefaultCompletionType("<c-x><c-u>")
+
+
+Secondary default completion type *supertab-contextdefault*
+ *g:SuperTabContextDefaultCompletionType*
+
+g:SuperTabContextDefaultCompletionType (default value: "<c-p>")
+
+Sets the default completion type used when g:SuperTabDefaultCompletionType is
+set to 'context' and no completion type is returned by any of the configured
+contexts.
+
+
+Completion contexts *supertab-completioncontexts*
+ *g:SuperTabCompletionContexts*
+
+g:SuperTabCompletionContexts (default value: ['s:ContextText'])
+
+Sets the list of contexts used for context completion. This value should
+be a list of function names which provide the context implementation.
+
+When supertab starts the default completion, each of these contexts will be
+consulted, in the order they were supplied, to determine the completion type
+to use. If a context returns a completion type, that type will be used,
+otherwise the next context in the list will be consulted. If after executing
+all the context functions, no completion type has been determined, then the
+value of g:SuperTabContextDefaultCompletionType will be used.
+
+Built in completion contexts:
+
+ s:ContextText *supertab-contexttext*
+
+ The text context will examine the text near the cursor to decide which type
+ of completion to attempt. Currently the text context can recognize method
+ calls or attribute references via '.', '::' or '->', and file path
+ references containing '/'.
+
+ /usr/l<tab> # will use filename completion
+ myvar.t<tab> # will use user completion if completefunc set, or
+ # omni completion if omnifunc set.
+ myvar-><tab> # same as above
+
+ Supported configuration attributes:
+
+ g:SuperTabContextTextFileTypeExclusions
+ List of file types for which the text context will be skipped.
+
+ g:SuperTabContextTextOmniPrecedence
+ List of omni completion option names in the order of precedence that they
+ should be used if available. By default, user completion will be given
+ precedence over omni completion, but you can use this variable to give
+ omni completion higher precedence by placing it first in the list.
+
+ s:ContextDiscover *supertab-contextdiscover*
+
+ This context will use the 'g:SuperTabContextDiscoverDiscovery' variable to
+ determine the completion type to use. It will evaluate each value, in the
+ order they were defined, until a variable evaluates to a non-zero or
+ non-empty value, then the associated completion type is used.
+
+ Supported configuration properties:
+
+ g:SuperTabContextDiscoverDiscovery
+ List of variable:completionType mappings.
+
+ Example context configuration: *supertab-contextexample*
+
+ let g:SuperTabCompletionContexts = ['s:ContextText', 's:ContextDiscover']
+ let g:SuperTabContextTextOmniPrecedence = ['&omnifunc', '&completefunc']
+ let g:SuperTabContextDiscoverDiscovery =
+ \ ["&completefunc:<c-x><c-u>", "&omnifunc:<c-x><c-o>"]
+
+ In addition to the default completion contexts, you can plug in your own
+ implementation by creating a globally accessible function that returns
+ the completion type to use (eg. "\<c-x>\<c-u>").
+
+ function MyTagContext()
+ if filereadable(expand('%:p:h') . '/tags')
+ return "\<c-x>\<c-]>"
+ endif
+ " no return will result in the evaluation of the next
+ " configured context
+ endfunction
+ let g:SuperTabCompletionContexts =
+ \ ['MyTagContext', 's:ContextText', 's:ContextDiscover']
+
+ Note: supertab also supports the b:SuperTabCompletionContexts variable
+ allowing you to set the list of contexts separately for the current buffer,
+ like from an ftplugin for example.
+
+
+Completion Duration *supertab-duration*
+ *g:SuperTabRetainCompletionDuration*
+
+g:SuperTabRetainCompletionDuration (default value: 'insert')
+
+Determines if, and for how long, the current completion type is retained.
+The possible values include:
+'completion' - The current completion type is only retained for the
+ current completion. Once you have chosen a completion
+ result or exited the completion mode, the default
+ completion type is restored.
+'insert' - The current completion type is saved until you exit insert
+ mode (via ESC). Once you exit insert mode the default
+ completion type is restored. (supertab default)
+'session' - The current completion type is saved for the duration of
+ your vim session or until you enter a different completion
+ mode.
+
+
+Preventing completion after... *supertab-preventcomplete*
+ *g:SuperTabNoCompleteBefore*
+ *g:SuperTabNoCompleteAfter*
+
+g:SuperTabNoCompleteBefore (default value: [])
+g:SuperTabNoCompleteAfter (default value: ['^', '\s'])
+
+These two variables are used to control when supertab will attempt completion
+or instead fall back to inserting a literal <tab>. There are two possible ways
+to define these variables:
+
+ 1) by specifying a list of patterns which are tested against the text before
+ and after the current cursor position that when matched, prevent completion.
+ So if you don't want supertab to start completion at the start of a line,
+ after a comma, or after a space, you can set g:SuperTabNoCompleteAfter
+ to ['^', ',', '\s'].
+
+ 2) by specifying a funcref to a global accessible function which expects
+ as parameter the text to be inspected (before or after) and, based on that (or
+ other factors), it returns 1 if completion must be prevented, 0 otherwise.
+
+Note: That a buffer local version of these variables
+(b:SuperTabNoCompleteBefore, b:SuperTabNoCompleteAfter) is also supported
+should you wish to have different values depending on the file type for
+instance.
+
+Changing the default mapping *supertab-forwardbackward*
+ *g:SuperTabMappingForward*
+ *g:SuperTabMappingBackward*
+
+g:SuperTabMappingForward (default value: '<tab>')
+g:SuperTabMappingBackward (default value: '<s-tab>')
+
+These two variables allow you to set the keys used to kick off the current
+completion. By default this is <tab> and <s-tab>. To change to something
+like <c-space> and <s-c-space>, you can add the following to your |vimrc|.
+
+ let g:SuperTabMappingForward = '<c-space>'
+ let g:SuperTabMappingBackward = '<s-c-space>'
+
+Note: if the above does not have the desired effect (which may happen in
+console version of vim), you can try the following mappings. Although the
+backwards mapping still doesn't seem to work in the console for me, your
+milage may vary.
+
+ let g:SuperTabMappingForward = '<nul>'
+ let g:SuperTabMappingBackward = '<s-nul>'
+
+
+Inserting true tabs *supertab-mappingtabliteral*
+ *g:SuperTabMappingTabLiteral*
+
+g:SuperTabMappingTabLiteral (default value: '<c-tab>')
+
+Sets the key mapping used to insert a literal tab where supertab would
+otherwise attempt to kick off insert completion. The default is '<c-tab>'
+(ctrl-tab) which unfortunately might not work at the console. So if you are
+using a console vim and want this functionality, you may have to change it to
+something that is supported. Alternatively, you can escape the <tab> with
+<c-v> (see |i_CTRL-V| for more infos).
+
+
+Enhanced longest match support *supertab-longestenhanced*
+ *g:SuperTabLongestEnhanced*
+
+g:SuperTabLongestEnhanced (default value: 0)
+
+When enabled and 'longest' is in your |completeopt| setting, supertab will
+provide an enhanced longest match support where typing one or more letters and
+hitting tab again while in a completion mode will complete the longest common
+match using the new text in the buffer.
+
+For example, say you have a buffer with the following contents:
+ FooBarFoo
+ FooBar
+ Foo
+ FooBarBaz
+And you then type F<tab>. Vim's builtin longest support will complete the
+longest common text 'Foo' and offer 'FooBarFoo', 'FooBar', 'Foo', and
+'FooBarBaz' as possible completions. With supertab's longest match
+enhancement disabled, typing B<tab> while still in the completion mode will
+end up completing 'FooBarBaz' or 'FooBarFoo' depending your settings, instead
+of the next longest common match of 'FooBar'. With supertab's enhanced
+longest match feature enabled, the typing of B<tab> will result in the next
+longest text being completed.
+
+
+Preselecting the first entry *supertab-longesthighlight*
+ *g:SuperTabLongestHighlight*
+
+g:SuperTabLongestHighlight (default value: 0)
+
+Sets whether or not to pre-highlight the first match when completeopt has the
+popup menu enabled and the 'longest' option as well. When enabled, <tab> will
+kick off completion and pre-select the first entry in the popup menu, allowing
+you to simply hit <enter> to use it.
+
+
+Mapping <cr> to end completion *supertab-crmapping*
+ *g:SuperTabCrMapping*
+
+g:SuperTabCrMapping (default value: 1)
+
+When enabled, <cr> will cancel completion mode preserving the current text.
+
+Compatibility with other plugins:
+ - endwise: compatible
+ - delimitMate: not compatible (disabled if the delimitMate <cr> mapping is
+ detected.)
+
+
+Auto close the preview window *supertab-closepreviewonpopupclose*
+ *g:SuperTabClosePreviewOnPopupClose*
+
+g:SuperTabClosePreviewOnPopupClose (default value: 0)
+
+When enabled, supertab will attempt to close vim's completion preview window
+when the completion popup closes (completion is finished or canceled).
+
+Completion Chaining *supertab-completionchaining*
+
+SuperTab provides the ability to chain one of the completion functions
+(|completefunc| or |omnifunc|) together with a one of the default vim
+completion key sequences (|ins-completion|), giving you the ability to attempt
+completion with the first, and upon no results, fall back to the second.
+
+To utilize this feature you need to call the SuperTabChain function where
+the first argument is the name of a vim compatible |complete-function| and the
+second is one of vim's insert completion (|ins-completion|) key bindings
+(<c-p>, <c-n>, <c-x><c-]>, etc). Calling this function will set the current
+buffer's |completefunc| option to a supertab provided implementation which
+utilizes the supplied arguments to perform the completion. Since the
+|completefunc| option is being set, this feature works best when also
+setting |g:SuperTabDefaultCompletionType| to either "context" or "<c-x><c-u>".
+
+Here is an example that can be added to your .vimrc which will setup the
+supertab chaining for any filetype that has a provided |omnifunc| to first
+try that, then fall back to supertab's default, <c-p>, completion:
+
+ autocmd FileType *
+ \ if &omnifunc != '' |
+ \ call SuperTabChain(&omnifunc, "<c-p>") |
+ \ call SuperTabSetDefaultCompletionType("<c-x><c-u>") |
+ \ endif
+
+Note: This feature does not support chaining any other combination of
+completions (2 or more completion functions, 2 or more key bindings, etc.). It
+can only support 1 completion function followed by 1 key binding. This is due
+to limitations imposed by vim's code completion implementation.
+
+Note: If the |completefunc| or |omnifunc| use vim's |complete_add()| instead
+of returning completion results as a list, then Supertab's completion chaining
+won't work properly with it since Supertab uses the function result to
+determine if it should fallback to the next completion type.
+
+vim:tw=78:ts=8:ft=help:norl:
View
923 bundle/supertab/plugin/supertab.vim
@@ -0,0 +1,923 @@
+" Author: Eric Van Dewoestine <ervandew@gmail.com>
+" Original concept and versions up to 0.32 written by
+" Gergely Kontra <kgergely@mcl.hu>
+" Version: 2.0
+" GetLatestVimScripts: 1643 1 :AutoInstall: supertab.vim
+"
+" Description: {{{
+" Use your tab key to do all your completion in insert mode!
+" You can cycle forward and backward with the <Tab> and <S-Tab> keys
+" Note: you must press <Tab> once to be able to cycle back
+"
+" http://www.vim.org/scripts/script.php?script_id=1643
+" }}}
+"
+" License: {{{
+" Copyright (c) 2002 - 2013
+" All rights reserved.
+"
+" Redistribution and use of this software in source and binary forms, with
+" or without modification, are permitted provided that the following
+" conditions are met:
+"
+" * Redistributions of source code must retain the above
+" copyright notice, this list of conditions and the
+" following disclaimer.
+"
+" * Redistributions in binary form must reproduce the above
+" copyright notice, this list of conditions and the
+" following disclaimer in the documentation and/or other
+" materials provided with the distribution.
+"
+" * Neither the name of Gergely Kontra or Eric Van Dewoestine nor the names
+" of its contributors may be used to endorse or promote products derived
+" from this software without specific prior written permission of Gergely
+" Kontra or Eric Van Dewoestine.
+"
+" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+" IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+" THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+" CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+" EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+" PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+" LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+" NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+" SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+" }}}
+"
+" Testing Info: {{{
+" Running vim + supertab with the absolute bare minimum settings:
+" $ vim -u NONE -U NONE -c "set nocp | runtime plugin/supertab.vim"
+" }}}
+
+if v:version < 700
+ finish
+endif
+
+if exists('complType') " Integration with other completion functions.
+ finish
+endif
+
+if exists("loaded_supertab")
+ finish
+endif
+let loaded_supertab = 1
+
+let s:save_cpo=&cpo
+set cpo&vim
+
+" Global Variables {{{
+
+ if !exists("g:SuperTabDefaultCompletionType")
+ let g:SuperTabDefaultCompletionType = "<c-p>"
+ endif
+
+ if !exists("g:SuperTabContextDefaultCompletionType")
+ let g:SuperTabContextDefaultCompletionType = "<c-p>"
+ endif
+
+ if !exists("g:SuperTabCompletionContexts")
+ let g:SuperTabCompletionContexts = ['s:ContextText']
+ endif
+
+ if !exists("g:SuperTabRetainCompletionDuration")
+ let g:SuperTabRetainCompletionDuration = 'insert'
+ endif
+
+ if !exists("g:SuperTabNoCompleteBefore")
+ " retain backwards compatability
+ if exists("g:SuperTabMidWordCompletion") && !g:SuperTabMidWordCompletion
+ let g:SuperTabNoCompleteBefore = ['\k']
+ else
+ let g:SuperTabNoCompleteBefore = []
+ endif
+ endif
+
+ if !exists("g:SuperTabNoCompleteAfter")
+ " retain backwards compatability
+ if exists("g:SuperTabLeadingSpaceCompletion") && g:SuperTabLeadingSpaceCompletion
+ let g:SuperTabNoCompleteAfter = []
+ else
+ let g:SuperTabNoCompleteAfter = ['^', '\s']
+ endif
+ endif
+
+ if !exists("g:SuperTabMappingForward")
+ let g:SuperTabMappingForward = '<tab>'
+ endif
+ if !exists("g:SuperTabMappingBackward")
+ let g:SuperTabMappingBackward = '<s-tab>'
+ endif
+
+ if !exists("g:SuperTabMappingTabLiteral")
+ let g:SuperTabMappingTabLiteral = '<c-tab>'
+ endif
+
+ if !exists("g:SuperTabLongestEnhanced")
+ let g:SuperTabLongestEnhanced = 0
+ endif
+
+ if !exists("g:SuperTabLongestHighlight")
+ let g:SuperTabLongestHighlight = 0
+ endif
+
+ if !exists("g:SuperTabCrMapping")
+ let g:SuperTabCrMapping = 1
+ endif
+
+ if !exists("g:SuperTabClosePreviewOnPopupClose")
+ let g:SuperTabClosePreviewOnPopupClose = 0
+ endif
+
+ if !exists("g:SuperTabUndoBreak")
+ let g:SuperTabUndoBreak = 0
+ endif
+
+" }}}
+
+" Script Variables {{{
+
+ " construct the help text.
+ let s:tabHelp =
+ \ "Hit <CR> or CTRL-] on the completion type you wish to switch to.\n" .
+ \ "Use :help ins-completion for more information.\n" .
+ \ "\n" .
+ \ "|<c-n>| - Keywords in 'complete' searching down.\n" .
+ \ "|<c-p>| - Keywords in 'complete' searching up (SuperTab default).\n" .
+ \ "|<c-x><c-l>| - Whole lines.\n" .
+ \ "|<c-x><c-n>| - Keywords in current file.\n" .
+ \ "|<c-x><c-k>| - Keywords in 'dictionary'.\n" .
+ \ "|<c-x><c-t>| - Keywords in 'thesaurus', thesaurus-style.\n" .
+ \ "|<c-x><c-i>| - Keywords in the current and included files.\n" .
+ \ "|<c-x><c-]>| - Tags.\n" .
+ \ "|<c-x><c-f>| - File names.\n" .
+ \ "|<c-x><c-d>| - Definitions or macros.\n" .
+ \ "|<c-x><c-v>| - Vim command-line.\n" .
+ \ "|<c-x><c-u>| - User defined completion.\n" .
+ \ "|<c-x><c-o>| - Omni completion.\n" .
+ \ "|<c-x>s| - Spelling suggestions."
+
+ " set the available completion types and modes.
+ let s:types =
+ \ "\<c-e>\<c-y>\<c-l>\<c-n>\<c-k>\<c-t>\<c-i>\<c-]>" .
+ \ "\<c-f>\<c-d>\<c-v>\<c-n>\<c-p>\<c-u>\<c-o>\<c-n>\<c-p>s"
+ let s:modes = '/^E/^Y/^L/^N/^K/^T/^I/^]/^F/^D/^V/^P/^U/^O/s'
+ let s:types = s:types . "np"
+ let s:modes = s:modes . '/n/p'
+
+" }}}
+
+function! SuperTabSetDefaultCompletionType(type) " {{{
+ " Globally available function that users can use to set the default
+ " completion type for the current buffer, like in an ftplugin.
+
+ " init hack for <c-x><c-v> workaround.
+ let b:complCommandLine = 0
+
+ let b:SuperTabDefaultCompletionType = a:type
+
+ " set the current completion type to the default
+ call SuperTabSetCompletionType(b:SuperTabDefaultCompletionType)
+endfunction " }}}
+
+function! SuperTabSetCompletionType(type) " {{{
+ " Globally available function that users can use to create mappings to quickly
+ " switch completion modes. Useful when a user wants to restore the default or
+ " switch to another mode without having to kick off a completion of that type
+ " or use SuperTabHelp. Note, this function only changes the current
+ " completion type, not the default, meaning that the default will still be
+ " restored once the configured retension duration has been met (see
+ " g:SuperTabRetainCompletionDuration). To change the default for the current
+ " buffer, use SuperTabDefaultCompletionType(type) instead. Example mapping to
+ " restore SuperTab default:
+ " nmap <F6> :call SetSuperTabCompletionType("<c-p>")<cr>
+
+ call s:InitBuffer()
+ exec "let b:complType = \"" . escape(a:type, '<') . "\""
+endfunction " }}}
+
+function! SuperTabAlternateCompletion(type) " {{{
+ " Function which can be mapped to a key to kick off an alternate completion
+ " other than the default. For instance, if you have 'context' as the default
+ " and want to map ctrl+space to issue keyword completion.
+ " Note: due to the way vim expands ctrl characters in mappings, you cannot
+ " create the alternate mapping like so:
+ " imap <c-space> <c-r>=SuperTabAlternateCompletion("<c-p>")<cr>
+ " instead, you have to use \<lt> to prevent vim from expanding the key
+ " when creating the mapping.
+ " gvim:
+ " imap <c-space> <c-r>=SuperTabAlternateCompletion("\<lt>c-p>")<cr>
+ " console:
+ " imap <nul> <c-r>=SuperTabAlternateCompletion("\<lt>c-p>")<cr>
+
+ call SuperTabSetCompletionType(a:type)
+ " end any current completion before attempting to start the new one.
+ " use feedkeys to prevent possible remapping of <c-e> from causing issues.
+ "call feedkeys("\<c-e>", 'n')
+ " ^ since we can't detect completion mode vs regular insert mode, we force
+ " vim into keyword completion mode and end that mode to prevent the regular
+ " insert behavior of <c-e> from occurring.
+ call feedkeys("\<c-x>\<c-p>\<c-e>", 'n')
+ call feedkeys(b:complType, 'n')
+ return ''
+endfunction " }}}
+
+function! SuperTabLongestHighlight(dir) " {{{
+ " When longest highlight is enabled, this function is used to do the actual
+ " selection of the completion popup entry.
+
+ if !pumvisible()
+ return ''
+ endif
+ return a:dir == -1 ? "\<up>" : "\<down>"
+endfunction " }}}
+
+function! s:Init() " {{{
+ " Setup mechanism to restore original completion type upon leaving insert
+ " mode if configured to do so
+ if g:SuperTabRetainCompletionDuration == 'insert'
+ augroup supertab_retain
+ autocmd!
+ autocmd InsertLeave * call s:SetDefaultCompletionType()
+ augroup END
+ endif
+endfunction " }}}
+
+function! s:InitBuffer() " {{{
+ if exists('b:SuperTabNoCompleteBefore')
+ return
+ endif
+
+ let b:complReset = 0
+ let b:complTypeManual = !exists('b:complTypeManual') ? '' : b:complTypeManual
+ let b:complTypeContext = ''
+
+ " init hack for <c-x><c-v> workaround.
+ let b:complCommandLine = 0
+
+ if !exists('b:SuperTabNoCompleteBefore')
+ let b:SuperTabNoCompleteBefore = g:SuperTabNoCompleteBefore
+ endif
+ if !exists('b:SuperTabNoCompleteAfter')
+ let b:SuperTabNoCompleteAfter = g:SuperTabNoCompleteAfter
+ endif
+
+ if !exists('b:SuperTabDefaultCompletionType')
+ let b:SuperTabDefaultCompletionType = g:SuperTabDefaultCompletionType
+ endif
+
+ " set the current completion type to the default
+ call SuperTabSetCompletionType(b:SuperTabDefaultCompletionType)
+
+ " hack to programatically revert a change to snipmate that breaks supertab
+ " but which the new maintainers don't care about:
+ " http://github.com/garbas/vim-snipmate/issues/37
+ let snipmate = maparg('<tab>', 'i')
+ if snipmate =~ '<C-G>u' && g:SuperTabMappingForward =~? '<tab>'
+ let snipmate = substitute(snipmate, '<C-G>u', '', '')
+ iunmap <tab>
+ exec "inoremap <silent> <tab> " . snipmate
+ endif
+endfunction " }}}
+
+function! s:ManualCompletionEnter() " {{{
+ " Handles manual entrance into completion mode.
+
+ if &smd
+ echo '' | echohl ModeMsg | echo '-- ^X++ mode (' . s:modes . ')' | echohl None
+ endif
+ let complType = nr2char(getchar())
+ if stridx(s:types, complType) != -1
+ if !exists('b:supertab_close_preview')
+ let b:supertab_close_preview = !s:IsPreviewOpen()
+ endif
+
+ if stridx("\<c-e>\<c-y>", complType) != -1 " no memory, just scroll...
+ return "\<c-x>" . complType
+ elseif stridx('np', complType) != -1
+ let complType = nr2char(char2nr(complType) - 96)
+ else
+ let complType = "\<c-x>" . complType
+ endif
+
+ let b:complTypeManual = complType
+
+ if index(['insert', 'session'], g:SuperTabRetainCompletionDuration) != -1
+ let b:complType = complType
+ endif
+
+ " Hack to workaround bug when invoking command line completion via <c-r>=
+ if complType == "\<c-x>\<c-v>"
+ return s:CommandLineCompletion()
+ endif
+
+ " optionally enable enhanced longest completion
+ if g:SuperTabLongestEnhanced && &completeopt =~ 'longest'
+ call s:EnableLongestEnhancement()
+ endif
+
+ if g:SuperTabLongestHighlight &&
+ \ &completeopt =~ 'longest' &&
+ \ &completeopt =~ 'menu' &&
+ \ !pumvisible()
+ let dir = (complType == "\<c-x>\<c-p>") ? -1 : 1
+ call feedkeys("\<c-r>=SuperTabLongestHighlight(" . dir . ")\<cr>", 'n')
+ endif
+
+ return complType
+ endif
+
+ echohl "Unknown mode"
+ return complType
+endfunction " }}}
+
+function! s:SetCompletionType() " {{{
+ " Sets the completion type based on what the user has chosen from the help
+ " buffer.
+
+ let chosen = substitute(getline('.'), '.*|\(.*\)|.*', '\1', '')
+ if chosen != getline('.')
+ let winnr = b:winnr
+ close
+ exec winnr . 'winc w'
+ call SuperTabSetCompletionType(chosen)
+ endif
+endfunction " }}}
+
+function! s:SetDefaultCompletionType() " {{{
+ if exists('b:SuperTabDefaultCompletionType') &&
+ \ (!exists('b:complCommandLine') || !b:complCommandLine)
+ call SuperTabSetCompletionType(b:SuperTabDefaultCompletionType)
+ endif
+endfunction " }}}
+
+function! SuperTab(command) " {{{
+ " Used to perform proper cycle navigation as the user requests the next or
+ " previous entry in a completion list, and determines whether or not to simply
+ " retain the normal usage of <tab> based on the cursor position.
+
+ if exists('b:SuperTabDisabled') && b:SuperTabDisabled
+ return g:SuperTabMappingForward ==? '<tab>' ? "\<tab>" : ''
+ endif
+
+ call s:InitBuffer()
+
+ if s:WillComplete()
+ if !exists('b:supertab_close_preview')
+ let b:supertab_close_preview = !s:IsPreviewOpen()
+ endif
+
+ " optionally enable enhanced longest completion
+ if g:SuperTabLongestEnhanced && &completeopt =~ 'longest'
+ call s:EnableLongestEnhancement()
+ endif
+
+ if !pumvisible()
+ let b:complTypeManual = ''
+ endif
+
+ " exception: if in <c-p> mode, then <c-n> should move up the list, and
+ " <c-p> down the list.
+ if a:command == 'p' && !b:complReset &&
+ \ (b:complType == "\<c-p>" ||
+ \ (b:complType == 'context' &&
+ \ b:complTypeManual == '' &&
+ \ b:complTypeContext == "\<c-p>"))
+ return "\<c-n>"
+
+ elseif a:command == 'p' && !b:complReset &&
+ \ (b:complType == "\<c-n>" ||
+ \ (b:complType == 'context' &&
+ \ b:complTypeManual == '' &&
+ \ b:complTypeContext == "\<c-n>"))
+ return "\<c-p>"
+
+ " already in completion mode and not resetting for longest enhancement, so
+ " just scroll to next/previous
+ elseif pumvisible() && !b:complReset
+ let type = b:complType == 'context' ? b:complTypeContext : b:complType
+ if a:command == 'n'
+ return type == "\<c-p>" ? "\<c-p>" : "\<c-n>"
+ endif
+ return type == "\<c-p>" ? "\<c-n>" : "\<c-p>"
+ endif
+
+ " handle 'context' completion.
+ if b:complType == 'context'
+ let complType = s:ContextCompletion()
+ if complType == ''
+ exec "let complType = \"" .
+ \ escape(g:SuperTabContextDefaultCompletionType, '<') . "\""
+ endif
+ let b:complTypeContext = complType
+
+ " Hack to workaround bug when invoking command line completion via <c-r>=
+ elseif b:complType == "\<c-x>\<c-v>"
+ let complType = s:CommandLineCompletion()
+ else
+ let complType = b:complType
+ endif
+
+ " highlight first result if longest enabled
+ if g:SuperTabLongestHighlight &&
+ \ &completeopt =~ 'longest' &&
+ \ &completeopt =~ 'menu' &&
+ \ (!pumvisible() || b:complReset)
+ let dir = (complType == "\<c-p>") ? -1 : 1
+ call feedkeys("\<c-r>=SuperTabLongestHighlight(" . dir . ")\<cr>", 'n')
+ endif
+
+ if b:complReset
+ let b:complReset = 0
+ " not an accurate condition for everyone, but better than sending <c-e>
+ " at the wrong time.
+ if pumvisible()
+ return "\<c-e>" . complType
+ endif
+ endif
+
+ if g:SuperTabUndoBreak && !pumvisible()
+ return "\<c-g>u" . complType
+ endif
+
+ return complType
+ endif
+
+ return g:SuperTabMappingForward ==? '<tab>' ? "\<tab>" : ''
+endfunction " }}}
+
+function! s:SuperTabHelp() " {{{
+ " Opens a help window where the user can choose a completion type to enter.
+
+ let winnr = winnr()
+ if bufwinnr("SuperTabHelp") == -1
+ botright split SuperTabHelp
+
+ setlocal noswapfile
+ setlocal buftype=nowrite
+ setlocal bufhidden=delete
+
+ let saved = @"
+ let @" = s:tabHelp
+ silent put
+ call cursor(1, 1)
+ silent 1,delete
+ call cursor(4, 1)
+ let @" = saved
+ exec "resize " . line('$')
+
+ syntax match Special "|.\{-}|"
+
+ setlocal readonly
+ setlocal nomodifiable
+
+ nmap <silent> <buffer> <cr> :call <SID>SetCompletionType()<cr>
+ nmap <silent> <buffer> <c-]> :call <SID>SetCompletionType()<cr>
+ else
+ exec bufwinnr("SuperTabHelp") . "winc w"
+ endif
+ let b:winnr = winnr
+endfunction " }}}
+
+function! s:WillComplete() " {{{
+ " Determines if completion should be kicked off at the current location.
+
+ if pumvisible()
+ return 1
+ endif
+
+ let line = getline('.')
+ let cnum = col('.')
+
+ " honor SuperTabNoCompleteAfter
+ let pre = cnum >= 2 ? line[:cnum - 2] : ''
+ let complAfterType = type(b:SuperTabNoCompleteAfter)
+ if complAfterType == 3
+ " the option was provided as a list of patterns
+ for pattern in b:SuperTabNoCompleteAfter
+ if pre =~ pattern . '$'
+ return 0
+ endif
+ endfor
+ elseif complAfterType == 2
+ " the option was provided as a funcref
+ return !b:SuperTabNoCompleteAfter(pre)
+ endif
+
+ " honor SuperTabNoCompleteBefore
+ " Within a word, but user does not have mid word completion enabled.
+ let post = line[cnum - 1:]
+ let complBeforeType = type(b:SuperTabNoCompleteBefore)
+ if complBeforeType == 3
+ " a list of patterns
+ for pattern in b:SuperTabNoCompleteBefore
+ if post =~ '^' . pattern
+ return 0
+ endif
+ endfor
+ elseif complBeforeType == 2
+ " the option was provided as a funcref
+ return !b:SuperTabNoCompleteBefore(post)
+ endif
+
+ return 1
+endfunction " }}}
+
+function! s:EnableLongestEnhancement() " {{{
+ augroup supertab_reset
+ autocmd!
+ autocmd InsertLeave,CursorMovedI <buffer>
+ \ call s:ReleaseKeyPresses() | autocmd! supertab_reset
+ augroup END
+ call s:CaptureKeyPresses()
+endfunction " }}}
+
+function! s:CompletionReset(char) " {{{
+ let b:complReset = 1
+ return a:char
+endfunction " }}}
+
+function! s:CaptureKeyPresses() " {{{
+ if !exists('b:capturing') || !b:capturing
+ let b:capturing = 1
+ let b:capturing_start = col('.')
+ " save any previous mappings
+ " TODO: capture additional info provided by vim 7.3.032 and up.
+ let b:captured = {
+ \ '<bs>': maparg('<bs>', 'i'),
+ \ '<c-h>': maparg('<c-h>', 'i'),
+ \ }
+ " TODO: use &keyword to get an accurate list of chars to map
+ for c in split('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_', '.\zs')
+ exec 'imap <buffer> ' . c . ' <c-r>=<SID>CompletionReset("' . c . '")<cr>'
+ endfor
+ imap <buffer> <bs> <c-r>=<SID>CompletionReset("\<lt>bs>")<cr>
+ imap <buffer> <c-h> <c-r>=<SID>CompletionReset("\<lt>c-h>")<cr>
+ endif
+endfunction " }}}
+
+function! s:IsPreviewOpen() " {{{
+ let wins = tabpagewinnr(tabpagenr(), '$')
+ let winnr = 1
+ while winnr <= wins
+ if getwinvar(winnr, '&previewwindow') == 1
+ return 1
+ endif
+ let winnr += 1
+ endwhile
+ return 0
+endfunction " }}}
+
+function! s:ClosePreview() " {{{
+ if exists('b:supertab_close_preview') && b:supertab_close_preview
+ let preview = 0
+ for bufnum in tabpagebuflist()
+ if getwinvar(bufwinnr(bufnum), '&previewwindow')
+ let preview = 1
+ break
+ endif
+ endfor
+ if preview
+ pclose
+ try
+ doautocmd <nomodeline> supertab_preview_closed User <supertab>
+ catch /E216/
+ " ignore: no autocmds defined
+ endtry
+ endif
+ endif
+ silent! unlet b:supertab_close_preview
+endfunction " }}}
+
+function! s:ReleaseKeyPresses() " {{{
+ if exists('b:capturing') && b:capturing
+ let b:capturing = 0
+ for c in split('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_', '.\zs')
+ exec 'iunmap <buffer> ' . c
+ endfor
+
+ iunmap <buffer> <bs>
+ iunmap <buffer> <c-h>
+
+ " restore any previous mappings
+ for [key, rhs] in items(b:captured)
+ if rhs != ''
+ let args = substitute(rhs, '.*\(".\{-}"\).*', '\1', '')
+ if args != rhs
+ let args = substitute(args, '<', '<lt>', 'g')
+ let expr = substitute(rhs, '\(.*\)".\{-}"\(.*\)', '\1%s\2', '')
+ let rhs = printf(expr, args)
+ endif
+ exec printf("imap <silent> %s %s", key, rhs)
+ endif
+ endfor
+ unlet b:captured
+
+ if mode() == 'i' && &completeopt =~ 'menu' && b:capturing_start != col('.')
+ " force full exit from completion mode (don't exit insert mode since
+ " that will break repeating with '.')
+ call feedkeys("\<space>\<bs>", 'n')
+ endif
+ unlet b:capturing_start
+ endif
+endfunction " }}}
+
+function! s:CommandLineCompletion() " {{{
+ " Hack needed to account for apparent bug in vim command line mode completion
+ " when invoked via <c-r>=
+
+ " This hack will trigger InsertLeave which will then invoke
+ " s:SetDefaultCompletionType. To prevent default completion from being
+ " restored prematurely, set an internal flag for s:SetDefaultCompletionType
+ " to check for.
+ let b:complCommandLine = 1
+ return "\<c-\>\<c-o>:call feedkeys('\<c-x>\<c-v>\<c-v>', 'n') | " .
+ \ "let b:complCommandLine = 0\<cr>"
+endfunction " }}}
+
+function! s:ContextCompletion() " {{{
+ let contexts = exists('b:SuperTabCompletionContexts') ?
+ \ b:SuperTabCompletionContexts : g:SuperTabCompletionContexts
+
+ for context in contexts
+ try
+ let Context = function(context)
+ let complType = Context()
+ unlet Context
+ if type(complType) == 1 && complType != ''
+ return complType
+ endif
+ catch /E700/
+ echohl Error
+ echom 'supertab: no context function "' . context . '" found.'
+ echohl None
+ endtry
+ endfor
+ return ''
+endfunction " }}}
+
+function! s:ContextDiscover() " {{{
+ let discovery = exists('g:SuperTabContextDiscoverDiscovery') ?
+ \ g:SuperTabContextDiscoverDiscovery : []
+
+ " loop through discovery list to find the default
+ if !empty(discovery)
+ for pair in discovery
+ let var = substitute(pair, '\(.*\):.*', '\1', '')
+ let type = substitute(pair, '.*:\(.*\)', '\1', '')
+ exec 'let value = ' . var
+ if value !~ '^\s*$' && value != '0'
+ exec "let complType = \"" . escape(type, '<') . "\""
+ return complType
+ endif
+ endfor
+ endif
+endfunction " }}}
+
+function! s:ContextText() " {{{
+ let exclusions = exists('g:SuperTabContextTextFileTypeExclusions') ?
+ \ g:SuperTabContextTextFileTypeExclusions : []
+
+ if index(exclusions, &ft) == -1
+ let curline = getline('.')
+ let cnum = col('.')
+ let synname = synIDattr(synID(line('.'), cnum - 1, 1), 'name')
+ if curline =~ '.*/\w*\%' . cnum . 'c' ||
+ \ ((has('win32') || has('win64')) && curline =~ '.*\\\w*\%' . cnum . 'c')
+ return "\<c-x>\<c-f>"
+
+ elseif curline =~ '.*\(\w\|[\])]\)\(\.\|>\?::\|->\)\w*\%' . cnum . 'c' &&
+ \ synname !~ '\(String\|Comment\)'
+ let omniPrecedence = exists('g:SuperTabContextTextOmniPrecedence') ?
+ \ g:SuperTabContextTextOmniPrecedence : ['&completefunc', '&omnifunc']
+
+ for omniFunc in omniPrecedence
+ if omniFunc !~ '^&'
+ let omniFunc = '&' . omniFunc
+ endif
+ if getbufvar(bufnr('%'), omniFunc) != ''
+ return omniFunc == '&omnifunc' ? "\<c-x>\<c-o>" : "\<c-x>\<c-u>"
+ endif
+ endfor
+ endif
+ endif
+endfunction " }}}
+
+function! s:ExpandMap(map) " {{{
+ let map = a:map
+ if map =~ '<Plug>'
+ let plug = substitute(map, '.\{-}\(<Plug>\w\+\).*', '\1', '')
+ let plug_map = maparg(plug, 'i')
+ let map = substitute(map, '.\{-}\(<Plug>\w\+\).*', plug_map, '')
+ endif
+ return map
+endfunction " }}}
+
+function! SuperTabChain(completefunc, completekeys) " {{{
+ if a:completefunc != 'SuperTabCodeComplete'
+ let b:SuperTabChain = [a:completefunc, a:completekeys]
+ setlocal completefunc=SuperTabCodeComplete
+ endif
+endfunction " }}}
+
+function! SuperTabCodeComplete(findstart, base) " {{{
+ if !exists('b:SuperTabChain')
+ echoe 'No completion chain has been set.'
+ return -2
+ endif
+
+ if len(b:SuperTabChain) != 2
+ echoe 'Completion chain can only be used with 1 completion function ' .
+ \ 'and 1 fallback completion key binding.'
+ return -2
+ endif
+
+ let Func = function(b:SuperTabChain[0])
+
+ if a:findstart
+ let start = Func(a:findstart, a:base)
+ if start >= 0
+ return start
+ endif
+
+ return col('.') - 1
+ endif
+
+ let results = Func(a:findstart, a:base)
+ if len(results)
+ return results
+ endif
+
+ exec 'let keys = "' . escape(b:SuperTabChain[1], '<') . '"'
+ call feedkeys("\<c-e>" . keys, 'nt')
+ return []
+endfunction " }}}
+
+" Autocmds {{{
+ if g:SuperTabClosePreviewOnPopupClose
+ augroup supertab_close_preview
+ autocmd!
+ autocmd InsertLeave,CursorMovedI * call s:ClosePreview()
+ augroup END
+ endif
+" }}}
+
+" Key Mappings {{{
+ " map a regular tab to ctrl-tab (note: doesn't work in console vim)
+ exec 'inoremap ' . g:SuperTabMappingTabLiteral . ' <tab>'
+
+ imap <c-x> <c-r>=<SID>ManualCompletionEnter()<cr>
+
+ imap <script> <Plug>SuperTabForward <c-r>=SuperTab('n')<cr>
+ imap <script> <Plug>SuperTabBackward <c-r>=SuperTab('p')<cr>
+
+ exec 'imap ' . g:SuperTabMappingForward . ' <Plug>SuperTabForward'
+ exec 'imap ' . g:SuperTabMappingBackward . ' <Plug>SuperTabBackward'
+
+ " After hitting <Tab>, hitting it once more will go to next match
+ " (because in XIM mode <c-n> and <c-p> mappings are ignored)
+ " and wont start a brand new completion
+ " The side effect, that in the beginning of line <c-n> and <c-p> inserts a
+ " <Tab>, but I hope it may not be a problem...
+ let ctrl_n = maparg('<c-n>', 'i')
+ if ctrl_n != ''
+ let ctrl_n = substitute(ctrl_n, '<', '<lt>', 'g')
+ exec 'imap <c-n> <c-r>=<SID>ForwardBack("n", "' . ctrl_n . '")<cr>'
+ else
+ imap <c-n> <Plug>SuperTabForward
+ endif
+ let ctrl_p = maparg('<c-p>', 'i')
+ if ctrl_p != ''
+ let ctrl_p = substitute(ctrl_p, '<', '<lt>', 'g')
+ exec 'imap <c-p> <c-r>=<SID>ForwardBack("p", "' . ctrl_p . '")<cr>'
+ else
+ imap <c-p> <Plug>SuperTabBackward
+ endif
+ function! s:ForwardBack(command, map)
+ exec "let map = \"" . escape(a:map, '<') . "\""
+ return pumvisible() ? SuperTab(a:command) : map
+ endfunction
+
+ if g:SuperTabCrMapping
+ let expr_map = 0
+ if v:version > 703 || (v:version == 703 && has('patch32'))
+ let map_dict = maparg('<cr>', 'i', 0, 1)
+ let expr_map = has_key(map_dict, 'expr') && map_dict.expr
+ else
+ let expr_map = maparg('<cr>', 'i') =~? '\<cr>'
+ endif
+
+ if expr_map
+ " Not compatible w/ expr mappings. This is most likely a user mapping,
+ " typically with the same functionality anyways.
+ elseif maparg('<CR>', 'i') =~ '<Plug>delimitMateCR'
+ " Not compatible w/ delimitMate since it doesn't play well with others
+ " and will always return a <cr> which we don't want when selecting a
+ " completion.
+ elseif maparg('<CR>','i') =~ '<CR>'
+ let map = maparg('<cr>', 'i')
+ let cr = (map =~? '\(^\|[^)]\)<cr>')
+ let map = s:ExpandMap(map)
+ exec "inoremap <script> <cr> <c-r>=<SID>SelectCompletion(" . cr . ")<cr>" . map
+ else
+ inoremap <cr> <c-r>=<SID>SelectCompletion(1)<cr>
+ endif
+ function! s:SelectCompletion(cr)
+ " selecting a completion
+ if pumvisible()
+ " ugly hack to let other <cr> mappings for other plugins cooperate
+ " with supertab
+ let b:supertab_pumwasvisible = 1
+
+ " close the preview window if configured to do so
+ if &completeopt =~ 'preview' && g:SuperTabClosePreviewOnPopupClose
+ if !exists('b:supertab_close_preview')
+ let b:supertab_close_preview = !s:IsPreviewOpen()
+ endif
+ call s:ClosePreview()
+ endif
+
+ return "\<c-y>"
+ endif
+
+ " only needed when chained with other mappings and one of them will
+ " issue a <cr>.
+ if exists('b:supertab_pumwasvisible') && !a:cr
+ unlet b:supertab_pumwasvisible
+ return ''
+ endif
+
+ " not so pleasant hack to keep <cr> working for abbreviations
+ let word = substitute(getline('.'), '^.*\s\+\(.*\%' . col('.') . 'c\).*', '\1', '')
+ let result = maparg(word, 'i', 1)
+ if result != ''
+ let bs = ""
+ let i = 0
+ while i < len(word)
+ let bs .= "\<bs>"
+ let i += 1
+ endwhile
+ " escape keys
+ let result = substitute(result, '\(<[a-zA-Z][-a-zA-Z]*>\)', '\\\1', 'g')
+ " ensure escaped keys are properly recognized
+ exec 'let result = "' . escape(result, '"') . '"'
+ return bs . result . (a:cr ? "\<cr>" : "")
+ endif
+
+ " only return a cr if nothing else is mapped to it since we don't want
+ " to duplicate a cr returned by another mapping.
+ return a:cr ? "\<cr>" : ""
+ endfunction
+ endif
+" }}}
+
+" Command Mappings {{{
+ if !exists(":SuperTabHelp")
+ command SuperTabHelp :call <SID>SuperTabHelp()
+ endif
+" }}}
+
+call s:Init()
+
+function! TestSuperTabCodeComplete(findstart, base) " {{{
+ " Test supertab completion chaining w/ a minimal vim environment:
+ " $ vim -u NONE -U NONE \
+ " --cmd "set nocp | sy on" \
+ " -c "so ~/.vim/plugin/supertab.vim" \
+ " -c "let g:SuperTabDefaultCompletionType = '<c-x><c-u>'" \
+ " -c "set completefunc=TestSuperTabCodeComplete" \
+ " -c "call SuperTabChain(&completefunc, '<c-p>')"
+ if a:findstart
+ let line = getline('.')
+ let start = col('.') - 1
+ if line[start] =~ '\.'
+ let start -= 1
+ endif
+ while start > 0 && line[start - 1] =~ '\w'
+ let start -= 1
+ endwhile
+ return start
+ else
+ let completions = []
+ if getline('.') =~ 'TestC'
+ call add(completions, {
+ \ 'word': 'test1(',
+ \ 'kind': 'm',
+ \ 'menu': 'test1(...)',
+ \ })
+ call add(completions, {
+ \ 'word': 'testing2(',
+ \ 'kind': 'm',
+ \ 'menu': 'testing2(...)',
+ \ })
+ endif
+
+ return completions
+ endif
+endfunction " }}}
+
+let &cpo = s:save_cpo
+
+" vim:ft=vim:fdm=marker
2  bundle/syntastic
@@ -1 +1 @@
-Subproject commit cfd41f1ca368c2a3c9f5dce671a43af0662bf022
+Subproject commit 182b3f01c09d70471bf073817b8231d1eddd41c2
2  bundle/vim-coffee-script
@@ -1 +1 @@
-Subproject commit d6dcb9b0fb5beac9e84cfb84c1917b7e0df5850f
+Subproject commit 089506ed89da1849485fdfcca002a42111759fab
2  bundle/vim-fugitive
@@ -1 +1 @@
-Subproject commit 6515bd43acc28c86fcf3bea64ce8a6b3d7db19ff
+Subproject commit 0103538d7a8e03c061c031e33459aeaa4cf040ab
View
60 bundle/vim-gitgutter/README.mkd
@@ -0,0 +1,60 @@
+## Vim Git Gutter
+
+A Vim plugin which shows a git diff in the 'gutter' (sign column). It shows whether each line has been added, modified, and where lines have been removed.
+
+This is a port of the [Git Gutter][st2gg] plugin for Sublime Text 2.
+
+
+### Screenshot
+
+![screenshot](https://raw.github.com/airblade/vim-gitgutter/master/screenshot.png)
+
+In the screenshot above you can see:
+
+* Line 15 has been modified.
+* Lines 21-24 are new.
+* A line or lines were removed between lines 25 and 26.
+
+
+### Installation
+
+If you don't have a preferred installation method, I recommend installing [pathogen.vim][pathogen], and then simply copy and paste:
+
+```
+cd ~/.vim/bundle
+git clone git://github.com/airblade/vim-gitgutter.git
+```
+
+
+### FAQ
+
+> The colours in the sign column are weird.
+
+The syntax highlighting for your sign column is probably set strangely. Either modify your colorscheme or add this to your `~/.vimrc`:
+
+```
+highlight clear SignColumn
+```
+
+> Lines removed below a modified line are not shown.
+
+True. This plugin uses Vim's signs which require a sign to be on a line (not between two lines) and only permit one sign per line. Removed lines are signed with an underscore on the line above. If that line has also been modified, the plugin has to choose whether to show the removed-lines sign or the modified-line sign. It prefers the latter.
+
+
+### Alternatives
+
+I'm not aware of any other Vim plugins which (only) show git diffs in the gutter. However these may be of interest:
+
+* [quickfixsigns_vim][qf] has a large superset of this functionality.
+* [fugitive.vim][fugitive] is a full-on Git wrapper. It doesn't show git diffs in the gutter (ha!) but it does a bazillion other git things.
+
+
+### Intellectual Property
+
+Copyright Andrew Stewart, AirBlade Software Ltd. Released under the MIT licence.
+
+
+ [st2gg]: https://github.com/jisaacks/GitGutter
+ [pathogen]: https://github.com/tpope/vim-pathogen
+ [qf]: https://github.com/tomtom/quickfixsigns_vim
+ [fugitive]: https://github.com/tpope/vim-fugitive
View
237 bundle/vim-gitgutter/plugin/gitgutter.vim
@@ -0,0 +1,237 @@
+if exists('g:loaded_gitgutter') || !executable('git') || &cp
+ finish
+endif
+let g:loaded_gitgutter = 1
+
+" Initialisation {{{
+
+function! s:init()
+ if !exists('g:gitgutter_initialised')
+ call s:define_highlights()
+ call s:define_signs()
+
+ " Vim doesn't namespace sign ids so every plugin shares the same
+ " namespace. Sign ids are simply integers so to avoid clashes with other
+ " signs we guess at a clear run.
+ "
+ " Note also we currently never reset s:next_sign_id.
+ let s:first_sign_id = 3000
+ let s:next_sign_id = s:first_sign_id
+ let s:sign_ids = {} " key: filename, value: list of sign ids
+ let s:other_signs = []
+
+ let g:gitgutter_initialised = 1
+ endif
+endfunction
+
+function! s:define_highlights()
+ highlight lineAdded guifg=#009900 guibg=NONE ctermfg=2 ctermbg=NONE
+ highlight lineModified guifg=#bbbb00 guibg=NONE ctermfg=3 ctermbg=NONE
+ highlight lineRemoved guifg=#ff2222 guibg=NONE ctermfg=1 ctermbg=NONE
+endfunction
+
+function! s:define_signs()
+ sign define GitGutterLineAdded text=+ texthl=lineAdded
+ sign define GitGutterLineModified text=~ texthl=lineModified
+ sign define GitGutterLineRemoved text=_ texthl=lineRemoved
+endfunction
+
+" }}}
+
+" Utility {{{
+
+function! s:current_file()
+ return expand("%:p")
+endfunction
+
+function! s:exists_current_file()
+ return strlen(s:current_file()) > 0
+endfunction
+
+function! s:directory_of_current_file()
+ return expand("%:p:h")
+endfunction
+
+function! s:command_in_directory_of_current_file(cmd)
+ return 'cd ' . s:directory_of_current_file() . ' && ' . a:cmd
+endfunction
+
+function! s:is_in_a_git_repo()
+ let cmd = 'git rev-parse > /dev/null 2>&1'
+ call system(s:command_in_directory_of_current_file(cmd))
+ return !v:shell_error
+endfunction
+
+function! s:is_tracked_by_git()
+ let cmd = 'git ls-files --error-unmatch > /dev/null 2>&1 ' . shellescape(s:current_file())
+ call system(s:command_in_directory_of_current_file(cmd))
+ return !v:shell_error
+endfunction
+
+" }}}
+
+" Diff processing {{{
+
+function! s:run_diff()
+ let cmd = 'git diff --no-ext-diff -U0 ' . shellescape(s:current_file()) .
+ \ ' | grep -e "^@@ "'
+ let diff = system(s:command_in_directory_of_current_file(cmd))
+ return diff
+endfunction
+
+function! s:parse_diff(diff)
+ let hunk_re = '^@@ -\(\d\+\),\?\(\d*\) +\(\d\+\),\?\(\d*\) @@'
+ let hunks = []
+ for line in split(a:diff, '\n')
+ let matches = matchlist(line, hunk_re)
+ let from_line = str2nr(matches[1])
+ let from_count = (matches[2] == '') ? 1 : str2nr(matches[2])
+ let to_line = str2nr(matches[3])
+ let to_count = (matches[4] == '') ? 1 : str2nr(matches[4])
+ call add(hunks, [from_line, from_count, to_line, to_count])
+ endfor
+ return hunks
+endfunction
+
+function! s:process_hunks(hunks)
+ let modified_lines = []
+ for hunk in a:hunks
+ call extend(modified_lines, s:process_hunk(hunk))
+ endfor
+ return modified_lines
+endfunction
+
+function! s:process_hunk(hunk)
+ let modifications = []
+ let from_line = a:hunk[0]
+ let from_count = a:hunk[1]
+ let to_line = a:hunk[2]
+ let to_count = a:hunk[3]
+ if s:is_added(from_count, to_count)
+ let offset = 0
+ while offset < to_count
+ let line_number = to_line + offset
+ call add(modifications, [line_number, 'added'])
+ let offset += 1
+ endwhile
+ elseif s:is_removed(from_count, to_count)
+ " removed lines came after `to_line`.
+ call add(modifications, [to_line, 'removed'])
+ else " modified
+ let offset = 0
+ while offset < to_count
+ let line_number = to_line + offset
+ call add(modifications, [line_number, 'modified'])
+ let offset += 1
+ endwhile
+ endif
+ return modifications
+endfunction
+
+function! s:is_added(from_count, to_count)
+ return a:from_count == 0 && a:to_count > 0
+endfunction
+
+function! s:is_removed(from_count, to_count)
+ return a:from_count > 0 && a:to_count == 0
+endfunction
+
+" }}}
+
+" Sign processing {{{
+
+function! s:clear_signs(file_name)
+ if has_key(s:sign_ids, a:file_name)
+ for id in s:sign_ids[a:file_name]
+ exe ":sign unplace " . id . " file=" . a:file_name
+ endfor
+ let s:sign_ids[a:file_name] = []
+ endif
+endfunction
+
+" This assumes there are no GitGutter signs in the current file.
+" If this is untenable we could change the regexp to exclude GitGutter's
+" signs.
+function! s:find_other_signs(file_name)
+ redir => signs
+ silent exe ":sign place file=" . a:file_name
+ redir END
+ let s:other_signs = []
+ for sign_line in split(signs, '\n')
+ if sign_line =~ '^\s\+line'
+ let matches = matchlist(sign_line, '^\s\+line=\(\d\+\)')
+ let line_number = str2nr(matches[1])
+ call add(s:other_signs, line_number)
+ endif
+ endfor
+endfunction
+
+function! s:show_signs(file_name, modified_lines)
+ for line in a:modified_lines
+ let line_number = line[0]
+ let type = line[1]
+ " TODO: eugh
+ if type ==? 'added'
+ let name = 'GitGutterLineAdded'
+ elseif type ==? 'removed'
+ let name = 'GitGutterLineRemoved'
+ elseif type ==? 'modified'
+ let name = 'GitGutterLineModified'
+ endif
+ call s:add_sign(line_number, name, a:file_name)
+ endfor
+endfunction
+
+function! s:add_sign(line_number, name, file_name)
+ let id = s:next_sign_id()
+ if !s:is_other_sign(a:line_number) " Don't clobber other people's signs.
+ exe ":sign place " . id . " line=" . a:line_number . " name=" . a:name . " file=" . a:file_name
+ call s:remember_sign(id, a:file_name)
+ endif
+endfunction
+
+function! s:next_sign_id()
+ let next_id = s:next_sign_id
+ let s:next_sign_id += 1
+ return next_id
+endfunction
+
+function! s:remember_sign(id, file_name)
+ if has_key(s:sign_ids, a:file_name)
+ let sign_ids_for_current_file = s:sign_ids[a:file_name]
+ call add(sign_ids_for_current_file, a:id)
+ else
+ let sign_ids_for_current_file = [a:id]
+ endif
+ let s:sign_ids[a:file_name] = sign_ids_for_current_file
+endfunction
+
+function! s:is_other_sign(line_number)
+ return index(s:other_signs, a:line_number) == -1 ? 0 : 1
+endfunction
+
+" }}}
+
+" Public interface {{{
+
+function! GitGutter()
+ if s:exists_current_file() && s:is_in_a_git_repo() && s:is_tracked_by_git()
+ call s:init()
+ let diff = s:run_diff()
+ let hunks = s:parse_diff(diff)
+ let modified_lines = s:process_hunks(hunks)
+ let file_name = s:current_file()
+ call s:clear_signs(file_name)
+ call s:find_other_signs(file_name)
+ call s:show_signs(file_name, modified_lines)
+ endif
+endfunction
+
+augroup gitgutter
+ autocmd!
+ autocmd BufReadPost,BufWritePost,FileReadPost,FileWritePost * call GitGutter()
+augroup END
+
+" }}}
+
+" vim:set et sw=2 fdm=marker:
View
BIN  bundle/vim-gitgutter/screenshot.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2  bundle/vim-golang
@@ -1 +1 @@
-Subproject commit a6065526042591e67c0d460bdf06ad9e79f57b24
+Subproject commit b63f8e84af8d5f9c29609da8c82b3628b86d5164
View
7 bundle/vim-literate-coffeescript/LICENSE
@@ -0,0 +1,7 @@
+Copyright (c) 2013 Michael Smith
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
56 bundle/vim-literate-coffeescript/README.md
@@ -0,0 +1,56 @@
+`vim-literate-coffeescript` adds syntax highlighting and indentation support for
+[Literate CoffeeScript](http://coffeescript.org/#literate) to the vim text
+editor.
+
+It looks something like this:
+
+![Preview](test/test.png)
+
+# Dependencies
+
+You must have syntax highlighting installed for both
+[Markdown](https://github.com/tpope/vim-markdown) and
+[CoffeeScript](https://github.com/kchmck/vim-coffee-script) installed to use
+this package.
+
+# Installation
+
+## Manually
+
+ 1. Clone this repository.
+
+ git clone https://github.com/mintplant/vim-literate-coffeescript.git
+
+ 2. Copy all the vim-specific files into your ~/.vim folder.
+
+ cp -r vim-literate-coffeescript/ftdetect/ ~/.vim/
+ cp -r vim-literate-coffeescript/indent/ ~/.vim/
+ cp -r vim-literate-coffeescript/syntax/ ~/.vim/
+
+## With Pathogen
+
+### Setup
+
+ 1. Install [Pathogen](http://www.vim.org/scripts/script.php?script_id=2332)
+
+ 2. Change directory to your bundle folder.
+
+ cd ~/.vim/bundle
+
+ 3. Clone this repository.
+
+ git clone https://github.com/mintplant/vim-literate-coffeescript.git
+
+### Updating
+
+ 1. Change directory to where the repository was cloned.
+
+ cd ~/.vim/bundle/vim-literate-coffeescript/
+
+ 2. Pull in the latest changes.
+
+ git pull
+
+# License
+
+[MIT](LICENSE)
View
7 bundle/vim-literate-coffeescript/ftdetect/litcoffee.vim
@@ -0,0 +1,7 @@
+" Language: Literate CoffeeScript
+" Maintainer: Michael Smith <michael@diglumi.com>
+" URL: https://github.com/mintplant/vim-literate-coffeescript
+" License: MIT
+
+autocmd BufNewFile,BufRead *.litcoffee set filetype=litcoffee
+
View
22 bundle/vim-literate-coffeescript/indent/litcoffee.vim
@@ -0,0 +1,22 @@
+if exists('b:did_indent')
+ finish
+endif
+
+runtime! indent/coffee.vim
+
+let b:did_indent = 1
+
+setlocal indentexpr=GetLitCoffeeIndent()
+
+if exists('*GetLitCoffeeIndent')
+ finish
+endif
+
+function GetLitCoffeeIndent()
+ if searchpair('^ \|\t', '', '$', 'bWnm') > 0
+ return GetCoffeeIndent(v:lnum)
+ else
+ return -1
+ endif
+endfunc
+
View
17 bundle/vim-literate-coffeescript/syntax/litcoffee.vim
@@ -0,0 +1,17 @@
+" Language: Literate CoffeeScript
+" Maintainer: Michael Smith <michael@diglumi.com>
+" URL: https://github.com/mintplant/vim-literate-coffeescript
+" License: MIT
+
+runtime! syntax/markdowm.vim
+
+if exists('b:current_syntax') && b:current_syntax == 'litcoffee'
+ finish
+endif
+
+syn include @markdown syntax/markdown.vim
+syn include @coffee syntax/coffee.vim
+
+syn region commentMarkdown start='^' end='$' contains=@markdown
+syn region inlineCoffee start='^ \|\t' end='$' contains=@coffee
+
View
117 bundle/vim-literate-coffeescript/test/test.litcoffee
@@ -0,0 +1,117 @@
+The **Scope** class regulates lexical scoping within CoffeeScript. As you
+generate code, you create a tree of scopes in the same shape as the nested
+function bodies. Each scope knows about the variables declared within it,
+and has a reference to its parent enclosing scope. In this way, we know which
+variables are new and need to be declared with `var`, and which are shared
+with external scopes.
+
+Import the helpers we plan to use.
+
+ {extend, last} = require './helpers'
+
+ exports.Scope = class Scope
+
+The `root` is the top-level **Scope** object for a given file.
+
+ @root: null
+
+Initialize a scope with its parent, for lookups up the chain,
+as well as a reference to the **Block** node it belongs to, which is
+where it should declare its variables, and a reference to the function that
+it belongs to.
+
+ constructor: (@parent, @expressions, @method) ->
+ @variables = [{name: 'arguments', type: 'arguments'}]
+ @positions = {}
+ Scope.root = this unless @parent
+
+Adds a new variable or overrides an existing one.
+
+ add: (name, type, immediate) ->
+ return @parent.add name, type, immediate if @shared and not immediate
+ if Object::hasOwnProperty.call @positions, name
+ @variables[@positions[name]].type = type
+ else
+ @positions[name] = @variables.push({name, type}) - 1
+
+When `super` is called, we need to find the name of the current method we're
+in, so that we know how to invoke the same method of the parent class. This
+can get complicated if super is being called from an inner function.
+`namedMethod` will walk up the scope tree until it either finds the first
+function object that has a name filled in, or bottoms out.
+
+ namedMethod: ->
+ return @method if @method.name or !@parent
+ @parent.namedMethod()
+
+Look up a variable name in lexical scope, and declare it if it does not
+already exist.
+
+ find: (name) ->
+ return yes if @check name
+ @add name, 'var'
+ no
+
+Reserve a variable name as originating from a function parameter for this
+scope. No `var` required for internal references.
+
+ parameter: (name) ->
+ return if @shared and @parent.check name, yes
+ @add name, 'param'
+
+Just check to see if a variable has already been declared, without reserving,
+walks up to the root scope.
+
+ check: (name) ->
+ !!(@type(name) or @parent?.check(name))
+
+Generate a temporary variable name at the given index.
+
+ temporary: (name, index) ->
+ if name.length > 1
+ '_' + name + if index > 1 then index - 1 else ''
+ else
+ '_' + (index + parseInt name, 36).toString(36).replace /\d/g, 'a'