From 73e07d17ea151e8b1741176986edb61db8bad9e1 Mon Sep 17 00:00:00 2001 From: Rohan Vasant Ghige Date: Wed, 6 Mar 2019 04:44:32 -0800 Subject: [PATCH] [EXTRA_AUTO_PAIRS] Add support for extra auto pairs rather than over-writing pristine pairs Please note there is already support for doing this as follows, Existing support for adding new pairs let g:AutoPairs['<']='>' But, for adding numerous pairs it becomes tedious and repeatative. e.g. let g:AutoPairs['<']='>' let g:AutoPairs['"']='"' let g:AutoPairs['&']='&' let g:AutoPairs['@']='@' Instead of this current change enables user do following, let g:ExtraAutoPairs = {'<':'>', '"':'"', '&':'&', '@':'@'} Signed-off-by: Rohan Vasant Ghige --- README.md | 5 +++++ plugin/auto-pairs.vim | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/README.md b/README.md index 8d079ba..3208495 100644 --- a/README.md +++ b/README.md @@ -161,6 +161,11 @@ Options Default: {'(':')', '[':']', '{':'}',"'":"'",'"':'"', "`":"`", '```':'```', '"""':'"""', "'''":"'''"} +* g:ExtraAutoPairs + + Append to pristine dictionary of pairs rather than overwriting the it. + let g:ExtraAutoPairs = {'<':'>'} + * b:AutoPairs Default: g:AutoPairs diff --git a/plugin/auto-pairs.vim b/plugin/auto-pairs.vim index af5eb32..dfc7498 100644 --- a/plugin/auto-pairs.vim +++ b/plugin/auto-pairs.vim @@ -16,6 +16,13 @@ if !exists('g:AutoPairs') let g:AutoPairs = {'(':')', '[':']', '{':'}',"'":"'",'"':'"', '```':'```', '"""':'"""', "'''":"'''", "`":"`"} end +" Extend default dictionary with extra pair dictionary +" This feature is useful when user doesn't want to disturb the pristine AutoPairs +" dictionary. +if exists('g:ExtraAutoPairs') + call extend(g:AutoPairs, g:ExtraAutoPairs) +end + " default pairs base on filetype func! AutoPairsDefaultPairs() if exists('b:autopairs_defaultpairs')