mirror of
https://github.com/Raimondi/delimitMate.git
synced 2025-12-06 12:44:27 +08:00
Add jump_expansion
This commit is contained in:
@@ -186,7 +186,8 @@ function! delimitMate#TextChangedI(...) "{{{1
|
||||
echom 23
|
||||
if s:option('expand_cr') && !empty(pair)
|
||||
echom "23.1"
|
||||
return feedkeys("\<Del>")
|
||||
let spaces = strchars(s:info.cur.next_line, '^\s*')
|
||||
return feedkeys(repeat("\<Del>", spaces), 'nti')
|
||||
endif
|
||||
let quote = filter(s:option('quotes'), 's:info.cur.p_char . matchstr(s:info.cur.next_line, "^\\s*\\zs\\S") ==# v:val.v:val')
|
||||
if s:option('expand_cr') && s:option('expand_inside_quotes') && !empty(quote)
|
||||
@@ -322,6 +323,15 @@ function! s:keys4left(char, pair, info, opts) "{{{1
|
||||
endfunction
|
||||
|
||||
function! s:keys4right(char, pair, info, opts) "{{{1
|
||||
if a:opts.jump_expansion
|
||||
echom 40
|
||||
let around = matchstr(a:info.cur.prev_line, "\\S$") . matchstr(a:info.cur.next_line, "^\\s*\zs\\S")
|
||||
if empty(a:info.cur.ahead) && a:char ==# matchstr(a:info.cur.next_line, "^\\s*\\zs\\S")
|
||||
let rights = strchars(matchstr(a:info.cur.next_line, '^\s*')) + 2
|
||||
echom "40.1"
|
||||
return "\<Esc>s" . repeat("\<Right>", rights)
|
||||
endif
|
||||
endif
|
||||
if !a:opts.autoclose
|
||||
if s:info.cur.around == a:pair
|
||||
echom 41
|
||||
@@ -383,9 +393,12 @@ endfunction
|
||||
function! s:keys4cr(info, opts) "{{{1
|
||||
if a:opts.expand_cr
|
||||
\&& !empty(filter(copy(a:opts.pairs), 'v:val ==# a:info.prev.around'))
|
||||
\|| (a:opts.expand_cr == 2 && !empty(filter(copy(a:opts.pairs), 'strcharpart(v:val, 1, 1) == a:info.cur.n_char')))
|
||||
" Empty pair
|
||||
echom 71
|
||||
return "\<Up>\<End>\<CR>"
|
||||
let right = a:info.cur.line
|
||||
let rm_spaces = empty(a:info.cur.behind) ? '' : "\<C-U>"
|
||||
return rm_spaces . "\<Del>x\<C-G>U\<Left>\<BS>\<CR>" . a:info.cur.n_char . "\<Del>\<Up>\<End>\<CR>"
|
||||
endif
|
||||
if a:opts.expand_cr && a:opts.expand_inside_quotes
|
||||
\&& !empty(filter(copy(a:opts.quotes), 'v:val.v:val ==# a:info.prev.around'))
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
let &rtp = expand('<sfile>:p:h:h') . ',' . &rtp . ',' . expand('<sfile>:p:h:h') . '/after'
|
||||
set bs=2
|
||||
set hidden
|
||||
set whichwrap=[]
|
||||
let g:delimitMate_pairs = ['()','{}','[]','<>','¿?','¡!',',:']
|
||||
let g:delimitMate_quotes = ['"', "'", '`', '«', '|']
|
||||
ru plugin/delimitMate.vim
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
" - Add 5 to vimtap#Plan().
|
||||
|
||||
call vimtest#StartTap()
|
||||
call vimtap#Plan(25)
|
||||
call vimtap#Plan(26)
|
||||
|
||||
|
||||
let g:delimitMate_expand_cr = 1
|
||||
"let g:delimitMate_eol_marker = ';'
|
||||
@@ -36,26 +37,37 @@ call DMTest_single('', "i( \<CR>\<BS>\<BS>x", '(x)')
|
||||
|
||||
" Conflict with indentation settings (cindent). Issue #95
|
||||
se cindent
|
||||
|
||||
call DMTest_single(
|
||||
\ ['sub foo {',
|
||||
\ ' while (1) {',
|
||||
\ ' ',
|
||||
\ '',
|
||||
\ ' }',
|
||||
\ '}'],
|
||||
\ "i\<Esc>3G8|a}x",
|
||||
\ "3Gi\<BS>x",
|
||||
\ ['sub foo {',
|
||||
\ ' while (1) {x}',
|
||||
\ '}'])
|
||||
|
||||
call DMTest_single(
|
||||
\ ['sub foo {',
|
||||
\ ' while (1) {',
|
||||
\ ' ',
|
||||
\ ' bar',
|
||||
\ ' }',
|
||||
\ '}'],
|
||||
\ "3GA}x",
|
||||
\ ['sub foo {',
|
||||
\ ' while (1) {',
|
||||
\ ' bar',
|
||||
\ ' }x',
|
||||
\ '}'])
|
||||
|
||||
call DMTest_single('"{bracketed}', "\<Esc>A\"x", '"{bracketed}"x')
|
||||
|
||||
" Syntax folding enabled by autocmd breaks expansion. But ti can't be tested
|
||||
" with :normal
|
||||
" Syntax folding enabled by autocmd breaks expansion.
|
||||
new
|
||||
autocmd InsertEnter * let w:fdm=&foldmethod | setl foldmethod=manual
|
||||
autocmd InsertLeave * let &foldmethod = w:fdm
|
||||
autocmd InsertEnter <buffer> let w:fdm=&foldmethod | setl foldmethod=manual
|
||||
autocmd InsertLeave <buffer> let &foldmethod = w:fdm
|
||||
set foldmethod=marker
|
||||
set foldmarker={,}
|
||||
set foldlevel=0
|
||||
@@ -64,7 +76,7 @@ call DMTest_single('', "iabc {\<CR>x",
|
||||
\['abc {',
|
||||
\ ' x',
|
||||
\ '}'])
|
||||
|
||||
:bp
|
||||
" expand_cr != 2
|
||||
call DMTest_single('abc(def)', "i\<Esc>$i\<CR>x",
|
||||
\ ['abc(def',
|
||||
@@ -72,12 +84,14 @@ call DMTest_single('abc(def)', "i\<Esc>$i\<CR>x",
|
||||
|
||||
" expand_cr == 2
|
||||
let delimitMate_expand_cr = 2
|
||||
call DMTest_single('abc(def)', "i\<Esc>$i\<CR>x", ['abc(def', ' x', ' )'])
|
||||
call DMTest_single('abc(def)', "$i\<CR>x", ['abc(def', ' x', ' )'])
|
||||
|
||||
" Play nice with smartindent
|
||||
set all&
|
||||
set whichwrap=[]
|
||||
set bs=2
|
||||
set smartindent
|
||||
call DMTest_single('', "i\<Esc>$i{\<CR>x", ['{', ' x', '}'])
|
||||
call DMTest_single('', "i{\<CR>x", ['{', ' x', '}'])
|
||||
|
||||
call DMTest_quotes('', "i' x", "' x'")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user