From 33bf1de0f8536a498c8cfb798463b44dfa049596 Mon Sep 17 00:00:00 2001 From: haya14busa Date: Thu, 23 Jan 2014 11:38:00 +0900 Subject: [PATCH] Implement activate function For clever motion & highlight --- autoload/EasyMotion.vim | 9 +++++++++ plugin/EasyMotion.vim | 3 +++ t/easymotion_spec.vim | 11 ++++++++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/autoload/EasyMotion.vim b/autoload/EasyMotion.vim index 587963e..3505065 100644 --- a/autoload/EasyMotion.vim +++ b/autoload/EasyMotion.vim @@ -761,6 +761,15 @@ endfunction "}}} function! EasyMotion#is_active() "{{{ return s:EasyMotion_is_active endfunction "}}} +function! EasyMotion#activate(is_visual) "{{{ + let s:EasyMotion_is_active = 1 + call EasyMotion#attach_active_autocmd() + call EasyMotion#highlight#add_highlight(s:previous.regexp, 'EasyMotionMoveHL') + call EasyMotion#highlight#attach_autocmd() + if a:is_visual == 1 + normal! gv + endif +endfunction "}}} "}}} " Grouping Algorithms: {{{ let s:grouping_algorithms = { diff --git a/plugin/EasyMotion.vim b/plugin/EasyMotion.vim index e5c4b38..377e965 100644 --- a/plugin/EasyMotion.vim +++ b/plugin/EasyMotion.vim @@ -367,6 +367,9 @@ map (easymotion-clever-s2) map (easymotion-clever-sn) \ EasyMotion#is_active() ? '(easymotion-next)' : '(easymotion-sn)' +noremap (easymotion-activate) :call EasyMotion#activate(0) +xnoremap (easymotion-activate) :call EasyMotion#activate(1) + " }}} " == Default key mapping {{{ diff --git a/t/easymotion_spec.vim b/t/easymotion_spec.vim index e89b94d..ee28fb1 100644 --- a/t/easymotion_spec.vim +++ b/t/easymotion_spec.vim @@ -1,7 +1,7 @@ "============================================================================= " FILE: t/easymotion_spec.vim " AUTHOR: haya14busa -" Last Change: 22 Jan 2014. +" Last Change: 23 Jan 2014. " Test: https://github.com/kana/vim-vspec " Refer: https://github.com/rhysd/clever-f.vim " Description: EasyMotion test with vim-vspec @@ -393,6 +393,15 @@ describe 'Default settings' Expect maparg('(easymotion-special-pd)', 'n') \ ==# ':call EasyMotion#SelectPhraseDelete()' " }}} + + " Activate {{{ + Expect maparg('(easymotion-activate)', 'n') + \ ==# ':call EasyMotion#activate(0)' + Expect maparg('(easymotion-activate)', 'o') + \ ==# ':call EasyMotion#activate(0)' + Expect maparg('(easymotion-activate)', 'v') + \ ==# ':call EasyMotion#activate(1)' + " }}} end it 'provide autoload functions'