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
" Will auto generated {']' => 1, ..., '}' => 1}in initialize.
" Will auto generated {']' => '[', ..., '}' => '{'}in initialize.
let g:AutoPairsClosedPairs = {}
@ -282,7 +282,7 @@ function! AutoPairsInit()
if open != close
call AutoPairsMap(close)
end
let g:AutoPairsClosedPairs[close] = 1
let g:AutoPairsClosedPairs[close] = open
endfor
" Still use <buffer> level mapping for <BS> <SPACE>
@ -318,16 +318,19 @@ endfunction
function! AutoPairsForceInit()
if exists('b:autopairs_loaded')
return
else
call AutoPairsInit()
endif
endfunction
end
" for auto-pairs starts with 'a', so the priority is higher than supertab and vim-endwise
"
" 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
inoremap <silent> <SID>AutoPairsReturn <C-R>=AutoPairsReturn()<CR>
imap <script> <Plug>AutoPairsReturn <SID>AutoPairsReturn
" Global keys mapping
" Buffer level keys mapping
" comptible with other plugin
if g:AutoPairsMapCR
let old_cr = maparg('<CR>', 'i')
@ -336,8 +339,15 @@ if g:AutoPairsMapCR
endif
if old_cr !~ 'AutoPairsReturn'
execute 'imap <CR> '.old_cr.'<Plug>AutoPairsReturn'
execute 'imap <buffer> <CR> '.old_cr.'<SID>AutoPairsReturn'
end
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()