Support migemo & smartsign to SelectPhrase
And some refactoring Escape '[' & ']' in s:findmotion for SelectPhrase
This commit is contained in:
parent
1ea0af6119
commit
9d474722d5
@ -236,33 +236,58 @@ function! EasyMotion#SelectPhrase() "{{{
|
|||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
" Generate regexp {{{
|
||||||
|
if chars[0] ==# chars[1]
|
||||||
|
let re = s:findMotion(chars[0])
|
||||||
|
else
|
||||||
|
" Convert chars {{{
|
||||||
|
" let g:EasyMotion_smartcase to 0 temporarily
|
||||||
|
let save_smart = g:EasyMotion_smartcase
|
||||||
|
let g:EasyMotion_smartcase = 0
|
||||||
|
|
||||||
|
let re1 = s:findMotion(chars[0])
|
||||||
|
let re2 = s:findMotion(chars[1])
|
||||||
|
|
||||||
|
let g:EasyMotion_smartcase = save_smart
|
||||||
|
unlet save_smart
|
||||||
|
"}}}
|
||||||
|
|
||||||
|
let re = re1 . '\|' . re2
|
||||||
|
|
||||||
|
if g:EasyMotion_smartcase && chars[0] =~# '\U' || chars[1] =~# '\U'
|
||||||
|
let re = '\c' . re
|
||||||
|
else
|
||||||
|
let re = '\C' . re
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
"}}}
|
||||||
|
|
||||||
|
" Store original pos
|
||||||
let orig_pos = [line('.'), col('.')]
|
let orig_pos = [line('.'), col('.')]
|
||||||
|
|
||||||
if g:EasyMotion_smartcase && chars[0] =~# '\v\U' || chars[1] =~# '\v\U'
|
" First
|
||||||
let re = '\c'
|
|
||||||
else
|
|
||||||
let re = '\C'
|
|
||||||
endif
|
|
||||||
|
|
||||||
let re = re . escape(chars[0], '.$^~') . '\|' . escape(chars[1], '.$^~')
|
|
||||||
call s:EasyMotion(re, 2, '', '', 0, 0, 0, 0)
|
call s:EasyMotion(re, 2, '', '', 0, 0, 0, 0)
|
||||||
if s:EasyMotion_cancelled
|
if s:EasyMotion_cancelled
|
||||||
keepjumps call cursor(orig_pos[0], orig_pos[1])
|
keepjumps call cursor(orig_pos[0], orig_pos[1])
|
||||||
return ''
|
return ''
|
||||||
else
|
|
||||||
let pos1 = [line('.'), col('.')]
|
|
||||||
keepjumps call cursor(orig_pos[0], orig_pos[1])
|
|
||||||
call s:EasyMotion(re, 2, '', '', 0, 0, 0, pos1)
|
|
||||||
if s:EasyMotion_cancelled
|
|
||||||
keepjumps call cursor(orig_pos[0], orig_pos[1])
|
|
||||||
return ''
|
|
||||||
else
|
|
||||||
normal! v
|
|
||||||
keepjumps call cursor(pos1[0], pos1[1])
|
|
||||||
normal! o
|
|
||||||
return 1
|
|
||||||
endif
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
" Store first pos
|
||||||
|
let pos1 = [line('.'), col('.')]
|
||||||
|
keepjumps call cursor(orig_pos[0], orig_pos[1])
|
||||||
|
|
||||||
|
" Second
|
||||||
|
call s:EasyMotion(re, 2, '', '', 0, 0, 0, pos1)
|
||||||
|
if s:EasyMotion_cancelled
|
||||||
|
keepjumps call cursor(orig_pos[0], orig_pos[1])
|
||||||
|
return ''
|
||||||
|
endif
|
||||||
|
|
||||||
|
" Success
|
||||||
|
normal! v
|
||||||
|
keepjumps call cursor(pos1[0], pos1[1])
|
||||||
|
normal! o
|
||||||
|
return 1
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
function! EasyMotion#SelectPhraseYank() "{{{
|
function! EasyMotion#SelectPhraseYank() "{{{
|
||||||
let orig_pos = [line('.'), col('.')]
|
let orig_pos = [line('.'), col('.')]
|
||||||
@ -431,12 +456,16 @@ endfunction " }}}
|
|||||||
" -- Find Motion Helper ------------------
|
" -- Find Motion Helper ------------------
|
||||||
function! s:findMotion(char) "{{{
|
function! s:findMotion(char) "{{{
|
||||||
" Find Motion: S,F,T
|
" Find Motion: S,F,T
|
||||||
let re = escape(a:char, '.$^~\')
|
let re = escape(a:char, '.$^~\[]')
|
||||||
|
|
||||||
if g:EasyMotion_use_migemo && a:char =~# '\a'
|
if g:EasyMotion_use_migemo && a:char =~# '\a'
|
||||||
let re = s:convertMigemo(re)
|
let re = s:convertMigemo(re)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if s:useSmartsign(a:char)
|
||||||
|
let re = s:convertSmartsign(re, a:char)
|
||||||
|
endif
|
||||||
|
|
||||||
if g:EasyMotion_smartcase
|
if g:EasyMotion_smartcase
|
||||||
let re = s:convertSmartcase(re, a:char)
|
let re = s:convertSmartcase(re, a:char)
|
||||||
endif
|
endif
|
||||||
@ -456,10 +485,6 @@ endfunction "}}}
|
|||||||
function! s:convertSmartcase(re, char) "{{{
|
function! s:convertSmartcase(re, char) "{{{
|
||||||
let re = a:re
|
let re = a:re
|
||||||
if a:char =~# '\U' "nonuppercase
|
if a:char =~# '\U' "nonuppercase
|
||||||
if s:useSmartsign()
|
|
||||||
let re = s:convertSmartsign(a:re, a:char)
|
|
||||||
endif
|
|
||||||
|
|
||||||
return '\c' . re
|
return '\c' . re
|
||||||
else "uppercase
|
else "uppercase
|
||||||
return '\C' . re
|
return '\C' . re
|
||||||
@ -475,9 +500,10 @@ function! s:convertSmartsign(re, char) "{{{
|
|||||||
return re
|
return re
|
||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
function! s:useSmartsign() "{{{
|
function! s:useSmartsign(char) "{{{
|
||||||
if exists('g:EasyMotion_use_smartsign_us') ||
|
if (exists('g:EasyMotion_use_smartsign_us') ||
|
||||||
\ exists('g:EasyMotion_use_smartsign_jp')
|
\ exists('g:EasyMotion_use_smartsign_jp')) &&
|
||||||
|
\ a:char =~# '\A'
|
||||||
return 1
|
return 1
|
||||||
else
|
else
|
||||||
return 0
|
return 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user