Skip to content

Commit

Permalink
Update vimrc
Browse files Browse the repository at this point in the history
  • Loading branch information
oscardelben committed May 2, 2012
1 parent 9f16d79 commit d6170ff
Show file tree
Hide file tree
Showing 13 changed files with 212 additions and 85 deletions.
11 changes: 3 additions & 8 deletions .vim/.netrwhist
@@ -1,9 +1,4 @@
let g:netrw_dirhistmax =10
let g:netrw_dirhist_cnt =7
let g:netrw_dirhist_1='/Users/oscar/.rvm/gems/ruby-1.8.7-p352/gems/capybara-1.1.1/lib'
let g:netrw_dirhist_2='/Users/oscardelben/Downloads/plataformatec-devise-a5aa03b/lib/devise/omniauth'
let g:netrw_dirhist_3='/Users/oscardelben/.rvm/gems/ruby-1.8.7-p352/bundler/gems/accounts-client-dc1016248f8e'
let g:netrw_dirhist_4='/Users/oscardelben/Developer/wildfire/app_suite'
let g:netrw_dirhist_5='/Users/oscardelben/Developer/wildfire/app_suite/spec'
let g:netrw_dirhist_6='/Users/oscardelben/Developer/wildfire/app_suite'
let g:netrw_dirhist_7='/Users/oscardelben/.rvm/gems/ruby-1.8.7-p352/gems/rspec-core-2.7.1/lib/rspec/core'
let g:netrw_dirhist_cnt =2
let g:netrw_dirhist_1='/Users/oscardelben/code/try_meteor/.meteor/local/build/app/packages/mongo-livedata'
let g:netrw_dirhist_2='/Users/oscardelben/code/sheet/lib/sheet'
2 changes: 1 addition & 1 deletion .vim/bundle/command-t
Submodule command-t updated from e9a861 to bbdcfb
50 changes: 50 additions & 0 deletions .vim/bundle/supertab/doc/supertab.txt
Expand Up @@ -30,6 +30,9 @@ Supertab *supertab*
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*
Expand Down Expand Up @@ -304,4 +307,51 @@ 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*

Note: Experimental

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 that 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.

vim:tw=78:ts=8:ft=help:norl:
172 changes: 145 additions & 27 deletions .vim/bundle/supertab/plugin/supertab.vim
Expand Up @@ -14,7 +14,7 @@
" }}}
"
" License: {{{
" Copyright (c) 2002 - 2011
" Copyright (c) 2002 - 2012
" All rights reserved.
"
" Redistribution and use of this software in source and binary forms, with
Expand Down Expand Up @@ -123,6 +123,10 @@ set cpo&vim
let g:SuperTabCrMapping = 1
endif

if !exists("g:SuperTabClosePreviewOnPopupClose")
let g:SuperTabClosePreviewOnPopupClose = 0
endif

" }}}

" Script Variables {{{
Expand Down Expand Up @@ -256,19 +260,21 @@ function! s:InitBuffer()
let b:SuperTabNoCompleteAfter = g:SuperTabNoCompleteAfter
endif

let b:SuperTabDefaultCompletionType = g:SuperTabDefaultCompletionType
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 = string(maparg('<tab>', 'i'))
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> <c-r>=TriggerSnippet()<cr>"
exec "inoremap <silent> <tab> " . snipmate
endif
endfunction " }}}

Expand All @@ -280,6 +286,8 @@ function! s:ManualCompletionEnter()
endif
let complType = nr2char(getchar())
if stridx(s:types, complType) != -1
let b:supertab_close_preview = 1

if stridx("\<c-e>\<c-y>", complType) != -1 " no memory, just scroll...
return "\<c-x>" . complType
elseif stridx('np', complType) != -1
Expand Down Expand Up @@ -332,8 +340,7 @@ function! s:SetCompletionType()
endif
endfunction " }}}

" s:SetDefaultCompletionType() {{{
function! s:SetDefaultCompletionType()
function! s:SetDefaultCompletionType() " {{{
if exists('b:SuperTabDefaultCompletionType') &&
\ (!exists('b:complCommandLine') || !b:complCommandLine)
call SuperTabSetCompletionType(b:SuperTabDefaultCompletionType)
Expand All @@ -352,6 +359,8 @@ function! s:SuperTab(command)
call s:InitBuffer()

if s:WillComplete()
let b:supertab_close_preview = 1

" optionally enable enhanced longest completion
if g:SuperTabLongestEnhanced && &completeopt =~ 'longest'
call s:EnableLongestEnhancement()
Expand Down Expand Up @@ -495,8 +504,7 @@ function! s:WillComplete()
return 1
endfunction " }}}

" s:EnableLongestEnhancement() {{{
function! s:EnableLongestEnhancement()
function! s:EnableLongestEnhancement() " {{{
augroup supertab_reset
autocmd!
autocmd InsertLeave,CursorMovedI <buffer>
Expand All @@ -505,14 +513,12 @@ function! s:EnableLongestEnhancement()
call s:CaptureKeyPresses()
endfunction " }}}

" s:CompletionReset(char) {{{
function! s:CompletionReset(char)
function! s:CompletionReset(char) " {{{
let b:complReset = 1
return a:char
endfunction " }}}

" s:CaptureKeyPresses() {{{
function! s:CaptureKeyPresses()
function! s:CaptureKeyPresses() " {{{
if !exists('b:capturing') || !b:capturing
let b:capturing = 1
" save any previous mappings
Expand All @@ -530,8 +536,23 @@ function! s:CaptureKeyPresses()
endif
endfunction " }}}

" s:ReleaseKeyPresses() {{{
function! s:ReleaseKeyPresses()
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
endif
unlet b:supertab_close_preview
endif
endfunction " }}}

function! s:ReleaseKeyPresses() " {{{
if exists('b:capturing') && b:capturing
let b:capturing = 0
for c in split('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_', '.\zs')
Expand Down Expand Up @@ -576,8 +597,7 @@ function! s:CommandLineCompletion()
\ "let b:complCommandLine = 0\<cr>"
endfunction " }}}

" s:ContextCompletion() {{{
function! s:ContextCompletion()
function! s:ContextCompletion() " {{{
let contexts = exists('b:SuperTabCompletionContexts') ?
\ b:SuperTabCompletionContexts : g:SuperTabCompletionContexts

Expand All @@ -598,8 +618,7 @@ function! s:ContextCompletion()
return ''
endfunction " }}}

" s:ContextDiscover() {{{
function! s:ContextDiscover()
function! s:ContextDiscover() " {{{
let discovery = exists('g:SuperTabContextDiscoverDiscovery') ?
\ g:SuperTabContextDiscoverDiscovery : []

Expand All @@ -617,8 +636,7 @@ function! s:ContextDiscover()
endif
endfunction " }}}

" s:ContextText() {{{
function! s:ContextText()
function! s:ContextText() " {{{
let exclusions = exists('g:SuperTabContextTextFileTypeExclusions') ?
\ g:SuperTabContextTextFileTypeExclusions : []

Expand Down Expand Up @@ -647,8 +665,7 @@ function! s:ContextText()
endif
endfunction " }}}

" s:ExpandMap(map) {{{
function! s:ExpandMap(map)
function! s:ExpandMap(map) " {{{
let map = a:map
if map =~ '<Plug>'
let plug = substitute(map, '.\{-}\(<Plug>\w\+\).*', '\1', '')
Expand All @@ -658,6 +675,80 @@ function! s:ExpandMap(map)
return map
endfunction " }}}

function! SuperTabDelayedCommand(command, ...) " {{{
echom 'delay: ' . a:command
let uid = fnamemodify(tempname(), ':t:r')
if &updatetime > 1
exec 'let g:delayed_updatetime_save' . uid . ' = &updatetime'
endif
exec 'let g:delayed_command' . uid . ' = a:command'
let &updatetime = len(a:000) ? a:000[0] : 1
exec 'augroup delayed_command' . uid
exec 'autocmd CursorHoldI * ' .
\ ' if exists("g:delayed_updatetime_save' . uid . '") | ' .
\ ' let &updatetime = g:delayed_updatetime_save' . uid . ' | ' .
\ ' unlet g:delayed_updatetime_save' . uid . ' | ' .
\ ' endif | ' .
\ ' exec g:delayed_command' . uid . ' | ' .
\ ' unlet g:delayed_command' . uid . ' | ' .
\ ' autocmd! delayed_command' . uid
" just in case user leaves insert mode before CursorHoldI fires
exec 'autocmd CursorHold * ' .
\ ' if exists("g:delayed_updatetime_save' . uid . '") | ' .
\ ' let &updatetime = g:delayed_updatetime_save' . uid . ' | ' .
\ ' unlet g:delayed_updatetime_save' . uid . ' | ' .
\ ' endif | ' .
\ ' autocmd! delayed_command' . uid
exec 'augroup END'
endfunction " }}}

function! SuperTabChain(completefunc, completekeys) " {{{
let b:SuperTabChain = [a:completefunc, a:completekeys]
setlocal completefunc=SuperTabCodeComplete
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])
let keys = escape(b:SuperTabChain[1], '<')

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

call SuperTabDelayedCommand('call feedkeys("' . 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>'
Expand Down Expand Up @@ -695,7 +786,22 @@ endfunction " }}}
endfunction

if g:SuperTabCrMapping
if maparg('<CR>','i') =~ '<CR>'
let expr_map = 0
try
let map_dict = maparg('<cr>', 'i', 0, 1)
let expr_map = map_dict.expr
catch
let expr_map = maparg('<cr>', 'i') =~? '\<cr>'
endtry

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)
Expand All @@ -709,6 +815,13 @@ endfunction " }}}
" 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
let b:supertab_close_preview = 1
call s:ClosePreview()
endif

return "\<c-y>"
endif

Expand All @@ -721,10 +834,15 @@ endfunction " }}}

" not so pleasant hack to keep <cr> working for abbreviations
let word = substitute(getline('.'), '^.*\s\+\(.*\%' . col('.') . 'c\).*', '\1', '')
if maparg(word, 'i', 1) != ''
call feedkeys("\<c-]>", 't')
call feedkeys("\<cr>", 'n')
return ''
let result = maparg(word, 'i', 1)
if result != ''
let bs = ""
let i = 0
while i < len(word)
let bs .= "\<bs>"
let i += 1
endwhile
return bs . result . (a:cr ? "\<cr>" : "")
endif

" only return a cr if nothing else is mapped to it since we don't want
Expand Down
2 changes: 1 addition & 1 deletion .vim/bundle/tComment
Submodule tComment updated from bcbaea to d3523a
2 changes: 1 addition & 1 deletion .vim/bundle/vim-coffee-script
Submodule vim-coffee-script updated from 0e1246 to e63094
1 change: 1 addition & 0 deletions .vim/bundle/vim-less
Submodule vim-less added at aaf0c2
1 change: 1 addition & 0 deletions .vim/bundle/vim-markdown
Submodule vim-markdown added at 3a9915
2 changes: 1 addition & 1 deletion .vim/bundle/vim-rails
Submodule vim-rails updated from cccd2a to 0eda69
2 changes: 1 addition & 1 deletion .vim/bundle/vim-ruby
Submodule vim-ruby updated from f265e6 to 90f352

0 comments on commit d6170ff

Please sign in to comment.