Refactoring EasyMotion#init#InitMappings
Now you can chose do mapping or preparing <Plug> only
This commit is contained in:
parent
0bffa2ddc2
commit
ead7164a4b
@ -41,7 +41,7 @@ function! EasyMotion#init#InitHL(group, colors) " {{{
|
|||||||
execute printf('hi default link %s %s', a:group, group_default)
|
execute printf('hi default link %s %s', a:group, group_default)
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
|
|
||||||
function! EasyMotion#init#InitMappings(motions) "{{{
|
function! EasyMotion#init#InitMappings(motions, do_mapping) "{{{
|
||||||
for [motion, fn] in items(a:motions)
|
for [motion, fn] in items(a:motions)
|
||||||
silent exec 'nnoremap <silent>
|
silent exec 'nnoremap <silent>
|
||||||
\ <Plug>(easymotion-' . motion . ')
|
\ <Plug>(easymotion-' . motion . ')
|
||||||
@ -52,7 +52,7 @@ function! EasyMotion#init#InitMappings(motions) "{{{
|
|||||||
silent exec 'vnoremap <silent>
|
silent exec 'vnoremap <silent>
|
||||||
\ <Plug>(easymotion-' . motion . ')
|
\ <Plug>(easymotion-' . motion . ')
|
||||||
\ :<C-u>call EasyMotion#' . fn.name . '(1, ' . fn.dir . ')<CR>'
|
\ :<C-u>call EasyMotion#' . fn.name . '(1, ' . fn.dir . ')<CR>'
|
||||||
if g:EasyMotion_do_mapping && !hasmapto('<Plug>(easymotion-' . motion . ')')
|
if a:do_mapping && !hasmapto('<Plug>(easymotion-' . motion . ')')
|
||||||
silent exec 'map <silent> ' .
|
silent exec 'map <silent> ' .
|
||||||
\ g:EasyMotion_leader_key . motion . ' <Plug>(easymotion-' . motion . ')'
|
\ g:EasyMotion_leader_key . motion . ' <Plug>(easymotion-' . motion . ')'
|
||||||
endif
|
endif
|
||||||
|
@ -103,7 +103,7 @@ set cpo&vim
|
|||||||
\ , 'k' : { 'name': 'JK' , 'dir': 1 }
|
\ , 'k' : { 'name': 'JK' , 'dir': 1 }
|
||||||
\ , 'n' : { 'name': 'Search' , 'dir': 0 }
|
\ , 'n' : { 'name': 'Search' , 'dir': 0 }
|
||||||
\ , 'N' : { 'name': 'Search' , 'dir': 1 }
|
\ , 'N' : { 'name': 'Search' , 'dir': 1 }
|
||||||
\ })
|
\ }, g:EasyMotion_do_mapping)
|
||||||
" }}}
|
" }}}
|
||||||
" Special mapping for other functions {{{
|
" Special mapping for other functions {{{
|
||||||
call EasyMotion#init#InitSpecialMappings({
|
call EasyMotion#init#InitSpecialMappings({
|
||||||
@ -111,11 +111,13 @@ set cpo&vim
|
|||||||
\ , 'p' : { 'name': 'SelectPhrase'}
|
\ , 'p' : { 'name': 'SelectPhrase'}
|
||||||
\ })
|
\ })
|
||||||
" }}}
|
" }}}
|
||||||
" More functions {{{
|
" Prepare more key mapping {{{
|
||||||
noremap <Plug>(easymotion-bd-w) :<C-u>call EasyMotion#WB(0,2)<CR>
|
call EasyMotion#init#InitMappings({
|
||||||
noremap <Plug>(easymotion-bd-e) :<C-u>call EasyMotion#E(0,2)<CR>
|
\ 'bd-w' : { 'name': 'WB' , 'dir': 2 }
|
||||||
noremap <Plug>(easymotion-bd-n) :<C-u>call EasyMotion#Search(0,2)<CR>
|
\ , 'bd-e' : { 'name': 'E' , 'dir': 2 }
|
||||||
noremap <Plug>(easymotion-bd-jk) :<C-u>call EasyMotion#JK(0,2)<CR>
|
\ , 'bd-n' : { 'name': 'Search' , 'dir': 2 }
|
||||||
|
\ , 'bd-jk' : { 'name': 'JK' , 'dir': 2 }
|
||||||
|
\ }, 0) " Prepare <Plug> but don't map by default.
|
||||||
" }}}
|
" }}}
|
||||||
" }}}
|
" }}}
|
||||||
" Restore 'cpoptions' {{{
|
" Restore 'cpoptions' {{{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user