compatible with vim-endwise, supertab.

This commit is contained in:
jiangfriend@gmail.com 2012-05-14 15:22:43 +08:00
parent a01f22e5ad
commit 82c649c522

View File

@ -62,7 +62,7 @@ if !exists('g:AutoPairsShortcutBackInsert')
endif endif
" Will auto generated {']' => 1, ..., '}' => 1}in initialize. " Will auto generated {']' => '[', ..., '}' => '{'}in initialize.
let g:AutoPairsClosedPairs = {} let g:AutoPairsClosedPairs = {}
@ -282,7 +282,7 @@ function! AutoPairsInit()
if open != close if open != close
call AutoPairsMap(close) call AutoPairsMap(close)
end end
let g:AutoPairsClosedPairs[close] = 1 let g:AutoPairsClosedPairs[close] = open
endfor endfor
" Still use <buffer> level mapping for <BS> <SPACE> " Still use <buffer> level mapping for <BS> <SPACE>
@ -318,16 +318,19 @@ endfunction
function! AutoPairsForceInit() function! AutoPairsForceInit()
if exists('b:autopairs_loaded') if exists('b:autopairs_loaded')
return return
else end
call AutoPairsInit() " for auto-pairs starts with 'a', so the priority is higher than supertab and vim-endwise
endif "
endfunction " vim-endwise didn't support <Plug>AutoPairsReturn
" when use <Plug>AutoPairsReturn will cause <Plug> wasn't expanded
"
" supertab didn't support <SID>AutoPairsReturn
" when use <SID>AutoPairsReturn will cause Duplicated <CR>
"
" and when load after vim-endwise will cause endwise duplicated closed. so always
" load AutoPairs at last
" Always silent the command " Buffer level keys mapping
inoremap <silent> <SID>AutoPairsReturn <C-R>=AutoPairsReturn()<CR>
imap <script> <Plug>AutoPairsReturn <SID>AutoPairsReturn
" Global keys mapping
" comptible with other plugin " comptible with other plugin
if g:AutoPairsMapCR if g:AutoPairsMapCR
let old_cr = maparg('<CR>', 'i') let old_cr = maparg('<CR>', 'i')
@ -336,8 +339,15 @@ if g:AutoPairsMapCR
endif endif
if old_cr !~ 'AutoPairsReturn' if old_cr !~ 'AutoPairsReturn'
execute 'imap <CR> '.old_cr.'<Plug>AutoPairsReturn' execute 'imap <buffer> <CR> '.old_cr.'<SID>AutoPairsReturn'
end end
endif endif
call AutoPairsInit()
endfunction
" Always silent the command
inoremap <silent> <SID>AutoPairsReturn <C-R>=AutoPairsReturn()<CR>
imap <script> <Plug>AutoPairsReturn <SID>AutoPairsReturn
au BufEnter * :call AutoPairsForceInit() au BufEnter * :call AutoPairsForceInit()