From 82c649c522aee2cbd318de3d32d0e4ec90ac1f2f Mon Sep 17 00:00:00 2001 From: "jiangfriend@gmail.com" Date: Mon, 14 May 2012 15:22:43 +0800 Subject: [PATCH] compatible with vim-endwise, supertab. --- plugin/auto-pairs.vim | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/plugin/auto-pairs.vim b/plugin/auto-pairs.vim index ac3ec73..0388194 100644 --- a/plugin/auto-pairs.vim +++ b/plugin/auto-pairs.vim @@ -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 level mapping for @@ -318,26 +318,36 @@ endfunction function! AutoPairsForceInit() if exists('b:autopairs_loaded') return - else - call AutoPairsInit() + end + " for auto-pairs starts with 'a', so the priority is higher than supertab and vim-endwise + " + " vim-endwise didn't support AutoPairsReturn + " when use AutoPairsReturn will cause wasn't expanded + " + " supertab didn't support AutoPairsReturn + " when use AutoPairsReturn will cause Duplicated + " + " and when load after vim-endwise will cause endwise duplicated closed. so always + " load AutoPairs at last + + " Buffer level keys mapping + " comptible with other plugin + if g:AutoPairsMapCR + let old_cr = maparg('', 'i') + if old_cr == '' + let old_cr = '' + endif + + if old_cr !~ 'AutoPairsReturn' + execute 'imap '.old_cr.'AutoPairsReturn' + end endif + call AutoPairsInit() endfunction " Always silent the command inoremap AutoPairsReturn =AutoPairsReturn() imap