mirror of
https://github.com/Raimondi/delimitMate.git
synced 2025-12-07 21:24:51 +08:00
Use getter func.
This commit is contained in:
@@ -17,7 +17,7 @@ endfunction "}}}
|
|||||||
function! delimitMate#ShouldJump(...) "{{{
|
function! delimitMate#ShouldJump(...) "{{{
|
||||||
" Returns 1 if the next character is a closing delimiter.
|
" Returns 1 if the next character is a closing delimiter.
|
||||||
let char = delimitMate#GetCharFromCursor(0)
|
let char = delimitMate#GetCharFromCursor(0)
|
||||||
let list = b:_l_delimitMate_right_delims + b:_l_delimitMate_quotes_list
|
let list = s:g('right_delims') + s:g('quotes_list')
|
||||||
|
|
||||||
" Closing delimiter on the right.
|
" Closing delimiter on the right.
|
||||||
if (!a:0 && index(list, char) > -1)
|
if (!a:0 && index(list, char) > -1)
|
||||||
@@ -27,11 +27,11 @@ function! delimitMate#ShouldJump(...) "{{{
|
|||||||
|
|
||||||
" Closing delimiter with space expansion.
|
" Closing delimiter with space expansion.
|
||||||
let nchar = delimitMate#GetCharFromCursor(1)
|
let nchar = delimitMate#GetCharFromCursor(1)
|
||||||
if !a:0 && b:_l_delimitMate_expand_space && char == " "
|
if !a:0 && s:g('expand_space') && char == " "
|
||||||
if index(list, nchar) > -1
|
if index(list, nchar) > -1
|
||||||
return 2
|
return 2
|
||||||
endif
|
endif
|
||||||
elseif a:0 && b:_l_delimitMate_expand_space && nchar == a:1
|
elseif a:0 && s:g('expand_space') && nchar == a:1
|
||||||
return 3
|
return 3
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -41,11 +41,11 @@ function! delimitMate#ShouldJump(...) "{{{
|
|||||||
|
|
||||||
" Closing delimiter with CR expansion.
|
" Closing delimiter with CR expansion.
|
||||||
let uchar = matchstr(getline(line('.') + 1), '^\s*\zs\S')
|
let uchar = matchstr(getline(line('.') + 1), '^\s*\zs\S')
|
||||||
if !a:0 && b:_l_delimitMate_expand_cr && char == ""
|
if !a:0 && s:g('expand_cr') && char == ""
|
||||||
if index(list, uchar) > -1
|
if index(list, uchar) > -1
|
||||||
return 4
|
return 4
|
||||||
endif
|
endif
|
||||||
elseif a:0 && b:_l_delimitMate_expand_cr && uchar == a:1
|
elseif a:0 && s:g('expand_cr') && uchar == a:1
|
||||||
return 5
|
return 5
|
||||||
endif
|
endif
|
||||||
return 0
|
return 0
|
||||||
@@ -55,14 +55,14 @@ function! delimitMate#IsEmptyPair(str) "{{{
|
|||||||
if strlen(substitute(a:str, ".", "x", "g")) != 2
|
if strlen(substitute(a:str, ".", "x", "g")) != 2
|
||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
let idx = index(b:_l_delimitMate_left_delims, matchstr(a:str, '^.'))
|
let idx = index(s:g('left_delims'), matchstr(a:str, '^.'))
|
||||||
if idx > -1 &&
|
if idx > -1 &&
|
||||||
\ b:_l_delimitMate_right_delims[idx] == matchstr(a:str, '.$')
|
\ s:g('right_delims')[idx] == matchstr(a:str, '.$')
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
let idx = index(b:_l_delimitMate_quotes_list, matchstr(a:str, '^.'))
|
let idx = index(s:g('quotes_list'), matchstr(a:str, '^.'))
|
||||||
if idx > -1 &&
|
if idx > -1 &&
|
||||||
\ b:_l_delimitMate_quotes_list[idx] == matchstr(a:str, '.$')
|
\ s:g('quotes_list')[idx] == matchstr(a:str, '.$')
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
return 0
|
return 0
|
||||||
@@ -86,12 +86,14 @@ function! delimitMate#IsCRExpansion(...) " {{{
|
|||||||
let nchar = getline(line('.')-1)[-1:]
|
let nchar = getline(line('.')-1)[-1:]
|
||||||
let schar = matchstr(getline(line('.')+1), '^\s*\zs\S')
|
let schar = matchstr(getline(line('.')+1), '^\s*\zs\S')
|
||||||
let isEmpty = a:0 ? getline('.') =~ '^\s*$' : empty(getline('.'))
|
let isEmpty = a:0 ? getline('.') =~ '^\s*$' : empty(getline('.'))
|
||||||
if index(b:_l_delimitMate_left_delims, nchar) > -1
|
if index(s:g('left_delims'), nchar) > -1
|
||||||
\ && index(b:_l_delimitMate_left_delims, nchar) == index(b:_l_delimitMate_right_delims, schar)
|
\ && index(s:g('left_delims'), nchar)
|
||||||
|
\ == index(s:g('right_delims'), schar)
|
||||||
\ && isEmpty
|
\ && isEmpty
|
||||||
return 1
|
return 1
|
||||||
elseif index(b:_l_delimitMate_quotes_list, nchar) > -1
|
elseif index(s:g('quotes_list'), nchar) > -1
|
||||||
\ && index(b:_l_delimitMate_quotes_list, nchar) == index(b:_l_delimitMate_quotes_list, schar)
|
\ && index(s:g('quotes_list'), nchar)
|
||||||
|
\ == index(s:g('quotes_list'), schar)
|
||||||
\ && isEmpty
|
\ && isEmpty
|
||||||
return 1
|
return 1
|
||||||
else
|
else
|
||||||
@@ -103,14 +105,19 @@ function! delimitMate#IsSpaceExpansion() " {{{
|
|||||||
if col('.') > 2
|
if col('.') > 2
|
||||||
let pchar = delimitMate#GetCharFromCursor(-2)
|
let pchar = delimitMate#GetCharFromCursor(-2)
|
||||||
let nchar = delimitMate#GetCharFromCursor(1)
|
let nchar = delimitMate#GetCharFromCursor(1)
|
||||||
let isSpaces = (delimitMate#GetCharFromCursor(-1) == delimitMate#GetCharFromCursor(0) && delimitMate#GetCharFromCursor(-1) == " ")
|
let isSpaces =
|
||||||
|
\ (delimitMate#GetCharFromCursor(-1)
|
||||||
|
\ == delimitMate#GetCharFromCursor(0)
|
||||||
|
\ && delimitMate#GetCharFromCursor(-1) == " ")
|
||||||
|
|
||||||
if index(b:_l_delimitMate_left_delims, pchar) > -1 &&
|
if index(s:g('left_delims'), pchar) > -1 &&
|
||||||
\ index(b:_l_delimitMate_left_delims, pchar) == index(b:_l_delimitMate_right_delims, nchar) &&
|
\ index(s:g('left_delims'), pchar)
|
||||||
|
\ == index(s:g('right_delims'), nchar) &&
|
||||||
\ isSpaces
|
\ isSpaces
|
||||||
return 1
|
return 1
|
||||||
elseif index(b:_l_delimitMate_quotes_list, pchar) > -1 &&
|
elseif index(s:g('quotes_list'), pchar) > -1 &&
|
||||||
\ index(b:_l_delimitMate_quotes_list, pchar) == index(b:_l_delimitMate_quotes_list, nchar) &&
|
\ index(s:g('quotes_list'), pchar)
|
||||||
|
\ == index(s:g('quotes_list'), nchar) &&
|
||||||
\ isSpaces
|
\ isSpaces
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
@@ -175,7 +182,8 @@ endfunction " }}}
|
|||||||
function! delimitMate#GetCurrentSyntaxRegionIf(char) "{{{
|
function! delimitMate#GetCurrentSyntaxRegionIf(char) "{{{
|
||||||
let col = col('.')
|
let col = col('.')
|
||||||
let origin_line = getline('.')
|
let origin_line = getline('.')
|
||||||
let changed_line = strpart(origin_line, 0, col - 1) . a:char . strpart(origin_line, col - 1)
|
let changed_line = strpart(origin_line, 0, col - 1) . a:char
|
||||||
|
\ . strpart(origin_line, col - 1)
|
||||||
call setline('.', changed_line)
|
call setline('.', changed_line)
|
||||||
let region = delimitMate#GetSyntaxRegion(line('.'), col)
|
let region = delimitMate#GetSyntaxRegion(line('.'), col)
|
||||||
call setline('.', origin_line)
|
call setline('.', origin_line)
|
||||||
@@ -183,17 +191,17 @@ function! delimitMate#GetCurrentSyntaxRegionIf(char) "{{{
|
|||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! delimitMate#IsForbidden(char) "{{{
|
function! delimitMate#IsForbidden(char) "{{{
|
||||||
if b:_l_delimitMate_excluded_regions_enabled == 0
|
if s:g('excluded_regions_enabled') == 0
|
||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
let region = delimitMate#GetCurrentSyntaxRegion()
|
let region = delimitMate#GetCurrentSyntaxRegion()
|
||||||
if index(b:_l_delimitMate_excluded_regions_list, region) >= 0
|
if index(s:g('excluded_regions_list'), region) >= 0
|
||||||
"echom "Forbidden 1!"
|
"echom "Forbidden 1!"
|
||||||
return 1
|
return 1
|
||||||
endif
|
endif
|
||||||
let region = delimitMate#GetCurrentSyntaxRegionIf(a:char)
|
let region = delimitMate#GetCurrentSyntaxRegionIf(a:char)
|
||||||
"echom "Forbidden 2!"
|
"echom "Forbidden 2!"
|
||||||
return index(b:_l_delimitMate_excluded_regions_list, region) >= 0
|
return index(s:g('excluded_regions_list'), region) >= 0
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! delimitMate#FlushBuffer() " {{{
|
function! delimitMate#FlushBuffer() " {{{
|
||||||
@@ -203,9 +211,9 @@ endfunction " }}}
|
|||||||
|
|
||||||
function! delimitMate#AddToBuffer(str, ...) "{{{
|
function! delimitMate#AddToBuffer(str, ...) "{{{
|
||||||
if a:0 && a:1 == 1
|
if a:0 && a:1 == 1
|
||||||
return add(b:_l_delimitMate_buffer, a:str)
|
return add(s:g('buffer'), a:str)
|
||||||
endif
|
endif
|
||||||
return insert(b:_l_delimitMate_buffer, a:str)
|
return insert(s:g('buffer'), a:str)
|
||||||
endfunction "delimitMate#AddToBuffer }}}
|
endfunction "delimitMate#AddToBuffer }}}
|
||||||
|
|
||||||
function! delimitMate#BalancedParens(char) "{{{
|
function! delimitMate#BalancedParens(char) "{{{
|
||||||
@@ -218,7 +226,7 @@ function! delimitMate#BalancedParens(char) "{{{
|
|||||||
let col = delimitMate#CursorIdx() - 1
|
let col = delimitMate#CursorIdx() - 1
|
||||||
let col = col >= 0 ? col : 0
|
let col = col >= 0 ? col : 0
|
||||||
let list = split(line, '\zs')
|
let list = split(line, '\zs')
|
||||||
let left = b:_l_delimitMate_left_delims[index(b:_l_delimitMate_right_delims, a:char)]
|
let left = s:g('left_delims')[index(s:g('right_delims'), a:char)]
|
||||||
let right = a:char
|
let right = a:char
|
||||||
let opening = 0
|
let opening = 0
|
||||||
let closing = 0
|
let closing = 0
|
||||||
@@ -246,14 +254,14 @@ function! delimitMate#BalancedParens(char) "{{{
|
|||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! delimitMate#RmBuffer(num) " {{{
|
function! delimitMate#RmBuffer(num) " {{{
|
||||||
if len(b:_l_delimitMate_buffer) > 0
|
if len(s:g('buffer')) > 0
|
||||||
call remove(b:_l_delimitMate_buffer, 0, (a:num-1))
|
call remove(s:g('buffer'), 0, (a:num-1))
|
||||||
endif
|
endif
|
||||||
return ""
|
return ""
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
|
|
||||||
function! delimitMate#IsSmartQuote(char) "{{{
|
function! delimitMate#IsSmartQuote(char) "{{{
|
||||||
if !b:_l_delimitMate_smart_quotes
|
if !s:g('smart_quotes')
|
||||||
return 0
|
return 0
|
||||||
endif
|
endif
|
||||||
let char_at = delimitMate#GetCharFromCursor(0)
|
let char_at = delimitMate#GetCharFromCursor(0)
|
||||||
@@ -307,18 +315,18 @@ function! delimitMate#ParenDelim(char) " {{{
|
|||||||
return ''
|
return ''
|
||||||
endif
|
endif
|
||||||
" Try to balance matchpairs
|
" Try to balance matchpairs
|
||||||
if b:_l_delimitMate_balance_matchpairs &&
|
if s:g('balance_matchpairs') &&
|
||||||
\ delimitMate#BalancedParens(a:char) <= 0
|
\ delimitMate#BalancedParens(a:char) <= 0
|
||||||
return ''
|
return ''
|
||||||
endif
|
endif
|
||||||
let line = getline('.')
|
let line = getline('.')
|
||||||
let col = col('.')-2
|
let col = col('.')-2
|
||||||
let tail = len(line) == (col + 1) ? b:_l_delimitMate_eol_marker : ''
|
let tail = len(line) == (col + 1) ? s:g('eol_marker') : ''
|
||||||
let left = b:_l_delimitMate_left_delims[index(b:_l_delimitMate_right_delims,a:char)]
|
let left = s:g('left_delims')[index(s:g('right_delims'),a:char)]
|
||||||
let smart_matchpairs = substitute(b:_l_delimitMate_smart_matchpairs, '\\!', left, 'g')
|
let smart_matchpairs = substitute(s:g('smart_matchpairs'), '\\!', left, 'g')
|
||||||
let smart_matchpairs = substitute(smart_matchpairs, '\\#', a:char, 'g')
|
let smart_matchpairs = substitute(smart_matchpairs, '\\#', a:char, 'g')
|
||||||
"echom left.':'.smart_matchpairs . ':' . matchstr(line[col+1], smart_matchpairs)
|
|
||||||
if b:_l_delimitMate_smart_matchpairs != '' &&
|
if s:g('smart_matchpairs') != '' &&
|
||||||
\ line[col+1:] =~ smart_matchpairs
|
\ line[col+1:] =~ smart_matchpairs
|
||||||
return ''
|
return ''
|
||||||
elseif (col) < 0
|
elseif (col) < 0
|
||||||
@@ -339,14 +347,14 @@ function! delimitMate#QuoteDelim(char) "{{{
|
|||||||
let char_at = delimitMate#GetCharFromCursor(0)
|
let char_at = delimitMate#GetCharFromCursor(0)
|
||||||
let char_before = delimitMate#GetCharFromCursor(-1)
|
let char_before = delimitMate#GetCharFromCursor(-1)
|
||||||
if char_at == a:char &&
|
if char_at == a:char &&
|
||||||
\ index(b:_l_delimitMate_nesting_quotes, a:char) < 0
|
\ index(s:g('nesting_quotes'), a:char) < 0
|
||||||
" Get out of the string.
|
" Get out of the string.
|
||||||
return a:char . delimitMate#Del()
|
return a:char . delimitMate#Del()
|
||||||
elseif delimitMate#IsSmartQuote(a:char)
|
elseif delimitMate#IsSmartQuote(a:char)
|
||||||
" Seems like a smart quote, insert a single char.
|
" Seems like a smart quote, insert a single char.
|
||||||
return a:char
|
return a:char
|
||||||
elseif (char_before == a:char && char_at != a:char)
|
elseif (char_before == a:char && char_at != a:char)
|
||||||
\ && b:_l_delimitMate_smart_quotes
|
\ && s:g('smart_quotes')
|
||||||
" Seems like we have an unbalanced quote, insert one quotation
|
" Seems like we have an unbalanced quote, insert one quotation
|
||||||
" mark and jump to the middle.
|
" mark and jump to the middle.
|
||||||
call delimitMate#AddToBuffer(a:char)
|
call delimitMate#AddToBuffer(a:char)
|
||||||
@@ -395,7 +403,8 @@ function! delimitMate#JumpAny(key) " {{{
|
|||||||
if char == " "
|
if char == " "
|
||||||
" Space expansion.
|
" Space expansion.
|
||||||
"let char = char . getline('.')[col('.')] . delimitMate#Del()
|
"let char = char . getline('.')[col('.')] . delimitMate#Del()
|
||||||
return char . getline('.')[col('.')] . delimitMate#Del() . delimitMate#Del()
|
return char . getline('.')[col('.')] . delimitMate#Del() .
|
||||||
|
\ delimitMate#Del()
|
||||||
"call delimitMate#RmBuffer(1)
|
"call delimitMate#RmBuffer(1)
|
||||||
elseif char == ""
|
elseif char == ""
|
||||||
" CR expansion.
|
" CR expansion.
|
||||||
@@ -413,8 +422,8 @@ function! delimitMate#JumpMany() " {{{
|
|||||||
let rights = ""
|
let rights = ""
|
||||||
let found = 0
|
let found = 0
|
||||||
for char in line
|
for char in line
|
||||||
if index(b:_l_delimitMate_quotes_list, char) >= 0 ||
|
if index(s:g('quotes_list'), char) >= 0 ||
|
||||||
\ index(b:_l_delimitMate_right_delims, char) >= 0
|
\ index(s:g('right_delims'), char) >= 0
|
||||||
let rights .= "\<Right>"
|
let rights .= "\<Right>"
|
||||||
let found = 1
|
let found = 1
|
||||||
elseif found == 0
|
elseif found == 0
|
||||||
@@ -438,8 +447,8 @@ function! delimitMate#ExpandReturn() "{{{
|
|||||||
" Expand:
|
" Expand:
|
||||||
call delimitMate#FlushBuffer()
|
call delimitMate#FlushBuffer()
|
||||||
|
|
||||||
" Not sure why I used the previous combos, but I'm sure somebody will tell
|
" Not sure why I used the previous combos, but I'm sure somebody will
|
||||||
" me about it.
|
" tell me about it.
|
||||||
" XXX zv prevents breaking expansion with syntax folding enabled by
|
" XXX zv prevents breaking expansion with syntax folding enabled by
|
||||||
" InsertLeave.
|
" InsertLeave.
|
||||||
return "\<Esc>a\<CR>\<Esc>zvO"
|
return "\<Esc>a\<CR>\<Esc>zvO"
|
||||||
@@ -452,7 +461,8 @@ function! delimitMate#ExpandSpace() "{{{
|
|||||||
if delimitMate#IsForbidden("\<Space>")
|
if delimitMate#IsForbidden("\<Space>")
|
||||||
return "\<Space>"
|
return "\<Space>"
|
||||||
endif
|
endif
|
||||||
let escaped = delimitMate#CursorIdx() >= 2 && delimitMate#GetCharFromCursor(-2) == '\'
|
let escaped = delimitMate#CursorIdx() >= 2
|
||||||
|
\ && delimitMate#GetCharFromCursor(-2) == '\'
|
||||||
if delimitMate#WithinEmptyPair() && !escaped
|
if delimitMate#WithinEmptyPair() && !escaped
|
||||||
" Expand:
|
" Expand:
|
||||||
call delimitMate#AddToBuffer('s')
|
call delimitMate#AddToBuffer('s')
|
||||||
@@ -463,17 +473,18 @@ function! delimitMate#ExpandSpace() "{{{
|
|||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
function! delimitMate#BS() " {{{
|
function! delimitMate#BS() " {{{
|
||||||
let buffer_tail = get(b:_l_delimitMate_buffer, '-1', '')
|
let buffer_tail = get(s:g('buffer'), '-1', '')
|
||||||
if delimitMate#IsForbidden("")
|
if delimitMate#IsForbidden("")
|
||||||
let extra = ''
|
let extra = ''
|
||||||
elseif &backspace !~ 'start\|2' && empty(b:_l_delimitMate_buffer)
|
elseif &backspace !~ 'start\|2' && empty(s:g('buffer'))
|
||||||
let extra = ''
|
let extra = ''
|
||||||
elseif delimitMate#WithinEmptyPair()
|
elseif delimitMate#WithinEmptyPair()
|
||||||
let extra = delimitMate#Del()
|
let extra = delimitMate#Del()
|
||||||
elseif delimitMate#IsSpaceExpansion()
|
elseif delimitMate#IsSpaceExpansion()
|
||||||
let extra = delimitMate#Del()
|
let extra = delimitMate#Del()
|
||||||
elseif delimitMate#IsCRExpansion()
|
elseif delimitMate#IsCRExpansion()
|
||||||
let extra = repeat("\<Del>", len(matchstr(getline(line('.') + 1), '^\s*\S')))
|
let extra = repeat("\<Del>",
|
||||||
|
\ len(matchstr(getline(line('.') + 1), '^\s*\S')))
|
||||||
else
|
else
|
||||||
let extra = ''
|
let extra = ''
|
||||||
endif
|
endif
|
||||||
@@ -490,7 +501,7 @@ function! delimitMate#BS() " {{{
|
|||||||
endfunction " }}} delimitMate#BS()
|
endfunction " }}} delimitMate#BS()
|
||||||
|
|
||||||
function! delimitMate#Del() " {{{
|
function! delimitMate#Del() " {{{
|
||||||
if len(b:_l_delimitMate_buffer) > 0
|
if len(s:g('buffer')) > 0
|
||||||
call delimitMate#RmBuffer(1)
|
call delimitMate#RmBuffer(1)
|
||||||
return "\<Del>"
|
return "\<Del>"
|
||||||
else
|
else
|
||||||
@@ -499,15 +510,14 @@ function! delimitMate#Del() " {{{
|
|||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
|
|
||||||
function! delimitMate#Finish(move_back) " {{{
|
function! delimitMate#Finish(move_back) " {{{
|
||||||
let len = len(b:_l_delimitMate_buffer)
|
let len = len(s:g('buffer'))
|
||||||
if len > 0
|
if len > 0
|
||||||
let buffer = join(b:_l_delimitMate_buffer, '')
|
let buffer = join(s:g('buffer'), '')
|
||||||
let len2 = len(buffer)
|
let len2 = len(buffer)
|
||||||
" Reset buffer:
|
" Reset buffer:
|
||||||
let b:_l_delimitMate_buffer = []
|
let b:_l_delimitMate_buffer = []
|
||||||
let line = getline('.')
|
let line = getline('.')
|
||||||
let col = col('.') -2
|
let col = col('.') -2
|
||||||
"echom 'col: ' . col . '-' . line[:col] . "|" . line[col+len+1:] . '%' . buffer
|
|
||||||
if col < 0
|
if col < 0
|
||||||
call setline('.', line[col+len2+1:])
|
call setline('.', line[col+len2+1:])
|
||||||
else
|
else
|
||||||
@@ -531,7 +541,8 @@ endfunction " }}}
|
|||||||
function! delimitMate#TestMappings() "{{{
|
function! delimitMate#TestMappings() "{{{
|
||||||
if &modified
|
if &modified
|
||||||
echohl WarningMsg
|
echohl WarningMsg
|
||||||
let answer = input("Modified buffer, type \"yes\" to write and proceed with test: ") !~ '\c^yes$'
|
let answer = input("Modified buffer, type \"yes\" to write and proceed "
|
||||||
|
\ . "with test: ") !~ '\c^yes$'
|
||||||
echohl NONE
|
echohl NONE
|
||||||
if answer != '\c^yes$'
|
if answer != '\c^yes$'
|
||||||
return
|
return
|
||||||
@@ -539,32 +550,41 @@ function! delimitMate#TestMappings() "{{{
|
|||||||
write
|
write
|
||||||
endif
|
endif
|
||||||
let options = sort(keys(delimitMate#OptionsList()))
|
let options = sort(keys(delimitMate#OptionsList()))
|
||||||
let optoutput = ['delimitMate Report', '==================', '', '* Options: ( ) default, (g) global, (b) buffer','']
|
let optoutput = ['delimitMate Report', '==================', '',
|
||||||
|
\ '* Options: ( ) default, (g) global, (b) buffer','']
|
||||||
for option in options
|
for option in options
|
||||||
exec 'call add(optoutput, ''('.(exists('b:delimitMate_'.option) ? 'b' : exists('g:delimitMate_'.option) ? 'g' : ' ').') delimitMate_''.option.'' = ''.string(b:_l_delimitMate_'.option.'))'
|
exec 'call add(optoutput, ''('.(exists('b:delimitMate_'.option) ? 'b'
|
||||||
|
\ : exists('g:delimitMate_'.option) ? 'g' : ' ')
|
||||||
|
\ .') delimitMate_''.option.'' = ''.string(b:_l_delimitMate_'
|
||||||
|
\ .option.'))'
|
||||||
endfor
|
endfor
|
||||||
call append(line('$'), optoutput + ['--------------------',''])
|
call append(line('$'), optoutput + ['--------------------',''])
|
||||||
|
|
||||||
" Check if mappings were set. {{{
|
" Check if mappings were set. {{{
|
||||||
let imaps = b:_l_delimitMate_right_delims
|
let imaps = s:g('right_delims')
|
||||||
let imaps = imaps + ( b:_l_delimitMate_autoclose ? b:_l_delimitMate_left_delims : [] )
|
let imaps = imaps + ( s:g('autoclose') ? s:g('left_delims') : [] )
|
||||||
let imaps = imaps +
|
let imaps = imaps +
|
||||||
\ b:_l_delimitMate_quotes_list +
|
\ s:g('quotes_list') +
|
||||||
\ b:_l_delimitMate_apostrophes_list +
|
\ s:g('apostrophes_list') +
|
||||||
\ ['<BS>', '<S-BS>', '<Del>', '<S-Tab>', '<Esc>'] +
|
\ ['<BS>', '<S-BS>', '<Del>', '<S-Tab>', '<Esc>'] +
|
||||||
\ ['<Up>', '<Down>', '<Left>', '<Right>', '<LeftMouse>', '<RightMouse>'] +
|
\ ['<Up>', '<Down>', '<Left>', '<Right>', '<LeftMouse>',
|
||||||
\ ['<Home>', '<End>', '<PageUp>', '<PageDown>', '<S-Down>', '<S-Up>', '<C-G>g'] +
|
\ '<RightMouse>'] +
|
||||||
|
\ ['<Home>', '<End>', '<PageUp>', '<PageDown>', '<S-Down>',
|
||||||
|
\ '<S-Up>', '<C-G>g'] +
|
||||||
\ ['<ScrollWheelUp>', '<S-ScrollWheelUp>', '<C-ScrollWheelUp>'] +
|
\ ['<ScrollWheelUp>', '<S-ScrollWheelUp>', '<C-ScrollWheelUp>'] +
|
||||||
\ ['<ScrollWheelDown>', '<S-ScrollWheelDown>', '<C-ScrollWheelDown>'] +
|
\ ['<ScrollWheelDown>', '<S-ScrollWheelDown>',
|
||||||
\ ['<ScrollWheelLeft>', '<S-ScrollWheelLeft>', '<C-ScrollWheelLeft>'] +
|
\ '<C-ScrollWheelDown>'] +
|
||||||
\ ['<ScrollWheelRight>', '<S-ScrollWheelRight>', '<C-ScrollWheelRight>']
|
\ ['<ScrollWheelLeft>', '<S-ScrollWheelLeft>',
|
||||||
let imaps = imaps + ( b:_l_delimitMate_expand_cr ? ['<CR>'] : [] )
|
\ '<C-ScrollWheelLeft>'] +
|
||||||
let imaps = imaps + ( b:_l_delimitMate_expand_space ? ['<Space>'] : [] )
|
\ ['<ScrollWheelRight>', '<S-ScrollWheelRight>',
|
||||||
|
\ '<C-ScrollWheelRight>']
|
||||||
|
let imaps = imaps + ( s:g('expand_cr') ? ['<CR>'] : [] )
|
||||||
|
let imaps = imaps + ( s:g('expand_space') ? ['<Space>'] : [] )
|
||||||
|
|
||||||
let vmaps =
|
let vmaps =
|
||||||
\ b:_l_delimitMate_right_delims +
|
\ s:g('right_delims') +
|
||||||
\ b:_l_delimitMate_left_delims +
|
\ s:g('left_delims') +
|
||||||
\ b:_l_delimitMate_quotes_list
|
\ s:g('quotes_list')
|
||||||
|
|
||||||
let imappings = []
|
let imappings = []
|
||||||
for map in imaps
|
for map in imaps
|
||||||
@@ -580,64 +600,84 @@ function! delimitMate#TestMappings() "{{{
|
|||||||
let output = ['* Mappings:', ''] + imappings + ['--------------------', '']
|
let output = ['* Mappings:', ''] + imappings + ['--------------------', '']
|
||||||
call append('$', output+['* Showcase:', ''])
|
call append('$', output+['* Showcase:', ''])
|
||||||
" }}}
|
" }}}
|
||||||
if b:_l_delimitMate_autoclose
|
if s:g('autoclose')
|
||||||
" {{{
|
" {{{
|
||||||
for i in range(len(b:_l_delimitMate_left_delims))
|
for i in range(len(s:g('left_delims')))
|
||||||
exec "normal Go0\<C-D>Open: " . b:_l_delimitMate_left_delims[i]. "|"
|
exec "normal Go0\<C-D>Open: " . s:g('left_delims')[i]. "|"
|
||||||
exec "normal o0\<C-D>Delete: " . b:_l_delimitMate_left_delims[i] . "\<BS>|"
|
exec "normal o0\<C-D>Delete: " . s:g('left_delims')[i] . "\<BS>|"
|
||||||
exec "normal o0\<C-D>Exit: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . "|"
|
exec "normal o0\<C-D>Exit: " . s:g('left_delims')[i] . s:g('right_delims')[i] . "|"
|
||||||
if b:_l_delimitMate_expand_space == 1
|
if s:g('expand_space') == 1
|
||||||
exec "normal o0\<C-D>Space: " . b:_l_delimitMate_left_delims[i] . " |"
|
exec "normal o0\<C-D>Space: " . s:g('left_delims')[i] . " |"
|
||||||
exec "normal o0\<C-D>Delete space: " . b:_l_delimitMate_left_delims[i] . " \<BS>|"
|
exec "normal o0\<C-D>Delete space: " . s:g('left_delims')[i]
|
||||||
|
\ . " \<BS>|"
|
||||||
endif
|
endif
|
||||||
if b:_l_delimitMate_expand_cr == 1
|
if s:g('expand_cr') == 1
|
||||||
exec "normal o0\<C-D>Car return: " . b:_l_delimitMate_left_delims[i] . "\<CR>|"
|
exec "normal o0\<C-D>Car return: " . s:g('left_delims')[i] .
|
||||||
exec "normal Go0\<C-D>Delete car return: " . b:_l_delimitMate_left_delims[i] . "\<CR>0\<C-D>\<BS>|"
|
\ "\<CR>|"
|
||||||
|
exec "normal Go0\<C-D>Delete car return: " . s:g('left_delims')[i]
|
||||||
|
\ . "\<CR>0\<C-D>\<BS>|"
|
||||||
endif
|
endif
|
||||||
call append(line('$'), '')
|
call append(line('$'), '')
|
||||||
endfor
|
endfor
|
||||||
for i in range(len(b:_l_delimitMate_quotes_list))
|
for i in range(len(s:g('quotes_list')))
|
||||||
exec "normal Go0\<C-D>Open: " . b:_l_delimitMate_quotes_list[i] . "|"
|
exec "normal Go0\<C-D>Open: " . s:g('quotes_list')[i] . "|"
|
||||||
exec "normal o0\<C-D>Delete: " . b:_l_delimitMate_quotes_list[i] . "\<BS>|"
|
exec "normal o0\<C-D>Delete: " . s:g('quotes_list')[i] . "\<BS>|"
|
||||||
exec "normal o0\<C-D>Exit: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "|"
|
exec "normal o0\<C-D>Exit: " . s:g('quotes_list')[i] . s:g('quotes_list')[i] . "|"
|
||||||
if b:_l_delimitMate_expand_space == 1
|
if s:g('expand_space') == 1
|
||||||
exec "normal o0\<C-D>Space: " . b:_l_delimitMate_quotes_list[i] . " |"
|
exec "normal o0\<C-D>Space: " . s:g('quotes_list')[i] . " |"
|
||||||
exec "normal o0\<C-D>Delete space: " . b:_l_delimitMate_quotes_list[i] . " \<BS>|"
|
exec "normal o0\<C-D>Delete space: " . s:g('quotes_list')[i]
|
||||||
|
\ . " \<BS>|"
|
||||||
endif
|
endif
|
||||||
if b:_l_delimitMate_expand_cr == 1
|
if s:g('expand_cr') == 1
|
||||||
exec "normal o0\<C-D>Car return: " . b:_l_delimitMate_quotes_list[i] . "\<CR>|"
|
exec "normal o0\<C-D>Car return: " . s:g('quotes_list')[i]
|
||||||
exec "normal Go0\<C-D>Delete car return: " . b:_l_delimitMate_quotes_list[i] . "\<CR>\<BS>|"
|
\ . "\<CR>|"
|
||||||
|
exec "normal Go0\<C-D>Delete car return: " . s:g('quotes_list')[i]
|
||||||
|
\ . "\<CR>\<BS>|"
|
||||||
endif
|
endif
|
||||||
call append(line('$'), '')
|
call append(line('$'), '')
|
||||||
endfor
|
endfor
|
||||||
"}}}
|
"}}}
|
||||||
else
|
else
|
||||||
"{{{
|
"{{{
|
||||||
for i in range(len(b:_l_delimitMate_left_delims))
|
for i in range(len(s:g('left_delims')))
|
||||||
exec "normal GoOpen & close: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . "|"
|
exec "normal GoOpen & close: " . s:g('left_delims')[i]
|
||||||
exec "normal oDelete: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . "\<BS>|"
|
\ . s:g('right_delims')[i] . "|"
|
||||||
exec "normal oExit: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . b:_l_delimitMate_right_delims[i] . "|"
|
exec "normal oDelete: " . s:g('left_delims')[i]
|
||||||
if b:_l_delimitMate_expand_space == 1
|
\ . s:g('right_delims')[i] . "\<BS>|"
|
||||||
exec "normal oSpace: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . " |"
|
exec "normal oExit: " . s:g('left_delims')[i] . s:g('right_delims')[i]
|
||||||
exec "normal oDelete space: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . " \<BS>|"
|
\ . s:g('right_delims')[i] . "|"
|
||||||
|
if s:g('expand_space') == 1
|
||||||
|
exec "normal oSpace: " . s:g('left_delims')[i]
|
||||||
|
\ . s:g('right_delims')[i] . " |"
|
||||||
|
exec "normal oDelete space: " . s:g('left_delims')[i]
|
||||||
|
\ . s:g('right_delims')[i] . " \<BS>|"
|
||||||
endif
|
endif
|
||||||
if b:_l_delimitMate_expand_cr == 1
|
if s:g('expand_cr') == 1
|
||||||
exec "normal oCar return: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . "\<CR>|"
|
exec "normal oCar return: " . s:g('left_delims')[i]
|
||||||
exec "normal GoDelete car return: " . b:_l_delimitMate_left_delims[i] . b:_l_delimitMate_right_delims[i] . "\<CR>\<BS>|"
|
\ . s:g('right_delims')[i] . "\<CR>|"
|
||||||
|
exec "normal GoDelete car return: " . s:g('left_delims')[i]
|
||||||
|
\ . s:g('right_delims')[i] . "\<CR>\<BS>|"
|
||||||
endif
|
endif
|
||||||
call append(line('$'), '')
|
call append(line('$'), '')
|
||||||
endfor
|
endfor
|
||||||
for i in range(len(b:_l_delimitMate_quotes_list))
|
for i in range(len(s:g('quotes_list')))
|
||||||
exec "normal GoOpen & close: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "|"
|
exec "normal GoOpen & close: " . s:g('quotes_list')[i]
|
||||||
exec "normal oDelete: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "\<BS>|"
|
\ . s:g('quotes_list')[i] . "|"
|
||||||
exec "normal oExit: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "|"
|
exec "normal oDelete: " . s:g('quotes_list')[i]
|
||||||
if b:_l_delimitMate_expand_space == 1
|
\ . s:g('quotes_list')[i] . "\<BS>|"
|
||||||
exec "normal oSpace: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . " |"
|
exec "normal oExit: " . s:g('quotes_list')[i] . s:g('quotes_list')[i]
|
||||||
exec "normal oDelete space: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . " \<BS>|"
|
\ . s:g('quotes_list')[i] . "|"
|
||||||
|
if s:g('expand_space') == 1
|
||||||
|
exec "normal oSpace: " . s:g('quotes_list')[i]
|
||||||
|
\ . s:g('quotes_list')[i] . " |"
|
||||||
|
exec "normal oDelete space: " . s:g('quotes_list')[i]
|
||||||
|
\ . s:g('quotes_list')[i] . " \<BS>|"
|
||||||
endif
|
endif
|
||||||
if b:_l_delimitMate_expand_cr == 1
|
if s:g('expand_cr') == 1
|
||||||
exec "normal oCar return: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "\<CR>|"
|
exec "normal oCar return: " . s:g('quotes_list')[i]
|
||||||
exec "normal GoDelete car return: " . b:_l_delimitMate_quotes_list[i] . b:_l_delimitMate_quotes_list[i] . "\<CR>\<BS>|"
|
\ . s:g('quotes_list')[i] . "\<CR>|"
|
||||||
|
exec "normal GoDelete car return: " . s:g('quotes_list')[i]
|
||||||
|
\ . s:g('quotes_list')[i] . "\<CR>\<BS>|"
|
||||||
endif
|
endif
|
||||||
call append(line('$'), '')
|
call append(line('$'), '')
|
||||||
endfor
|
endfor
|
||||||
@@ -649,7 +689,11 @@ 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, 'smart_matchpairs' : '\w', 'balance_matchpairs' : 0, 'excluded_regions' : 'Comment', 'excluded_ft' : '', 'eol_marker': '', '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' : '', 'eol_marker': '', 'apostrophes' : ''}
|
||||||
endfunction " delimitMate#OptionsList }}}
|
endfunction " delimitMate#OptionsList }}}
|
||||||
"}}}
|
"}}}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user