diff --git a/plugin/auto-pairs.vim b/plugin/auto-pairs.vim index 94527c8..bce61fa 100644 --- a/plugin/auto-pairs.vim +++ b/plugin/auto-pairs.vim @@ -69,6 +69,18 @@ if !exists('g:AutoPairsSmartQuotes') let g:AutoPairsSmartQuotes = 1 endif +" 7.4.849 support U to avoid breaking '.' +" Issue talk: https://github.com/jiangmiao/auto-pairs/issues/3 +" Vim note: https://github.com/vim/vim/releases/tag/v7.4.849 +if v:version >= 704 && has("patch849") + let s:Go = "\U" +else + let s:Go = "" +endif + +let s:Left = s:Go."\" +let s:Right = s:Go."\" + " Will auto generated {']' => '[', ..., '}' => '{'}in initialize. let g:AutoPairsClosedPairs = {} @@ -105,13 +117,13 @@ function! AutoPairsInsert(key) " Skip the character if current character is the same as input if current_char == a:key - return "\U\" + return s:Right end if !g:AutoPairsFlyMode " Skip the character if next character is space if current_char == ' ' && next_char == a:key - return "\U\\U\" + return s:Right.s:Right end " Skip the character if closed pair is next character @@ -132,7 +144,7 @@ function! AutoPairsInsert(key) " Fly Mode, and the key is closed-pairs, search closed-pair and jump if g:AutoPairsFlyMode && has_key(b:AutoPairsClosedPairs, a:key) if search(a:key, 'W') - return "\U\" + return s:Right endif endif @@ -144,7 +156,7 @@ function! AutoPairsInsert(key) let close = b:AutoPairs[open] if current_char == close && open == close - return "\U\" + return s:Right end " Ignore auto close ' if follows a word @@ -159,7 +171,7 @@ function! AutoPairsInsert(key) let pprev_char = line[col('.')-3] if pprev_char == open && prev_char == open " Double pair found - return repeat(a:key, 4) . repeat("\U\", 3) + return repeat(a:key, 4) . repeat(s:Left, 3) end end @@ -194,7 +206,7 @@ function! AutoPairsInsert(key) endif endif - return open.close."\U\" + return open.close.s:Left endfunction function! AutoPairsDelete() @@ -318,10 +330,10 @@ function! AutoPairsFastWrap() else call search(s:FormatChunk(followed_open_pair, followed_close_pair), 'We') end - return "\U\".inputed_close_pair."\U\" + return s:Right.inputed_close_pair.s:Left else normal he - return "\U\".current_char."\U\" + return s:Right.current_char.s:Left end endfunction @@ -388,7 +400,7 @@ function! AutoPairsSpace() let cmd = '' let cur_char =line[col('.')-1] if has_key(g:AutoPairsParens, prev_char) && g:AutoPairsParens[prev_char] == cur_char - let cmd = "\\U\" + let cmd = "\".s:Left endif return "\".cmd endfunction