Plug support for EasyMotion prefix (leader) key

This commit is contained in:
haya14busa 2014-01-10 19:55:05 +09:00
parent d3bbdd90cc
commit d0352aacfd
2 changed files with 20 additions and 12 deletions

View File

@ -62,11 +62,11 @@ function! EasyMotion#init#InitMappings(motions, do_mapping) "{{{
\ eval('g:EasyMotion_mapping_' . motion) . ' <Plug>(easymotion-' . motion . ')'
elseif a:do_mapping
\ && !hasmapto('<Plug>(easymotion-' . motion . ')')
\ && empty(maparg(g:EasyMotion_leader_key . motion, 'nov'))
\ && empty(maparg('<Plug>(easymotion-prefix)' . motion, 'nov'))
" Do mapping
silent exec 'map <silent> ' .
\ g:EasyMotion_leader_key . motion . ' <Plug>(easymotion-' . motion . ')'
\'<Plug>(easymotion-prefix)' . motion . ' <Plug>(easymotion-' . motion . ')'
endif "}}}
endfor
@ -86,18 +86,18 @@ function! EasyMotion#init#InitSpecialMappings(motions, do_mapping) "{{{
" Do mapping {{{
if a:do_mapping
\ && !hasmapto('<Plug>(easymotion-special-' . motion . ')')
\ && empty(maparg(g:EasyMotion_leader_key . motion, 'ov'))
\ && empty(maparg('d' . g:EasyMotion_leader_key . motion, 'n'))
\ && empty(maparg('y' . g:EasyMotion_leader_key . motion, 'n'))
\ && empty(maparg('<Plug>(easymotion-prefix)' . motion, 'ov'))
\ && empty(maparg('d<Plug>(easymotion-prefix)'. motion, 'n'))
\ && empty(maparg('y<Plug>(easymotion-prefix)'. motion, 'n'))
silent exec 'omap <silent> ' .
\ g:EasyMotion_leader_key . motion . ' <Plug>(easymotion-special-' . motion . ')'
\ '<Plug>(easymotion-prefix)' . motion . ' <Plug>(easymotion-special-' . motion . ')'
silent exec 'xmap <silent> ' .
\ g:EasyMotion_leader_key . motion . ' <Plug>(easymotion-special-' . motion . ')'
\ '<Plug>(easymotion-prefix)' . motion . ' <Plug>(easymotion-special-' . motion . ')'
silent exec 'nmap <silent> ' .
\ 'd' . g:EasyMotion_leader_key . motion . ' d<Plug>(easymotion-special-' . motion . ')'
\ 'd<Plug>(easymotion-prefix)' . motion . ' d<Plug>(easymotion-special-' . motion . ')'
silent exec 'nmap <silent> ' .
\ 'y' . g:EasyMotion_leader_key . motion . ' y<Plug>(easymotion-special-' . motion . ')'
\ 'y<Plug>(easymotion-prefix)' . motion . ' y<Plug>(easymotion-special-' . motion . ')'
endif "}}}
endfor
endfunction "}}}

View File

@ -16,11 +16,19 @@ set cpo&vim
" }}}
" Default configuration {{{
" Default options {{{
let g:EasyMotion_do_mapping = get(g:, 'EasyMotion_do_mapping', 1)
if g:EasyMotion_do_mapping == 1
if exists('g:EasyMotion_leader_key')
exec 'map ' . g:EasyMotion_leader_key . ' <Plug>(easymotion-prefix)'
else
if !hasmapto('<Plug>(easymotion-prefix)')
map <Leader><Leader> <Plug>(easymotion-prefix)
endif
endif
endif
call EasyMotion#init#InitOptions({
\ 'leader_key' : '<Leader><Leader>'
\ , 'keys' : 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
\ 'keys' : 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
\ , 'do_shade' : 1
\ , 'do_mapping' : 1
\ , 'do_special_mapping' : 0
\ , 'grouping' : 1
\ , 'startofline' : 1