mirror of
https://github.com/Raimondi/delimitMate.git
synced 2025-12-06 20:54:31 +08:00
Add eol marker finished. Closes #102. Add s:g().
This commit is contained in:
@@ -10,6 +10,10 @@
|
||||
|
||||
"let delimitMate_loaded = 1
|
||||
|
||||
function! s:g(name, ...) "{{{
|
||||
return eval('b:_l_delimitMate_' . a:name)
|
||||
endfunction "}}}
|
||||
|
||||
function! delimitMate#ShouldJump(...) "{{{
|
||||
" Returns 1 if the next character is a closing delimiter.
|
||||
let char = delimitMate#GetCharFromCursor(0)
|
||||
@@ -197,8 +201,11 @@ function! delimitMate#FlushBuffer() " {{{
|
||||
return ''
|
||||
endfunction " }}}
|
||||
|
||||
function! delimitMate#AddToBuffer(str) "{{{
|
||||
call insert(b:_l_delimitMate_buffer, a:str)
|
||||
function! delimitMate#AddToBuffer(str, ...) "{{{
|
||||
if a:0 && a:1 == 1
|
||||
return add(b:_l_delimitMate_buffer, a:str)
|
||||
endif
|
||||
return insert(b:_l_delimitMate_buffer, a:str)
|
||||
endfunction "delimitMate#AddToBuffer }}}
|
||||
|
||||
function! delimitMate#BalancedParens(char) "{{{
|
||||
@@ -335,14 +342,23 @@ function! delimitMate#QuoteDelim(char) "{{{
|
||||
elseif delimitMate#IsSmartQuote(a:char)
|
||||
" Seems like a smart quote, insert a single char.
|
||||
return a:char
|
||||
elseif (char_before == a:char && char_at != a:char) && b:_l_delimitMate_smart_quotes
|
||||
" Seems like we have an unbalanced quote, insert one quotation mark and jump to the middle.
|
||||
elseif (char_before == a:char && char_at != a:char)
|
||||
\ && b:_l_delimitMate_smart_quotes
|
||||
" Seems like we have an unbalanced quote, insert one quotation
|
||||
" mark and jump to the middle.
|
||||
call delimitMate#AddToBuffer(a:char)
|
||||
return delimitMate#WriteAfter(a:char)
|
||||
else
|
||||
" Insert a pair and jump to the middle.
|
||||
call delimitMate#AddToBuffer(a:char)
|
||||
call delimitMate#WriteAfter(a:char)
|
||||
let sufix = ''
|
||||
if !empty(s:g('eol_marker')) && col('.') - 1 == len(getline('.'))
|
||||
let idx = len(s:g('eol_marker')) * -1
|
||||
let marker = getline('.')[idx : ]
|
||||
let has_marker = marker == s:g('eol_marker')
|
||||
let sufix = !has_marker ? s:g('eol_marker') : ''
|
||||
endif
|
||||
call delimitMate#AddToBuffer(a:char . sufix)
|
||||
call delimitMate#WriteAfter(a:char . sufix)
|
||||
return a:char
|
||||
endif
|
||||
endfunction "}}}
|
||||
@@ -459,12 +475,12 @@ function! delimitMate#BS() " {{{
|
||||
let extra = ''
|
||||
endif
|
||||
let tail_re = '\m\C\%('
|
||||
\ . join(b:_l_delimitMate_right_delims, '\|')
|
||||
\ . join(s:g('right_delims')+s:g('quotes_list'), '\|')
|
||||
\ . '\)'
|
||||
\ . escape(b:_l_delimitMate_eol_marker, '\*.^$')
|
||||
\ . escape(s:g('eol_marker'), '\*.^$')
|
||||
\ . '$'
|
||||
if buffer_tail =~ tail_re && search('\%#'.tail_re, 'cWn')
|
||||
let extra .= join(map(split(b:_l_delimitMate_eol_marker, '\zs'),
|
||||
let extra .= join(map(split(s:g('eol_marker'), '\zs'),
|
||||
\ 'delimitMate#Del()'), '')
|
||||
endif
|
||||
return "\<BS>" . extra
|
||||
|
||||
@@ -64,7 +64,7 @@ function! s:init() "{{{
|
||||
|
||||
" quotes
|
||||
call s:option_init("quotes", "\" ' `")
|
||||
call s:option_init("quotes_list", split(b:_l_delimitMate_quotes))
|
||||
call s:option_init("quotes_list", split(b:_l_delimitMate_quotes, '\zs'))
|
||||
|
||||
" nesting_quotes
|
||||
call s:option_init("nesting_quotes", [])
|
||||
|
||||
Reference in New Issue
Block a user