mirror of
https://github.com/Raimondi/delimitMate.git
synced 2025-12-08 05:34:45 +08:00
add option to disable closing delims if open delim added before an alphanumeric
This commit is contained in:
@@ -261,6 +261,8 @@ function! delimitMate#ParenDelim(char) " {{{
|
|||||||
if (col) < 0
|
if (col) < 0
|
||||||
call setline('.',a:char.line)
|
call setline('.',a:char.line)
|
||||||
call insert(b:_l_delimitMate_buffer, a:char)
|
call insert(b:_l_delimitMate_buffer, a:char)
|
||||||
|
elseif b:_l_delimitMate_smart_parens && line[col + 1] =~ '[[:alnum:]]'
|
||||||
|
return ''
|
||||||
else
|
else
|
||||||
"echom string(col).':'.line[:(col)].'|'.line[(col+1):]
|
"echom string(col).':'.line[:(col)].'|'.line[(col+1):]
|
||||||
call setline('.',line[:(col)].a:char.line[(col+1):])
|
call setline('.',line[:(col)].a:char.line[(col+1):])
|
||||||
@@ -528,7 +530,7 @@ function! delimitMate#TestMappings() "{{{
|
|||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! delimitMate#OptionsList() "{{{
|
function! delimitMate#OptionsList() "{{{
|
||||||
return {'autoclose' : 1,'matchpairs': &matchpairs, 'quotes' : '" '' `', 'nesting_quotes' : [], 'expand_cr' : 0, 'expand_space' : 0, 'smart_quotes' : 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_parens' : 1, 'balance_matchpairs' : 0, 'excluded_regions' : 'Comment', 'excluded_ft' : '', 'apostrophes' : ''}
|
||||||
endfunction " delimitMate#OptionsList }}}
|
endfunction " delimitMate#OptionsList }}}
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
|
|||||||
@@ -93,6 +93,8 @@ specific file types, see |delimitMateOptionDetails| for examples.
|
|||||||
|
|
||||||
|'delimitMate_smart_quotes'| Turns on/off the "smart quotes" feature.
|
|'delimitMate_smart_quotes'| Turns on/off the "smart quotes" feature.
|
||||||
|
|
||||||
|
|'delimitMate_smart_parens'| Turns on/off the "smart parens" feature.
|
||||||
|
|
||||||
|'delimitMate_balance_matchpairs'|Turns on/off the "balance matching pairs"
|
|'delimitMate_balance_matchpairs'|Turns on/off the "balance matching pairs"
|
||||||
feature.
|
feature.
|
||||||
|
|
||||||
@@ -211,6 +213,18 @@ e.g.: >
|
|||||||
let delimitMate_smart_quotes = 0
|
let delimitMate_smart_quotes = 0
|
||||||
au FileType tcl let b:delimitMate_smart_quotes = 0
|
au FileType tcl let b:delimitMate_smart_quotes = 0
|
||||||
<
|
<
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
*'delimitMate_smart_parens'*
|
||||||
|
*'b:delimitMate_smart_parens'*
|
||||||
|
Values: 1 or 0 ~
|
||||||
|
Default: 1 ~
|
||||||
|
|
||||||
|
This option turns on/off the smart parens feature. Read
|
||||||
|
|delimitMateSmartParens| for details.
|
||||||
|
e.g.: >
|
||||||
|
let delimitMate_smart_parens = 0
|
||||||
|
au FileType tcl let b:delimitMate_smart_parens = 0
|
||||||
|
<
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
*'delimitMate_balance_matchpairs'*
|
*'delimitMate_balance_matchpairs'*
|
||||||
*'b:delimitMate_balance_matchpairs'*
|
*'b:delimitMate_balance_matchpairs'*
|
||||||
@@ -375,6 +389,23 @@ e.g. typing at the "|": >
|
|||||||
" | let i = "| | let i = "|"
|
" | let i = "| | let i = "|"
|
||||||
'm | I| | I'm|
|
'm | I| | I'm|
|
||||||
<
|
<
|
||||||
|
------------------------------------------------------------------------------
|
||||||
|
3.4 SMART PARENS *delimitMateSmartParens*
|
||||||
|
|
||||||
|
Like "smart quotes", but applied to parens (as well as [, {, etc.), only
|
||||||
|
inserting the opening delimiter if preceding an alphanumeric character. This
|
||||||
|
should cover adding parens, etc around existing words without having to handle
|
||||||
|
the uncessary closing delimiter. This feature can be disabled by setting the
|
||||||
|
option
|
||||||
|
|'delimitMate_smart_parens'| to 0.
|
||||||
|
|
||||||
|
e.g. typing at the "|": >
|
||||||
|
|
||||||
|
What | Before | After
|
||||||
|
=======================================
|
||||||
|
( | function| | function(|)
|
||||||
|
( | |var | (|var
|
||||||
|
<
|
||||||
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
||||||
3.5 BALANCING MATCHING PAIRS *delimitMateBalance*
|
3.5 BALANCING MATCHING PAIRS *delimitMateBalance*
|
||||||
|
|
||||||
|
|||||||
@@ -114,6 +114,8 @@ function! s:init() "{{{
|
|||||||
|
|
||||||
" smart_quotes
|
" smart_quotes
|
||||||
call s:option_init("smart_quotes", 1)
|
call s:option_init("smart_quotes", 1)
|
||||||
|
" smart_parens
|
||||||
|
call s:option_init("smart_parens", 1)
|
||||||
|
|
||||||
" apostrophes
|
" apostrophes
|
||||||
call s:option_init("apostrophes", "")
|
call s:option_init("apostrophes", "")
|
||||||
|
|||||||
Reference in New Issue
Block a user