Add smartsign feature like smartcase

Now, you can jump to '!' by '1'.
Option: keyboard layout
    g:EasyMotion_use_smartsign_us
    g:EasyMotion_use_smartsign_jp
This commit is contained in:
haya14busa 2013-12-29 14:29:05 +09:00
parent 9185b1362a
commit 4c55ab61ac
2 changed files with 60 additions and 6 deletions

View File

@ -339,7 +339,7 @@ endfunction "}}}
function! s:findMotion(char) "{{{
" Find Motion: S,F,T
let re = escape(a:char, '.$^~')
let re = escape(a:char, '.$^~\')
if g:EasyMotion_use_migemo
let re = s:convertMigemo(re)
@ -362,12 +362,43 @@ endfunction "}}}
return re
endfunction "}}}
function! s:convertSmartcase(re, char) "{{{
if a:char =~# '\v\U'
let re = '\c' . a:re
else
let re = '\C' . a:re
let re = a:re
if a:char =~# '\U' "nonuppercase
if s:useSmartsign()
let re = s:convertSmartsign(a:re, a:char)
endif
return '\c' . re
else "uppercase
return '\C' . re
endif
endfunction "}}}
function! s:convertSmartsign(re, char) "{{{
let smart_dict = s:load_smart_dict()
let upper_sign = escape(get(smart_dict, a:char, ''), '.$^~')
if upper_sign ==# ''
return a:re
else
let re = a:re . '\|' . upper_sign
return re
endif
endfunction "}}}
function! s:useSmartsign() "{{{
if exists('g:EasyMotion_use_smartsign_us') ||
\ exists('g:EasyMotion_use_smartsign_jp')
return 1
else
return 0
endif
endfunction "}}}
function! s:load_smart_dict() "{{{
if exists('g:EasyMotion_use_smartsign_us')
return g:EasyMotion#sticky_table#us
elseif exists('g:EasyMotion_use_smartsign_jp')
return g:EasyMotion#sticky_table#jp
else
return ''
endif
return re
endfunction "}}}
" }}}

View File

@ -0,0 +1,23 @@
" Saving 'cpoptions' {{{
let s:save_cpo = &cpo
set cpo&vim
" }}}
"
let EasyMotion#sticky_table#us = {
\',' : '<', '.' : '>', '/' : '?',
\'1' : '!', '2' : '@', '3' : '#', '4' : '$', '5' : '%',
\'6' : '^', '7' : '&', '8' : '*', '9' : '(', '0' : ')', '-' : '_', '=' : '+',
\';' : ':', '[' : '{', ']' : '}', '`' : '~', "'" : "\"", '\' : '|',
\}
let EasyMotion#sticky_table#jp = {
\',' : '<', '.' : '>', '/' : '?',
\'1' : '!', '2' : '"', '3' : '#', '4' : '$', '5' : '%',
\'6' : '&', '7' : "'", '8' : '(', '9' : ')', '0' : '_', '-' : '=', '^' : '~',
\';' : '+', ':' : '*', '[' : '{', ']' : '}', '@' : '`', '\' : '|',
\}
" Restore 'cpoptions' {{{
let &cpo = s:save_cpo
unlet s:save_cpo
" }}}