Use regex for smart_matchpairs.

If the text in the line to the right of the cursor matches
smart_matchpairs, do not auto close.

To match the opening paren, insert a escaped bang (\!) in the pattern.
This commit is contained in:
Israel Chauca Fuentes
2010-11-17 17:53:33 -06:00
parent f7b53f045d
commit 86f70a7d9c
2 changed files with 7 additions and 4 deletions

View File

@@ -259,8 +259,11 @@ function! delimitMate#ParenDelim(char) " {{{
endif
let line = getline('.')
let col = col('.')-2
if b:_l_delimitMate_smart_matchpairs &&
\ line[col+1] =~ '\w'
let left = b:_l_delimitMate_left_delims[index(b:_l_delimitMate_right_delims,a:char)]
let smart_matchpairs = substitute(b:_l_delimitMate_smart_matchpairs, '\\!', left, 'g')
"echom left.':'.smart_matchpairs . ':' . matchstr(line[col+1], smart_matchpairs)
if b:_l_delimitMate_smart_matchpairs != '' &&
\ line[col+1:] =~ smart_matchpairs
return ''
elseif (col) < 0
call setline('.',a:char.line)
@@ -531,7 +534,7 @@ function! delimitMate#TestMappings() "{{{
endfunction "}}}
function! delimitMate#OptionsList() "{{{
return {'autoclose' : 1,'matchpairs': &matchpairs, 'quotes' : '" '' `', 'nesting_quotes' : [], 'expand_cr' : 0, 'expand_space' : 0, 'smart_quotes' : 1, 'smart_matchpairs' : 1, 'balance_matchpairs' : 0, 'excluded_regions' : 'Comment', 'excluded_ft' : '', 'apostrophes' : ''}
return {'autoclose' : 1,'matchpairs': &matchpairs, 'quotes' : '" '' `', 'nesting_quotes' : [], 'expand_cr' : 0, 'expand_space' : 0, 'smart_quotes' : 1, 'smart_matchpairs' : '\w', 'balance_matchpairs' : 0, 'excluded_regions' : 'Comment', 'excluded_ft' : '', 'apostrophes' : ''}
endfunction " delimitMate#OptionsList }}}
"}}}

View File

@@ -112,7 +112,7 @@ function! s:init() "{{{
call s:option_init("expand_cr", 0)
" smart_matchpairs
call s:option_init("smart_matchpairs", 1)
call s:option_init("smart_matchpairs", '^\%(\w\|\!\)')
" smart_quotes
call s:option_init("smart_quotes", 1)