From 07d9fa9ddc26c35a421a8ab37371c7e3141896ff Mon Sep 17 00:00:00 2001 From: Israel Chauca Fuentes Date: Sat, 4 Jan 2014 18:14:03 -0500 Subject: [PATCH] =?UTF-8?q?Check=20delimitMate=5Fmatchpairs=E2=80=99=20syn?= =?UTF-8?q?tax.=20Also=20some=20formatting.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- autoload/delimitMate.vim | 2 +- plugin/delimitMate.vim | 42 ++++++++++++++-------------------------- 2 files changed, 15 insertions(+), 29 deletions(-) diff --git a/autoload/delimitMate.vim b/autoload/delimitMate.vim index 1aae08b..433c573 100644 --- a/autoload/delimitMate.vim +++ b/autoload/delimitMate.vim @@ -35,7 +35,7 @@ function! s:g(name, ...) "{{{ else let name = 'delimitMate_' . a:name endif - return eval(scope . ':' . name) + return deepcopy(eval(scope . ':' . name)) endfunction "}}} function! s:exists(name, ...) "{{{ diff --git a/plugin/delimitMate.vim b/plugin/delimitMate.vim index 3dff651..f604b64 100644 --- a/plugin/delimitMate.vim +++ b/plugin/delimitMate.vim @@ -40,32 +40,33 @@ endfunction "}}} function! s:init() "{{{ " Initialize variables: - " autoclose call s:option_init("autoclose", 1) - " matchpairs call s:option_init("matchpairs", string(&matchpairs)[1:-2]) call s:option_init("matchpairs_list", map(split(s:g('matchpairs'), ','), 'split(v:val, '':'')')) + let pairs = s:g('matchpairs_list') + if len(filter(pairs, 'v:val[0] ==# v:val[1]')) + echohl ErrorMsg + echom 'delimitMate: each member of a pair in delimitMate_matchpairs must be different from each other.' + echom 'delimitMate: invalid pairs: ' . join(map(pairs, 'join(v:val, ":")'), ', ') + echohl Normal + return 0 + endif call s:option_init("left_delims", map(copy(s:g('matchpairs_list')), 'v:val[0]')) call s:option_init("right_delims", map(copy(s:g('matchpairs_list')), 'v:val[1]')) - " quotes call s:option_init("quotes", "\" ' `") call s:option_init("quotes_list",split(s:g('quotes'), '\s\+')) - " nesting_quotes call s:option_init("nesting_quotes", []) - " excluded_regions call s:option_init("excluded_regions", "Comment") call s:option_init("excluded_regions_list", split(s:g('excluded_regions'), ',\s*')) let enabled = len(s:g('excluded_regions_list')) > 0 call s:option_init("excluded_regions_enabled", enabled) - " excluded filetypes call s:option_init("excluded_ft", "") - " expand_space if exists("b:delimitMate_expand_space") && type(b:delimitMate_expand_space) == type("") echom "b:delimitMate_expand_space is '".b:delimitMate_expand_space."' but it must be either 1 or 0!" @@ -80,7 +81,6 @@ function! s:init() "{{{ let g:delimitMate_expand_space = 1 endif call s:option_init("expand_space", 0) - " expand_cr if exists("b:delimitMate_expand_cr") && type(b:delimitMate_expand_cr) == type("") echom "b:delimitMate_expand_cr is '".b:delimitMate_expand_cr."' but it must be either 1 or 0!" @@ -100,34 +100,25 @@ function! s:init() "{{{ echom "delimitMate: There seems to be some incompatibility with your settings that may interfer with the expansion of . See :help 'delimitMate_expand_cr' for details." endif call s:option_init("expand_cr", 0) - " expand_in_quotes call s:option_init('expand_inside_quotes', 0) - " jump_expansion call s:option_init("jump_expansion", 0) - " smart_matchpairs call s:option_init("smart_matchpairs", '^\%(\w\|\!\|£\|\$\|_\|["'']\s*\S\)') - " smart_quotes call s:option_init("smart_quotes", 1) - " apostrophes call s:option_init("apostrophes", "") call s:option_init("apostrophes_list", split(s:g('apostrophes'), ":\s*")) - " tab2exit call s:option_init("tab2exit", 1) - " balance_matchpairs call s:option_init("balance_matchpairs", 0) - " eol marker call s:option_init("eol_marker", "") - - call s:s('buffer', []) - + " Everything is fine. + return 1 endfunction "}}} Init() "}}} @@ -204,33 +195,29 @@ function! s:TestMappingsDo() "{{{ endfunction "}}} function! s:DelimitMateDo(...) "{{{ - " First, remove all magic, if needed: if exists("b:delimitMate_enabled") && b:delimitMate_enabled == 1 call s:Unmap() endif - " Check if this file type is excluded: if exists("g:delimitMate_excluded_ft") && \ index(split(g:delimitMate_excluded_ft, ','), &filetype, 0, 1) >= 0 - " Finish here: return 1 endif - " Check if user tried to disable using b:loaded_delimitMate if exists("b:loaded_delimitMate") return 1 endif - " Initialize settings: - call s:init() - + if ! s:init() + " Something went wrong. + return + endif " Now, add magic: if !exists("g:delimitMate_offByDefault") || !g:delimitMate_offByDefault call s:Map() endif - if a:0 > 0 echo "delimitMate has been reset." endif @@ -247,7 +234,6 @@ function! s:DelimitMateSwitch() "{{{ echo "delimitMate has been enabled." endif endfunction "}}} - "}}} " Mappers: {{{