From e5bbe4f7447bd7c0c512c694a4c7bb9d78fb25e8 Mon Sep 17 00:00:00 2001 From: Michael Quinn Date: Wed, 12 Oct 2016 12:20:39 -0700 Subject: [PATCH 1/2] Adding a new global variable g:AutoPairsIgnoreCharacters is a list that lets the user determine which characters escape automatic closing. By default, it equals ['\'] --- README.md | 7 +++++++ plugin/auto-pairs.vim | 16 ++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 72bde89..a797540 100644 --- a/README.md +++ b/README.md @@ -249,6 +249,13 @@ Options Work with FlyMode, insert the key at the Fly Mode jumped postion +* g:AutoPairsIgnoreCharacters + + Default : ['\'] + + Sets the characters to stop auto closing. For example, when set to + ['\', '#'], the plugin will not automatically close `#'` + Buffer Level Pairs Setting -------------------------- diff --git a/plugin/auto-pairs.vim b/plugin/auto-pairs.vim index 200b2dd..afe55c3 100644 --- a/plugin/auto-pairs.vim +++ b/plugin/auto-pairs.vim @@ -74,6 +74,10 @@ if !exists('g:AutoPairsSmartQuotes') let g:AutoPairsSmartQuotes = 1 endif +if !exists('g:AutoPairsIgnoreCharacters') + let g:AutoPairsIgnoreCharacters = ['\'] +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 @@ -111,8 +115,8 @@ function! AutoPairsInsert(key) let eol = 1 end - " Ignore auto close if prev character is \ - if prev_char == '\' + " Ignore auto close if prev character is in g:AutoPairsIgnoreCharacters + if index(g:AutoPairsIgnoreCharacters, prev_char) != -1 return a:key end @@ -231,7 +235,7 @@ function! AutoPairsDelete() let prev_char = get(prev_chars, -1, '') let pprev_char = get(prev_chars, -2, '') - if pprev_char == '\' + if index(g:AutoPairsIgnoreCharacters, pprev_char) != -1 return "\" end @@ -261,7 +265,7 @@ function! AutoPairsDelete() end - if has_key(b:AutoPairs, prev_char) + if has_key(b:AutoPairs, prev_char) let close = b:AutoPairs[prev_char] if match(line,'^\s*'.close, col('.')-1) != -1 " Delete (|___) @@ -504,9 +508,9 @@ function! AutoPairsTryInit() " supertab doesn't support AutoPairsReturn " when use AutoPairsReturn will cause Duplicated " - " and when load after vim-endwise will cause unexpected endwise inserted. + " and when load after vim-endwise will cause unexpected endwise inserted. " so always load AutoPairs at last - + " Buffer level keys mapping " comptible with other plugin if g:AutoPairsMapCR From 79ce87888451e93a5e2b853be3724c59b479c281 Mon Sep 17 00:00:00 2001 From: Michael Quinn Date: Tue, 30 Jul 2019 16:46:16 -0700 Subject: [PATCH 2/2] Restore previous changes --- plugin/auto-pairs.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/auto-pairs.vim b/plugin/auto-pairs.vim index 28c2f25..4b0e951 100644 --- a/plugin/auto-pairs.vim +++ b/plugin/auto-pairs.vim @@ -208,8 +208,8 @@ func! AutoPairsInsert(key) let [before, after, afterline] = s:getline() - " Ignore auto close if prev character is \ - if before[-1:-1] == '\' + " Ignore auto close if prev character is in g:AutoPairsIgnoreCharacters + if index(g:AutoPairsIgnoreCharacters, prev_char) != -1 return a:key end