From c7e1b7c2bf7c548f33102bb7bc7879bfe5dd38ec Mon Sep 17 00:00:00 2001 From: haya14busa Date: Thu, 16 Jan 2014 13:36:36 +0900 Subject: [PATCH 1/5] Implement "." repeat! Require tpope/vim-repeat --- autoload/EasyMotion.vim | 188 ++++++++++++++++++++++++++++++++-------- plugin/EasyMotion.vim | 5 ++ 2 files changed, 156 insertions(+), 37 deletions(-) diff --git a/autoload/EasyMotion.vim b/autoload/EasyMotion.vim index 6b8dc31..791f168 100644 --- a/autoload/EasyMotion.vim +++ b/autoload/EasyMotion.vim @@ -13,6 +13,12 @@ set cpo&vim function! EasyMotion#init() " Init Migemo Dictionary let s:previous = {} + let s:current = { + \ 'is_operator' : 0, + \ 'dot_repeat_target_cnt' : 0, + \ 'dot_prompt_user_cnt' : 0, + \ } + " dot_ prefix key is especially for dot repeat varibale call EasyMotion#reset() let s:migemo_dicts = {} " Anywhere regular expression: {{{ @@ -48,18 +54,22 @@ function! EasyMotion#reset() \ 'within_line' : 0, \ 'dot_repeat' : 0, \ } + " Reset count for dot repeat target chars + let s:current.dot_repeat_target_cnt = 0 + let s:current.dot_prompt_user_cnt = 0 + return "" endfunction "}}} " == Motion functions {{{ " -- Find Motion ------------------------- function! EasyMotion#S(num_strokes, visualmode, direction) " {{{ + let s:current.is_operator = mode(1) ==# 'no' ? 1: 0 + let is_exclusive = mode(1) ==# 'no' ? 1 : 0 + let s:previous['input'] = get(s:previous, 'input', '') let input = EasyMotion#command_line#GetInput(a:num_strokes, s:previous.input) let s:previous['input'] = input - let mode = mode(1) - let is_exclusive = mode ==# 'no' ? 1 : 0 - " Check that we have an input char if empty(input) " Restore selection @@ -76,13 +86,13 @@ function! EasyMotion#S(num_strokes, visualmode, direction) " {{{ call s:EasyMotion(re, a:direction, a:visualmode ? visualmode() : '', is_exclusive) endfunction " }}} function! EasyMotion#T(num_strokes, visualmode, direction) " {{{ + let s:current.is_operator = mode(1) ==# 'no' ? 1: 0 + let is_exclusive = mode(1) ==# 'no' ? 1 : 0 + let s:previous['input'] = get(s:previous, 'input', '') let input = EasyMotion#command_line#GetInput(a:num_strokes, s:previous.input) let s:previous['input'] = input - let mode = mode(1) - let is_exclusive = mode ==# 'no' ? 1 : 0 - " Check that we have an input char if empty(input) " Restore selection @@ -108,21 +118,26 @@ function! EasyMotion#T(num_strokes, visualmode, direction) " {{{ endfunction " }}} " -- Word Motion ------------------------- function! EasyMotion#WB(visualmode, direction) " {{{ + let s:current.is_operator = mode(1) ==# 'no' ? 1: 0 call s:EasyMotion('\(\<.\|^$\)', a:direction, a:visualmode ? visualmode() : '', 0) endfunction " }}} function! EasyMotion#WBW(visualmode, direction) " {{{ + let s:current.is_operator = mode(1) ==# 'no' ? 1: 0 call s:EasyMotion('\(\(^\|\s\)\@<=\S\|^$\)', a:direction, a:visualmode ? visualmode() : '', 0) endfunction " }}} function! EasyMotion#E(visualmode, direction) " {{{ + let s:current.is_operator = mode(1) ==# 'no' ? 1: 0 let is_exclusive = mode(1) ==# 'no' ? 1 : 0 call s:EasyMotion('\(.\>\|^$\)', a:direction, a:visualmode ? visualmode() : '', is_exclusive) endfunction " }}} function! EasyMotion#EW(visualmode, direction) " {{{ + let s:current.is_operator = mode(1) ==# 'no' ? 1: 0 let is_exclusive = mode(1) ==# 'no' ? 1 : 0 call s:EasyMotion('\(\S\(\s\|$\)\|^$\)', a:direction, a:visualmode ? visualmode() : '', is_exclusive) endfunction " }}} " -- JK Motion --------------------------- function! EasyMotion#JK(visualmode, direction) " {{{ + let s:current.is_operator = mode(1) ==# 'no' ? 1: 0 "FIXME: support exclusive if g:EasyMotion_startofline call s:EasyMotion('^\(\w\|\s*\zs\|$\)', a:direction, a:visualmode ? visualmode() : '', 0) @@ -132,28 +147,32 @@ function! EasyMotion#JK(visualmode, direction) " {{{ endif endfunction " }}} function! EasyMotion#Sol(visualmode, direction) " {{{ + let s:current.is_operator = mode(1) ==# 'no' ? 1: 0 call s:EasyMotion('^\(\w\|\s*\zs\|$\)', a:direction, a:visualmode ? visualmode() : '', '') endfunction " }}} function! EasyMotion#Eol(visualmode, direction) " {{{ + let s:current.is_operator = mode(1) ==# 'no' ? 1: 0 call s:EasyMotion('\(\w\|\s*\zs\|.\|^\)$', a:direction, a:visualmode ? visualmode() : '', '') endfunction " }}} " -- Search Motion ----------------------- function! EasyMotion#Search(visualmode, direction) " {{{ + let s:current.is_operator = mode(1) ==# 'no' ? 1: 0 call s:EasyMotion(@/, a:direction, a:visualmode ? visualmode() : '', 0) endfunction " }}} " -- JumpToAnywhere Motion --------------- function! EasyMotion#JumpToAnywhere(visualmode, direction) " {{{ + let s:current.is_operator = mode(1) ==# 'no' ? 1: 0 call s:EasyMotion( g:EasyMotion_re_anywhere, a:direction, a:visualmode ? visualmode() : '', 0) endfunction " }}} " -- Line Motion ------------------------- function! EasyMotion#SL(num_strokes, visualmode, direction) " {{{ + let s:current.is_operator = mode(1) ==# 'no' ? 1: 0 + let is_exclusive = mode(1) ==# 'no' ? 1 : 0 + let s:previous['input'] = get(s:previous, 'input', '') let input = EasyMotion#command_line#GetInput(a:num_strokes, s:previous.input) let s:previous['input'] = input - - let is_exclusive = mode(1) ==# 'no' ? 1 : 0 - " Check that we have an input char if empty(input) " Restore selection @@ -172,12 +191,13 @@ function! EasyMotion#SL(num_strokes, visualmode, direction) " {{{ call s:EasyMotion(re, a:direction, a:visualmode ? visualmode() : '', is_exclusive) endfunction " }}} function! EasyMotion#TL(num_strokes, visualmode, direction) " {{{ + let s:current.is_operator = mode(1) ==# 'no' ? 1: 0 + let is_exclusive = mode(1) ==# 'no' ? 1 : 0 + let s:previous['input'] = get(s:previous, 'input', '') let input = EasyMotion#command_line#GetInput(a:num_strokes, s:previous.input) let s:previous['input'] = input - let is_exclusive = mode(1) ==# 'no' ? 1 : 0 - " Check that we have an input char if empty(input) " Restore selection @@ -204,16 +224,20 @@ function! EasyMotion#TL(num_strokes, visualmode, direction) " {{{ call s:EasyMotion(re, a:direction, a:visualmode ? visualmode() : '', is_exclusive) endfunction " }}} function! EasyMotion#WBL(visualmode, direction) " {{{ + let s:current.is_operator = mode(1) ==# 'no' ? 1: 0 + let is_exclusive = mode(1) ==# 'no' ? 1 : 0 let s:flag.within_line = 1 call s:EasyMotion('\(\<.\|^$\)', a:direction, a:visualmode ? visualmode() : '', 0) endfunction " }}} function! EasyMotion#EL(visualmode, direction) " {{{ let s:flag.within_line = 1 + let s:current.is_operator = mode(1) ==# 'no' ? 1: 0 let is_exclusive = mode(1) ==# 'no' ? 1 : 0 call s:EasyMotion('\(.\>\|^$\)', a:direction, a:visualmode ? visualmode() : '', is_exclusive) endfunction " }}} function! EasyMotion#LineAnywhere(visualmode, direction) " {{{ let s:flag.within_line = 1 + let s:current.is_operator = mode(1) ==# 'no' ? 1: 0 let re = g:EasyMotion_re_line_anywhere call s:EasyMotion(re, a:direction, a:visualmode ? visualmode() : '', 0) endfunction " }}} @@ -356,6 +380,7 @@ function! EasyMotion#SelectPhraseDelete() "{{{ endfunction "}}} " -- User Motion ------------------------- function! EasyMotion#User(pattern, mode, direction) " {{{ + let s:current.is_operator = mode(1) ==# 'no' ? 1: 0 let visualmode = match('\v([Vv])|(C-v)', a:mode) > 0 ? visualmode() : '' let re = escape(a:pattern, '|') call s:EasyMotion(re, a:direction, visualmode, 0) @@ -370,11 +395,28 @@ function! EasyMotion#Repeat(visualmode) " {{{ let re = s:previous.regexp let direction = s:previous.direction let s:flag.within_line = s:previous.line_flag + let s:current.is_operator = mode(1) ==# 'no' ? 1: 0 let is_exclusive = mode(1) ==# 'no' ? 1 : 0 call s:EasyMotion(re, direction, a:visualmode ? visualmode() : '', is_exclusive) endfunction " }}} +function! EasyMotion#DotRepeat(visualmode) " {{{ + " Repeat previous motion with previous targets + if s:previous ==# {} + call s:Message("Previous motion doesn't exist") + return + endif + let re = s:previous.regexp + let direction = s:previous.direction + let is_exclusive = s:previous.is_exclusive + let s:current.is_operator = 1 + let s:flag.within_line = s:previous.line_flag + for cnt in range(v:count1) + let s:flag.dot_repeat = 1 + silent call s:EasyMotion(re, direction, 0, is_exclusive) + endfor +endfunction " }}} " }}} " == Helper functions {{{ " -- Message ----------------------------- @@ -966,20 +1008,37 @@ function! s:PromptUser(groups, allows_repeat, fixed_column) "{{{ endif "}}} try - " Set lines with markers + " Set lines with markers {{{ call s:SetLines(lines_items, 'marker') - redraw + redraw "}}} + " Get target character {{{ call s:Prompt('Target key') - let char = s:GetChar() + "}}} + + " Convert uppercase {{{ if g:EasyMotion_use_upper == 1 && match(g:EasyMotion_keys, '\l') == -1 let char = toupper(char) - endif + endif "}}} + + " Jump first target when Enter key is pressed "{{{ if char ==# ' ' && g:EasyMotion_enter_jump_first == 1 let char = g:EasyMotion_keys[0] - endif - " }}} + endif "}}} + + " For dot repeat {{{ + if mode(1) ==# 'no' + " Store previous target when operator pending mode + if s:current.dot_prompt_user_cnt == 0 + " Store + let s:previous['target'] = char + else + " Append target chars + let s:previous['target'] .= char + endif + endif "}}} + finally " Restore original lines call s:SetLines(lines_items, 'orig') @@ -1034,6 +1093,23 @@ function! s:PromptUser(groups, allows_repeat, fixed_column) "{{{ let target = a:groups[char] + if type(target) == 3 + " Return target coordinates + return target + else + " Prompt for new target character + let s:current.dot_prompt_user_cnt += 1 + return s:PromptUser(target, a:allows_repeat, a:fixed_column) + endif +endfunction "}}} +function! s:DotPromptUser(groups) "{{{ + " Get char from previous target + let char = s:previous.target[s:current.dot_repeat_target_cnt] + " For dot repeat target chars + let s:current.dot_repeat_target_cnt += 1 + + let target = a:groups[char] + if type(target) == 3 " Return target coordinates return target @@ -1063,17 +1139,20 @@ function! s:EasyMotion(regexp, direction, visualmode, is_exclusive, ...) " {{{ let targets = [] - " Store Regular Expression - let s:previous['regexp'] = a:regexp - let s:previous['direction'] = a:direction - let s:previous['line_flag'] = s:flag.within_line == 1 ? 1 : 0 + if s:flag.dot_repeat != 1 + " Store Regular Expression + let s:previous['regexp'] = a:regexp + let s:previous['direction'] = a:direction + let s:previous['line_flag'] = s:flag.within_line == 1 ? 1 : 0 + let s:previous['is_exclusive'] = a:is_exclusive + let s:previous['operator'] = v:operator + endif try " -- Reset properties -------------------- {{{ " Save original value and set new value call s:SaveValue() " }}} - " -- Find motion targets ----------------- {{{ " Setup searchpos args {{{ let search_direction = (a:direction >= 1 ? 'b' : '') let search_stopline = a:direction >= 1 ? win_first_line : win_last_line @@ -1196,7 +1275,7 @@ function! s:EasyMotion(regexp, direction, visualmode, is_exclusive, ...) " {{{ let groups = GroupingFn(targets, split(g:EasyMotion_keys, '\zs')) " -- Shade inactive source --------------- {{{ - if g:EasyMotion_do_shade && targets_len != 1 + if g:EasyMotion_do_shade && targets_len != 1 && s:flag.dot_repeat != 1 if !empty(a:visualmode) let shade_hl_pos = '\%' . c_pos[0] . 'l\%'. c_pos[1] .'c' else @@ -1236,8 +1315,12 @@ function! s:EasyMotion(regexp, direction, visualmode, is_exclusive, ...) " {{{ "}}} " -- Prompt user for target group/character {{{ - let coords = s:PromptUser(groups, allows_repeat, fixed_column) - let s:previous_target_coord = coords + if s:flag.dot_repeat != 1 + let coords = s:PromptUser(groups, allows_repeat, fixed_column) + let s:previous_target_coord = coords + else + let coords = s:DotPromptUser(groups) + endif "}}} " -- Update selection -------------------- {{{ @@ -1249,24 +1332,55 @@ function! s:EasyMotion(regexp, direction, visualmode, is_exclusive, ...) " {{{ " }}} " -- Update cursor position -------------- {{{ call cursor(orig_pos[0], orig_pos[1]) - " Handle operator-pending mode {{{ - if a:is_exclusive == 1 - " This mode requires that we eat one more - " character to the right if we're using - " a forward motion + if s:flag.dot_repeat == 1 + " support dot repeat {{{ + " Use visual mode to emulate dot repeat normal! v + if s:previous.is_exclusive == 0 + if s:previous.direction == 0 "Forward + let coords[1] -= 1 + elseif s:previous.direction == 1 "Backward + " Shift visual selection to left by making cursor one key + " left. + normal! hoh + endif + endif + keepjumps call cursor(coords[0], coords[1]) + let cmd = s:previous.operator + if s:previous.operator ==# 'c' + let cmd .= getreg('.') + endif + + exec 'normal! ' . cmd + "}}} + else + " Handle operator-pending mode {{{ + if a:is_exclusive == 1 + " Exclusive motion requires that we eat one more + " character to the right if we're using + " a forward motion + normal! v + endif " }}} + + " Adjuast screen for visual scroll {{{ + if ! empty(a:visualmode) + keepjumps call cursor(win_first_line, 0) + normal! zt + endif "}}} + + keepjumps call cursor(coords[0], coords[1]) + + endif + + " Set tpope/vim-repeat + if s:current.is_operator == 1 + silent! call repeat#set("\(easymotion-dotrepeat)") endif - " }}} - " Adjuast screen for visual scroll {{{ - if ! empty(a:visualmode) - keepjumps call cursor(win_first_line, 0) - normal! zt - endif "}}} - keepjumps call cursor(coords[0], coords[1]) call s:Message('Jumping to [' . coords[0] . ', ' . coords[1] . ']') let s:EasyMotion_cancelled = 0 "}}} + catch redraw diff --git a/plugin/EasyMotion.vim b/plugin/EasyMotion.vim index f616fb0..408c43a 100644 --- a/plugin/EasyMotion.vim +++ b/plugin/EasyMotion.vim @@ -241,6 +241,11 @@ noremap (easymotion-repeat) \ :call EasyMotion#Repeat(0) xnoremap (easymotion-repeat) \ :call EasyMotion#Repeat(1) + +noremap (easymotion-dotrepeat) + \ :call EasyMotion#DotRepeat(0) +xnoremap (easymotion-dotrepeat) + \ :call EasyMotion#DotRepeat(1) "}}} " -- Line Motion {{{ From 335ea6dac70b6366c063549dc5545253700ace27 Mon Sep 17 00:00:00 2001 From: haya14busa Date: Thu, 16 Jan 2014 15:57:23 +0900 Subject: [PATCH 2/5] Fix typo --- autoload/EasyMotion.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/EasyMotion.vim b/autoload/EasyMotion.vim index 791f168..8da31b7 100644 --- a/autoload/EasyMotion.vim +++ b/autoload/EasyMotion.vim @@ -1307,7 +1307,7 @@ function! s:EasyMotion(regexp, direction, visualmode, is_exclusive, ...) " {{{ " -- Jump back before prompt for visual scroll {{{ " Because searchpos() change current cursor position and " if you just use cursor([orig_num, orig_pos]) to jump back, - " current line will bebecome center of window + " current line will become center of window if ! empty(a:visualmode) keepjumps call cursor(win_first_line,0) normal! zt From 9d8864c838b1974730330deeb00c4265ff6cd4c7 Mon Sep 17 00:00:00 2001 From: haya14busa Date: Thu, 16 Jan 2014 20:40:56 +0900 Subject: [PATCH 3/5] Fix typo: --- plugin/EasyMotion.vim | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/plugin/EasyMotion.vim b/plugin/EasyMotion.vim index 408c43a..e128833 100644 --- a/plugin/EasyMotion.vim +++ b/plugin/EasyMotion.vim @@ -111,7 +111,7 @@ function! s:find_motion_map_helper(motions) "{{{ silent exec 'xnoremap (easymotion-'.name.')' . \ ' :call EasyMotion#'. dict.fnc .'('. dict.cnt .',1,'. dict.direction .')' " Example: - " noremap (easymotion-f2) :call EasyMotion#S(2,1,0) + " noremap (easymotion-f2) :call EasyMotion#S(2,1,0) " xnoremap (easymotion-f2) :call EasyMotion#S(2,1,0) endfor endfunction "}}} @@ -167,8 +167,8 @@ xnoremap (easymotion-bd-w) :call EasyMotion#WB(1,2) "}}} " WORD: {{{ -noremap (easymotion-w) :call EasyMotion#WBW(0,0) -xnoremap (easymotion-w) :call EasyMotion#WBW(1,0) +noremap (easymotion-W) :call EasyMotion#WBW(0,0) +xnoremap (easymotion-W) :call EasyMotion#WBW(1,0) noremap (easymotion-B) :call EasyMotion#WBW(0,1) xnoremap (easymotion-B) :call EasyMotion#WBW(1,1) noremap (easymotion-bd-W) :call EasyMotion#WBW(0,2) @@ -207,8 +207,10 @@ noremap (easymotion-sol-j) :call EasyMotion#Sol(0,0 xnoremap (easymotion-sol-j) :call EasyMotion#Sol(1,0) noremap (easymotion-sol-k) :call EasyMotion#Sol(0,1) xnoremap (easymotion-sol-k) :call EasyMotion#Sol(1,1) -noremap (easymotion-sol-bd-Jk) :call EasyMotion#Sol(0,2) -xnoremap (easymotion-sol-bd-Jk) :call EasyMotion#Sol(1,2) +noremap (easymotion-sol-bd-jk) :call EasyMotion#Sol(0,2) +xnoremap (easymotion-sol-bd-jk) :call EasyMotion#Sol(1,2) +"}}} + " End of Line JK {{{ noremap (easymotion-eol-j) :call EasyMotion#Eol(0,0) xnoremap (easymotion-eol-j) :call EasyMotion#Eol(1,0) From a6c9d4c40ca9dfeae0b6bbe51227c0ad9e1b1689 Mon Sep 17 00:00:00 2001 From: haya14busa Date: Thu, 16 Jan 2014 20:42:20 +0900 Subject: [PATCH 4/5] Add vim-vspec test --- .gitignore | 3 +- .travis.yml | 8 + Gemfile | 3 + Rakefile | 11 + t/easymotion_spec.vim | 948 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 972 insertions(+), 1 deletion(-) create mode 100644 .travis.yml create mode 100644 Gemfile create mode 100644 Rakefile create mode 100644 t/easymotion_spec.vim diff --git a/.gitignore b/.gitignore index 24a015a..5d0b4ff 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ doc/tags -ignore/ tmp* +*.lock +.vim-flavor diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..351865e --- /dev/null +++ b/.travis.yml @@ -0,0 +1,8 @@ +language: ruby +rvm: + - 2.0.0 +script: + - rake ci +install: + - git clone https://github.com/kana/vim-vspec.git + - git clone https://github.com/tpope/vim-repeat.git diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..a87f4e1 --- /dev/null +++ b/Gemfile @@ -0,0 +1,3 @@ +source 'https://rubygems.org' + +gem 'vim-flavor', '~> 1.1' diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..63a3a36 --- /dev/null +++ b/Rakefile @@ -0,0 +1,11 @@ +#!/usr/bin/env rake + +task :ci => [:dump, :test] + +task :dump do + sh 'vim --version' +end + +task :test do + sh 'bundle exec vim-flavor test' +end diff --git a/t/easymotion_spec.vim b/t/easymotion_spec.vim new file mode 100644 index 0000000..32b7dee --- /dev/null +++ b/t/easymotion_spec.vim @@ -0,0 +1,948 @@ +"============================================================================= +" FILE: t/easymotion_spec.vim +" AUTHOR: haya14busa +" Last Change: 16 Jan 2014. +" Test: https://github.com/kana/vim-vspec +" Refer: https://github.com/rhysd/clever-f.vim +" Description: EasyMotion test with vim-vspec +" License: MIT license {{{ +" Permission is hereby granted, free of charge, to any person obtaining +" a copy of this software and associated documentation files (the +" "Software"), to deal in the Software without restriction, including +" without limitation the rights to use, copy, modify, merge, publish, +" distribute, sublicense, and/or sell copies of the Software, and to +" permit persons to whom the Software is furnished to do so, subject to +" the following conditions: +" +" The above copyright notice and this permission notice shall be included +" in all copies or substantial portions of the Software. +" +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +" IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +" CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +" TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +" SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +" }}} +"============================================================================= + +let s:root_dir = matchstr(system('git rev-parse --show-cdup'), '[^\n]\+') +execute 'set' 'rtp +=./'.s:root_dir +runtime! plugin/EasyMotion.vim + +" Default settings {{{ +describe 'Default settings' + it 'provide default mappings for find motion' + " Find Motion: {{{ + " s + Expect maparg('(easymotion-s)', 'n') ==# ':call EasyMotion#S(1,0,2)' + Expect maparg('(easymotion-s)', 'o') ==# ':call EasyMotion#S(1,0,2)' + Expect maparg('(easymotion-s)', 'v') ==# ':call EasyMotion#S(1,1,2)' + " f + Expect maparg('(easymotion-f)', 'n') ==# ':call EasyMotion#S(1,0,0)' + Expect maparg('(easymotion-f)', 'o') ==# ':call EasyMotion#S(1,0,0)' + Expect maparg('(easymotion-f)', 'v') ==# ':call EasyMotion#S(1,1,0)' + " F + Expect maparg('(easymotion-F)', 'n') ==# ':call EasyMotion#S(1,0,1)' + Expect maparg('(easymotion-F)', 'o') ==# ':call EasyMotion#S(1,0,1)' + Expect maparg('(easymotion-F)', 'v') ==# ':call EasyMotion#S(1,1,1)' + " t + Expect maparg('(easymotion-t)', 'n') ==# ':call EasyMotion#T(1,0,0)' + Expect maparg('(easymotion-t)', 'o') ==# ':call EasyMotion#T(1,0,0)' + Expect maparg('(easymotion-t)', 'v') ==# ':call EasyMotion#T(1,1,0)' + " T + Expect maparg('(easymotion-T)', 'n') ==# ':call EasyMotion#T(1,0,1)' + Expect maparg('(easymotion-T)', 'o') ==# ':call EasyMotion#T(1,0,1)' + Expect maparg('(easymotion-T)', 'v') ==# ':call EasyMotion#T(1,1,1)' + " sl + Expect maparg('(easymotion-sl)', 'n') ==# ':call EasyMotion#SL(1,0,2)' + Expect maparg('(easymotion-sl)', 'o') ==# ':call EasyMotion#SL(1,0,2)' + Expect maparg('(easymotion-sl)', 'v') ==# ':call EasyMotion#SL(1,1,2)' + " fl + Expect maparg('(easymotion-fl)', 'n') ==# ':call EasyMotion#SL(1,0,0)' + Expect maparg('(easymotion-fl)', 'o') ==# ':call EasyMotion#SL(1,0,0)' + Expect maparg('(easymotion-fl)', 'v') ==# ':call EasyMotion#SL(1,1,0)' + " Fl + Expect maparg('(easymotion-Fl)', 'n') ==# ':call EasyMotion#SL(1,0,1)' + Expect maparg('(easymotion-Fl)', 'o') ==# ':call EasyMotion#SL(1,0,1)' + Expect maparg('(easymotion-Fl)', 'v') ==# ':call EasyMotion#SL(1,1,1)' + " tl + Expect maparg('(easymotion-tl)', 'n') ==# ':call EasyMotion#TL(1,0,0)' + Expect maparg('(easymotion-tl)', 'o') ==# ':call EasyMotion#TL(1,0,0)' + Expect maparg('(easymotion-tl)', 'v') ==# ':call EasyMotion#TL(1,1,0)' + " Tl + Expect maparg('(easymotion-Tl)', 'n') ==# ':call EasyMotion#TL(1,0,1)' + Expect maparg('(easymotion-Tl)', 'o') ==# ':call EasyMotion#TL(1,0,1)' + Expect maparg('(easymotion-Tl)', 'v') ==# ':call EasyMotion#TL(1,1,1)' + "}}} + + " Two Char Find Motion: {{{ + " s2 + Expect maparg('(easymotion-s2)', 'n') ==# ':call EasyMotion#S(2,0,2)' + Expect maparg('(easymotion-s2)', 'o') ==# ':call EasyMotion#S(2,0,2)' + Expect maparg('(easymotion-s2)', 'v') ==# ':call EasyMotion#S(2,1,2)' + " f2 + Expect maparg('(easymotion-f2)', 'n') ==# ':call EasyMotion#S(2,0,0)' + Expect maparg('(easymotion-f2)', 'o') ==# ':call EasyMotion#S(2,0,0)' + Expect maparg('(easymotion-f2)', 'v') ==# ':call EasyMotion#S(2,1,0)' + " F2 + Expect maparg('(easymotion-F2)', 'n') ==# ':call EasyMotion#S(2,0,1)' + Expect maparg('(easymotion-F2)', 'o') ==# ':call EasyMotion#S(2,0,1)' + Expect maparg('(easymotion-F2)', 'v') ==# ':call EasyMotion#S(2,1,1)' + " t2 + Expect maparg('(easymotion-t2)', 'n') ==# ':call EasyMotion#T(2,0,0)' + Expect maparg('(easymotion-t2)', 'o') ==# ':call EasyMotion#T(2,0,0)' + Expect maparg('(easymotion-t2)', 'v') ==# ':call EasyMotion#T(2,1,0)' + " T2 + Expect maparg('(easymotion-T2)', 'n') ==# ':call EasyMotion#T(2,0,1)' + Expect maparg('(easymotion-T2)', 'o') ==# ':call EasyMotion#T(2,0,1)' + Expect maparg('(easymotion-T2)', 'v') ==# ':call EasyMotion#T(2,1,1)' + " sl2 + Expect maparg('(easymotion-sl2)', 'n') ==# ':call EasyMotion#SL(2,0,2)' + Expect maparg('(easymotion-sl2)', 'o') ==# ':call EasyMotion#SL(2,0,2)' + Expect maparg('(easymotion-sl2)', 'v') ==# ':call EasyMotion#SL(2,1,2)' + " fl2 + Expect maparg('(easymotion-fl2)', 'n') ==# ':call EasyMotion#SL(2,0,0)' + Expect maparg('(easymotion-fl2)', 'o') ==# ':call EasyMotion#SL(2,0,0)' + Expect maparg('(easymotion-fl2)', 'v') ==# ':call EasyMotion#SL(2,1,0)' + " Fl2 + Expect maparg('(easymotion-Fl2)', 'n') ==# ':call EasyMotion#SL(2,0,1)' + Expect maparg('(easymotion-Fl2)', 'o') ==# ':call EasyMotion#SL(2,0,1)' + Expect maparg('(easymotion-Fl2)', 'v') ==# ':call EasyMotion#SL(2,1,1)' + " tl2 + Expect maparg('(easymotion-tl2)', 'n') ==# ':call EasyMotion#TL(2,0,0)' + Expect maparg('(easymotion-tl2)', 'o') ==# ':call EasyMotion#TL(2,0,0)' + Expect maparg('(easymotion-tl2)', 'v') ==# ':call EasyMotion#TL(2,1,0)' + " Tl2 + Expect maparg('(easymotion-Tl2)', 'n') ==# ':call EasyMotion#TL(2,0,1)' + Expect maparg('(easymotion-Tl2)', 'o') ==# ':call EasyMotion#TL(2,0,1)' + Expect maparg('(easymotion-Tl2)', 'v') ==# ':call EasyMotion#TL(2,1,1)' + "}}} + + " Multi Char Find Motion: {{{ + " sn + Expect maparg('(easymotion-sn)', 'n') ==# ':call EasyMotion#S(50,0,2)' + Expect maparg('(easymotion-sn)', 'o') ==# ':call EasyMotion#S(50,0,2)' + Expect maparg('(easymotion-sn)', 'v') ==# ':call EasyMotion#S(50,1,2)' + " fn + Expect maparg('(easymotion-fn)', 'n') ==# ':call EasyMotion#S(50,0,0)' + Expect maparg('(easymotion-fn)', 'o') ==# ':call EasyMotion#S(50,0,0)' + Expect maparg('(easymotion-fn)', 'v') ==# ':call EasyMotion#S(50,1,0)' + " Fn + Expect maparg('(easymotion-Fn)', 'n') ==# ':call EasyMotion#S(50,0,1)' + Expect maparg('(easymotion-Fn)', 'o') ==# ':call EasyMotion#S(50,0,1)' + Expect maparg('(easymotion-Fn)', 'v') ==# ':call EasyMotion#S(50,1,1)' + " tn + Expect maparg('(easymotion-tn)', 'n') ==# ':call EasyMotion#T(50,0,0)' + Expect maparg('(easymotion-tn)', 'o') ==# ':call EasyMotion#T(50,0,0)' + Expect maparg('(easymotion-tn)', 'v') ==# ':call EasyMotion#T(50,1,0)' + " Tn + Expect maparg('(easymotion-Tn)', 'n') ==# ':call EasyMotion#T(50,0,1)' + Expect maparg('(easymotion-Tn)', 'o') ==# ':call EasyMotion#T(50,0,1)' + Expect maparg('(easymotion-Tn)', 'v') ==# ':call EasyMotion#T(50,1,1)' + " sln + Expect maparg('(easymotion-sln)', 'n') ==# ':call EasyMotion#SL(50,0,2)' + Expect maparg('(easymotion-sln)', 'o') ==# ':call EasyMotion#SL(50,0,2)' + Expect maparg('(easymotion-sln)', 'v') ==# ':call EasyMotion#SL(50,1,2)' + " fln + Expect maparg('(easymotion-fln)', 'n') ==# ':call EasyMotion#SL(50,0,0)' + Expect maparg('(easymotion-fln)', 'o') ==# ':call EasyMotion#SL(50,0,0)' + Expect maparg('(easymotion-fln)', 'v') ==# ':call EasyMotion#SL(50,1,0)' + " Fln + Expect maparg('(easymotion-Fln)', 'n') ==# ':call EasyMotion#SL(50,0,1)' + Expect maparg('(easymotion-Fln)', 'o') ==# ':call EasyMotion#SL(50,0,1)' + Expect maparg('(easymotion-Fln)', 'v') ==# ':call EasyMotion#SL(50,1,1)' + " tln + Expect maparg('(easymotion-tln)', 'n') ==# ':call EasyMotion#TL(50,0,0)' + Expect maparg('(easymotion-tln)', 'o') ==# ':call EasyMotion#TL(50,0,0)' + Expect maparg('(easymotion-tln)', 'v') ==# ':call EasyMotion#TL(50,1,0)' + " Tln + Expect maparg('(easymotion-Tln)', 'n') ==# ':call EasyMotion#TL(50,0,1)' + Expect maparg('(easymotion-Tln)', 'o') ==# ':call EasyMotion#TL(50,0,1)' + Expect maparg('(easymotion-Tln)', 'v') ==# ':call EasyMotion#TL(50,1,1)' + "}}} + end + + it 'provide default mappings for regrex motion' + "(is_visual, direction) + " direction: + " - 0: forward + " - 1: backward + " - 2: bi-direction + " Word Motion: {{{ + Expect maparg('(easymotion-w)', 'n') ==# ':call EasyMotion#WB(0,0)' + Expect maparg('(easymotion-w)', 'o') ==# ':call EasyMotion#WB(0,0)' + Expect maparg('(easymotion-w)', 'v') ==# ':call EasyMotion#WB(1,0)' + Expect maparg('(easymotion-b)', 'n') ==# ':call EasyMotion#WB(0,1)' + Expect maparg('(easymotion-b)', 'o') ==# ':call EasyMotion#WB(0,1)' + Expect maparg('(easymotion-b)', 'v') ==# ':call EasyMotion#WB(1,1)' + Expect maparg('(easymotion-bd-w)', 'n') ==# ':call EasyMotion#WB(0,2)' + Expect maparg('(easymotion-bd-w)', 'o') ==# ':call EasyMotion#WB(0,2)' + Expect maparg('(easymotion-bd-w)', 'v') ==# ':call EasyMotion#WB(1,2)' + Expect maparg('(easymotion-S)', 'n') ==# ':call EasyMotion#WB(0,2)' + Expect maparg('(easymotion-S)', 'o') ==# ':call EasyMotion#WB(0,2)' + Expect maparg('(easymotion-S)', 'v') ==# ':call EasyMotion#WB(1,2)' + " }}} + + " WORD Motion: {{{ + Expect maparg('(easymotion-W)', 'n') ==# ':call EasyMotion#WBW(0,0)' + Expect maparg('(easymotion-W)', 'o') ==# ':call EasyMotion#WBW(0,0)' + Expect maparg('(easymotion-W)', 'v') ==# ':call EasyMotion#WBW(1,0)' + Expect maparg('(easymotion-B)', 'n') ==# ':call EasyMotion#WBW(0,1)' + Expect maparg('(easymotion-B)', 'o') ==# ':call EasyMotion#WBW(0,1)' + Expect maparg('(easymotion-B)', 'v') ==# ':call EasyMotion#WBW(1,1)' + Expect maparg('(easymotion-bd-W)', 'n') ==# ':call EasyMotion#WBW(0,2)' + Expect maparg('(easymotion-bd-W)', 'o') ==# ':call EasyMotion#WBW(0,2)' + Expect maparg('(easymotion-bd-W)', 'v') ==# ':call EasyMotion#WBW(1,2)' + " }}} + + " End Of Word Motion: {{{ + Expect maparg('(easymotion-e)', 'n') ==# ':call EasyMotion#E(0,0)' + Expect maparg('(easymotion-e)', 'o') ==# ':call EasyMotion#E(0,0)' + Expect maparg('(easymotion-e)', 'v') ==# ':call EasyMotion#E(1,0)' + Expect maparg('(easymotion-ge)', 'n') ==# ':call EasyMotion#E(0,1)' + Expect maparg('(easymotion-ge)', 'o') ==# ':call EasyMotion#E(0,1)' + Expect maparg('(easymotion-ge)', 'v') ==# ':call EasyMotion#E(1,1)' + Expect maparg('(easymotion-bd-e)', 'n') ==# ':call EasyMotion#E(0,2)' + Expect maparg('(easymotion-bd-e)', 'o') ==# ':call EasyMotion#E(0,2)' + Expect maparg('(easymotion-bd-e)', 'v') ==# ':call EasyMotion#E(1,2)' + " }}} + + " END OF WORD Motion: {{{ + Expect maparg('(easymotion-E)', 'n') ==# ':call EasyMotion#EW(0,0)' + Expect maparg('(easymotion-E)', 'o') ==# ':call EasyMotion#EW(0,0)' + Expect maparg('(easymotion-E)', 'v') ==# ':call EasyMotion#EW(1,0)' + Expect maparg('(easymotion-gE)', 'n') ==# ':call EasyMotion#EW(0,1)' + Expect maparg('(easymotion-gE)', 'o') ==# ':call EasyMotion#EW(0,1)' + Expect maparg('(easymotion-gE)', 'v') ==# ':call EasyMotion#EW(1,1)' + Expect maparg('(easymotion-bd-E)', 'n') ==# ':call EasyMotion#EW(0,2)' + Expect maparg('(easymotion-bd-E)', 'o') ==# ':call EasyMotion#EW(0,2)' + Expect maparg('(easymotion-bd-E)', 'v') ==# ':call EasyMotion#EW(1,2)' + " }}} + + " JK Motion: {{{ + " default + Expect maparg('(easymotion-j)', 'n') ==# ':call EasyMotion#JK(0,0)' + Expect maparg('(easymotion-j)', 'o') ==# ':call EasyMotion#JK(0,0)' + Expect maparg('(easymotion-j)', 'v') ==# ':call EasyMotion#JK(1,0)' + Expect maparg('(easymotion-k)', 'n') ==# ':call EasyMotion#JK(0,1)' + Expect maparg('(easymotion-k)', 'o') ==# ':call EasyMotion#JK(0,1)' + Expect maparg('(easymotion-k)', 'v') ==# ':call EasyMotion#JK(1,1)' + Expect maparg('(easymotion-bd-jk)', 'n') ==# ':call EasyMotion#JK(0,2)' + Expect maparg('(easymotion-bd-jk)', 'o') ==# ':call EasyMotion#JK(0,2)' + Expect maparg('(easymotion-bd-jk)', 'v') ==# ':call EasyMotion#JK(1,2)' + " start of line + Expect maparg('(easymotion-sol-j)', 'n') ==# ':call EasyMotion#Sol(0,0)' + Expect maparg('(easymotion-sol-j)', 'o') ==# ':call EasyMotion#Sol(0,0)' + Expect maparg('(easymotion-sol-j)', 'v') ==# ':call EasyMotion#Sol(1,0)' + Expect maparg('(easymotion-sol-k)', 'n') ==# ':call EasyMotion#Sol(0,1)' + Expect maparg('(easymotion-sol-k)', 'o') ==# ':call EasyMotion#Sol(0,1)' + Expect maparg('(easymotion-sol-k)', 'v') ==# ':call EasyMotion#Sol(1,1)' + Expect maparg('(easymotion-sol-bd-jk)', 'n') ==# ':call EasyMotion#Sol(0,2)' + Expect maparg('(easymotion-sol-bd-jk)', 'o') ==# ':call EasyMotion#Sol(0,2)' + Expect maparg('(easymotion-sol-bd-jk)', 'v') ==# ':call EasyMotion#Sol(1,2)' + " end of line + Expect maparg('(easymotion-eol-j)', 'n') ==# ':call EasyMotion#Eol(0,0)' + Expect maparg('(easymotion-eol-j)', 'o') ==# ':call EasyMotion#Eol(0,0)' + Expect maparg('(easymotion-eol-j)', 'v') ==# ':call EasyMotion#Eol(1,0)' + Expect maparg('(easymotion-eol-k)', 'n') ==# ':call EasyMotion#Eol(0,1)' + Expect maparg('(easymotion-eol-k)', 'o') ==# ':call EasyMotion#Eol(0,1)' + Expect maparg('(easymotion-eol-k)', 'v') ==# ':call EasyMotion#Eol(1,1)' + Expect maparg('(easymotion-eol-bd-jk)', 'n') ==# ':call EasyMotion#Eol(0,2)' + Expect maparg('(easymotion-eol-bd-jk)', 'o') ==# ':call EasyMotion#Eol(0,2)' + Expect maparg('(easymotion-eol-bd-jk)', 'v') ==# ':call EasyMotion#Eol(1,2)' + " }}} + + " Search Motion: {{{ + Expect maparg('(easymotion-n)', 'n') ==# ':call EasyMotion#Search(0,0)' + Expect maparg('(easymotion-n)', 'o') ==# ':call EasyMotion#Search(0,0)' + Expect maparg('(easymotion-n)', 'v') ==# ':call EasyMotion#Search(1,0)' + Expect maparg('(easymotion-N)', 'n') ==# ':call EasyMotion#Search(0,1)' + Expect maparg('(easymotion-N)', 'o') ==# ':call EasyMotion#Search(0,1)' + Expect maparg('(easymotion-N)', 'v') ==# ':call EasyMotion#Search(1,1)' + Expect maparg('(easymotion-bd-n)', 'n') ==# ':call EasyMotion#Search(0,2)' + Expect maparg('(easymotion-bd-n)', 'o') ==# ':call EasyMotion#Search(0,2)' + Expect maparg('(easymotion-bd-n)', 'v') ==# ':call EasyMotion#Search(1,2)' + " }}} + + " JumpToAnywhere Motion: {{{ + Expect maparg('(easymotion-jumptoanywhere)', 'n') + \ ==# ':call EasyMotion#JumpToAnywhere(0,2)' + Expect maparg('(easymotion-jumptoanywhere)', 'o') + \ ==# ':call EasyMotion#JumpToAnywhere(0,2)' + Expect maparg('(easymotion-jumptoanywhere)', 'v') + \ ==# ':call EasyMotion#JumpToAnywhere(1,2)' + " }}} + + " Repeat Motion: {{{ + " (is_visual) + Expect maparg('(easymotion-repeat)', 'n') + \ ==# ':call EasyMotion#Repeat(0)' + Expect maparg('(easymotion-repeat)', 'o') + \ ==# ':call EasyMotion#Repeat(0)' + Expect maparg('(easymotion-repeat)', 'v') + \ ==# ':call EasyMotion#Repeat(1)' + Expect maparg('(easymotion-dotrepeat)', 'n') + \ ==# ':call EasyMotion#DotRepeat(0)' + Expect maparg('(easymotion-dotrepeat)', 'o') + \ ==# ':call EasyMotion#DotRepeat(0)' + Expect maparg('(easymotion-dotrepeat)', 'v') + \ ==# ':call EasyMotion#DotRepeat(1)' + " }}} + + " Line Motion: {{{ + " word + Expect maparg('(easymotion-wl)', 'n') ==# ':call EasyMotion#WBL(0,0)' + Expect maparg('(easymotion-wl)', 'o') ==# ':call EasyMotion#WBL(0,0)' + Expect maparg('(easymotion-wl)', 'v') ==# ':call EasyMotion#WBL(1,0)' + Expect maparg('(easymotion-bl)', 'n') ==# ':call EasyMotion#WBL(0,1)' + Expect maparg('(easymotion-bl)', 'o') ==# ':call EasyMotion#WBL(0,1)' + Expect maparg('(easymotion-bl)', 'v') ==# ':call EasyMotion#WBL(1,1)' + Expect maparg('(easymotion-bd-wl)', 'n') ==# ':call EasyMotion#WBL(0,2)' + Expect maparg('(easymotion-bd-wl)', 'o') ==# ':call EasyMotion#WBL(0,2)' + Expect maparg('(easymotion-bd-wl)', 'v') ==# ':call EasyMotion#WBL(1,2)' + " end of word + Expect maparg('(easymotion-el)', 'n') ==# ':call EasyMotion#EL(0,0)' + Expect maparg('(easymotion-el)', 'o') ==# ':call EasyMotion#EL(0,0)' + Expect maparg('(easymotion-el)', 'v') ==# ':call EasyMotion#EL(1,0)' + Expect maparg('(easymotion-gel)', 'n') ==# ':call EasyMotion#EL(0,1)' + Expect maparg('(easymotion-gel)', 'o') ==# ':call EasyMotion#EL(0,1)' + Expect maparg('(easymotion-gel)', 'v') ==# ':call EasyMotion#EL(1,1)' + Expect maparg('(easymotion-bd-el)', 'n') ==# ':call EasyMotion#EL(0,2)' + Expect maparg('(easymotion-bd-el)', 'o') ==# ':call EasyMotion#EL(0,2)' + Expect maparg('(easymotion-bd-el)', 'v') ==# ':call EasyMotion#EL(1,2)' + " LineAnywhere + Expect maparg('(easymotion-lineforward)', 'n') + \ ==# ':call EasyMotion#LineAnywhere(0,0)' + Expect maparg('(easymotion-lineforward)', 'o') + \ ==# ':call EasyMotion#LineAnywhere(0,0)' + Expect maparg('(easymotion-lineforward)', 'v') + \ ==# ':call EasyMotion#LineAnywhere(1,0)' + Expect maparg('(easymotion-linebackward)', 'n') + \ ==# ':call EasyMotion#LineAnywhere(0,1)' + Expect maparg('(easymotion-linebackward)', 'o') + \ ==# ':call EasyMotion#LineAnywhere(0,1)' + Expect maparg('(easymotion-linebackward)', 'v') + \ ==# ':call EasyMotion#LineAnywhere(1,1)' + Expect maparg('(easymotion-lineanywhere)', 'n') + \ ==# ':call EasyMotion#LineAnywhere(0,2)' + Expect maparg('(easymotion-lineanywhere)', 'o') + \ ==# ':call EasyMotion#LineAnywhere(0,2)' + Expect maparg('(easymotion-lineanywhere)', 'v') + \ ==# ':call EasyMotion#LineAnywhere(1,2)' + " }}} + + " Special Motion: {{{ + " SelectLines + Expect maparg('(easymotion-special-l)', 'o') + \ ==# ':call EasyMotion#SelectLines()' + Expect maparg('(easymotion-special-l)', 'v') + \ ==# ':call EasyMotion#SelectLines()' + Expect maparg('(easymotion-special-ly)', 'n') + \ ==# ':call EasyMotion#SelectLinesYank()' + Expect maparg('(easymotion-special-ld)', 'n') + \ ==# ':call EasyMotion#SelectLinesDelete()' + " SelectPhrase + Expect maparg('(easymotion-special-p)', 'o') + \ ==# ':call EasyMotion#SelectPhrase()' + Expect maparg('(easymotion-special-p)', 'v') + \ ==# ':call EasyMotion#SelectPhrase()' + Expect maparg('(easymotion-special-py)', 'n') + \ ==# ':call EasyMotion#SelectPhraseYank()' + Expect maparg('(easymotion-special-pd)', 'n') + \ ==# ':call EasyMotion#SelectPhraseDelete()' + " }}} + end + + it 'provide autoload functions' + try + " load autoload functions + runtime autoload/EasyMotion.vim + runtime autoload/EasyMotion/helper.vim + runtime autoload/EasyMotion/cmigemo.vim + runtime autoload/EasyMotion/init.vim + runtime autoload/EasyMotion/sticky_table.vim + catch + endtry + " autoload/EasyMotion.vim {{{ + Expect exists('*EasyMotion#hoge') ==# 0 + Expect exists('*EasyMotion#S') ==# 1 + Expect exists('*EasyMotion#T') ==# 1 + Expect exists('*EasyMotion#WB') ==# 1 + Expect exists('*EasyMotion#WBW') ==# 1 + Expect exists('*EasyMotion#E') ==# 1 + Expect exists('*EasyMotion#EW') ==# 1 + Expect exists('*EasyMotion#JK') ==# 1 + Expect exists('*EasyMotion#Sol') ==# 1 + Expect exists('*EasyMotion#Eol') ==# 1 + Expect exists('*EasyMotion#Search') ==# 1 + Expect exists('*EasyMotion#JumpToAnywhere') ==# 1 + Expect exists('*EasyMotion#SL') ==# 1 + Expect exists('*EasyMotion#TL') ==# 1 + Expect exists('*EasyMotion#WBL') ==# 1 + Expect exists('*EasyMotion#EL') ==# 1 + Expect exists('*EasyMotion#LineAnywhere') ==# 1 + Expect exists('*EasyMotion#SelectLines') ==# 1 + Expect exists('*EasyMotion#SelectLinesYank') ==# 1 + Expect exists('*EasyMotion#SelectLinesDelete') ==# 1 + Expect exists('*EasyMotion#SelectPhrase') ==# 1 + Expect exists('*EasyMotion#SelectPhraseYank') ==# 1 + Expect exists('*EasyMotion#SelectPhraseDelete') ==# 1 + Expect exists('*EasyMotion#Repeat') ==# 1 + Expect exists('*EasyMotion#DotRepeat') ==# 1 + "}}} + end + + it 'provide variables to customize EasyMotion' + " Option {{{ + Expect g:EasyMotion_keys ==# 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' + Expect g:EasyMotion_do_mapping ==# 1 + Expect g:EasyMotion_do_special_mapping ==# 0 + Expect g:EasyMotion_do_shade ==# 1 + Expect g:EasyMotion_grouping ==# 1 + Expect g:EasyMotion_startofline ==# 1 + Expect g:EasyMotion_smartcase ==# 0 + Expect g:EasyMotion_skipfoldedline ==# 1 + Expect g:EasyMotion_use_migemo ==# 0 + Expect g:EasyMotion_use_upper ==# 0 + Expect g:EasyMotion_enter_jump_first ==# 0 + Expect g:EasyMotion_show_prompt ==# 1 + Expect g:EasyMotion_prompt ==# '> ' + Expect g:EasyMotion_command_line_key_mappings ==# {} + " }}} + + " highlight {{{ + Expect g:EasyMotion_hl_group_target ==# 'EasyMotionTarget' + Expect g:EasyMotion_hl2_first_group_target ==# 'EasyMotionTarget2First' + Expect g:EasyMotion_hl2_second_group_target ==# 'EasyMotionTarget2Second' + Expect g:EasyMotion_hl_group_shade ==# 'EasyMotionShade' + Expect g:EasyMotion_hl_line_group_shade ==# 'EasyMotionShadeLine' + " }}} + end +end +"}}} + +function! AddLine(str) + put! =a:str +endfunction + +function! CursorPos() + return [line('.'), col('.'), getline('.')[col('.')-1]] +endfunction + +" s, f, F, t and T mappings {{{ +describe 's, f, F, t and T mappings' + + before + new + let g:EasyMotion_keys = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' + map s (easymotion-s) + map f (easymotion-f) + map F (easymotion-F) + map t (easymotion-t) + map T (easymotion-T) + call EasyMotion#init() + call AddLine('poge huga hiyo poyo') + end + + after + close! + end + + " s {{{ + it 'provide improved forward search like builtin f & F' + normal! 0 + let l = line('.') + Expect CursorPos() == [l,1,'p'] + normal sha + Expect CursorPos() == [l,6,'h'] + Expect CursorPos() != [l,1,'h'] + + normal! 0 + let l = line('.') + Expect CursorPos() == [l,1,'p'] + normal shb + Expect CursorPos() == [l,11,'h'] + + normal sh + Expect CursorPos() == [l,6,'h'] + + normal! $ + let l = line('.') + Expect CursorPos() == [l,19,'o'] + + normal spc + Expect CursorPos() == [l,19,'o'] + + normal spb + Expect CursorPos() == [l,1,'p'] + end + "}}} + " f {{{ + it 'provide improved backward search like builtin f' + normal! 0 + let l = line('.') + Expect CursorPos() == [l,1,'p'] + + normal fha + Expect CursorPos() == [l,6,'h'] + Expect CursorPos() != [l,1,'h'] + + normal! 0 + let l = line('.') + Expect CursorPos() == [l,1,'p'] + normal fhb + Expect CursorPos() == [l,11,'h'] + + normal fh + Expect CursorPos() == [l,11,'h'] + + end + " "}}} + " F {{{ + it 'provide improved backward search like builtin F' + normal! $ + let l = line('.') + Expect CursorPos() == [l,19,'o'] + + normal Fpa + Expect CursorPos() == [l,16,'p'] + + normal! $ + normal Fpc + Expect CursorPos() == [l,19,'o'] + + normal Fpb + Expect CursorPos() == [l,1,'p'] + end + " "}}} + " t {{{ + it 'provide t mapping like builtin t' + normal! 0 + let l = line('.') + Expect CursorPos() == [l,1,'p'] + Expect CursorPos() != [l,10,'a'] + + normal tha + Expect CursorPos() == [l,5,' '] + + normal! 0 + normal thb + Expect CursorPos() == [l,10,' '] + + normal! 0 + normal thc + Expect CursorPos() == [l,1,'p'] + end + " }}} + " T {{{ + it 'provide T mapping like builtin T' + normal! $ + let l = line('.') + Expect CursorPos() == [l,19,'o'] + Expect CursorPos() != [l,18,'a'] + + normal Toa + Expect CursorPos() == [l,18,'y'] + + normal! $ + normal Tob + Expect CursorPos() == [l,15,' '] + + normal Toa + Expect CursorPos() == [l,3,'g'] + + normal! $ + normal Tod + Expect CursorPos() == [l,19,'o'] + + normal Toc + Expect CursorPos() == [l,3,'g'] + end + "}}} + " visual + it 'have different context in normal mode and visual mode' + let l = line('.') + Expect CursorPos() == [l, 1, 'p'] + + normal foa + Expect CursorPos() == [l, 2, 'o'] + + normal vfha + Expect CursorPos() == [l, 6, 'h'] + + normal fha + Expect CursorPos() == [l, 11, 'h'] + + normal! d + Expect getline('.') == "piyo poyo" + Expect CursorPos() == [l, 2, 'i'] + + normal! dfpa + Expect getline('.') == "poyo" + Expect CursorPos() == [l, 2, 'o'] + end +end +"}}} + +" a non-existent char {{{ +describe 'a non-existent char' + + before + new + let g:EasyMotion_keys = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' + map s (easymotion-s) + map f (easymotion-f) + map F (easymotion-F) + map t (easymotion-t) + map T (easymotion-T) + call EasyMotion#init() + call AddLine('poge huga hiyo poyo') + end + + after + close! + end + + " makes no change {{{ + it 'makes no change' + normal! 0 + let origin = CursorPos() + + normal fd + Expect CursorPos() == origin + normal f1 + Expect CursorPos() == origin + normal f) + Expect CursorPos() == origin + normal f^ + Expect CursorPos() == origin + normal fm + Expect CursorPos() == origin + end + "}}} +end +"}}} + +" when target is in other line, s, f and F mappings {{{ +describe 'when target is in other line, s, f and F mappings' + before + new + let g:EasyMotion_keys = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' + map s (easymotion-s) + map f (easymotion-f) + map F (easymotion-F) + map t (easymotion-t) + map T (easymotion-T) + call EasyMotion#init() + call AddLine('foo bar baz') " L2 + call AddLine('poge huga hiyo poyo') " L1 + " '1234567890123456789' + normal! gg0 + end + + after + close! + end + + " move cursor forward across lines {{{ + it 'move cursor forward & backward across lines' + normal! 0 + let l = line('.') + Expect col('.') == 1 + + normal saa + Expect CursorPos() == [l, 9, 'a'] + + normal saa + Expect CursorPos() == [l+1, 6, 'a'] + + normal sob + Expect CursorPos() == [l+1, 2, 'o'] + + normal! gg0 + let l = line('.') + Expect col('.') == 1 + + normal faa + Expect CursorPos() == [l, 9, 'a'] + + normal faa + Expect CursorPos() == [l+1, 6, 'a'] + + normal faa + Expect CursorPos() == [l+1, 10, 'a'] + + normal Faa + Expect CursorPos() == [l+1, 6, 'a'] + + normal Faa + Expect CursorPos() == [l, 9, 'a'] + end + " }}} +end +"}}} + +" Multibyte characters {{{ +describe 'Multibyte characters' + + before + new + let g:EasyMotion_keys = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' + map s (easymotion-s) + map f (easymotion-f) + map F (easymotion-F) + map t (easymotion-t) + map T (easymotion-T) + call EasyMotion#init() + call AddLine('ビムかわいいよzビムx') + call AddLine('foo bar baz') + normal! gg + end + + after + close! + end + + " is supported "{{{ + it 'is supported' + normal! gg0 + let l = line('.') + + normal fza + Expect CursorPos() == [l, 11, 'z'] + Expect CursorPos() != [l, 1, '2'] + + normal fz + Expect CursorPos() == [l+1, 22, 'z'] + + normal! h + normal fxa + Expect CursorPos() == [l+1, 29, 'x'] + end + " }}} + +end +"}}} + +" EasyMotion#helper#include_multibyte_char {{{ +describe 'EasyMotion#helper#include_multibyte_char' + + it 'return true when the argument includes multibyte char' + Expect EasyMotion#helper#include_multibyte_char("あいうえお") to_be_true + Expect EasyMotion#helper#include_multibyte_char("aiueoあ") to_be_true + Expect EasyMotion#helper#include_multibyte_char("123ABC45") to_be_true + end + + it 'return false when the argument does not include multibyte char' + Expect EasyMotion#helper#include_multibyte_char("aiueo") to_be_false + Expect EasyMotion#helper#include_multibyte_char("this_is_a_pen.") to_be_false + Expect EasyMotion#helper#include_multibyte_char("!#$%&'()'") to_be_false + Expect EasyMotion#helper#include_multibyte_char("") to_be_false + end + +end +"}}} + +" migemo support {{{ +describe 'migemo support' + + before + new + let g:EasyMotion_keys = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' + let g:EasyMotion_use_migemo = 1 + map s (easymotion-s) + map f (easymotion-f) + map F (easymotion-F) + map t (easymotion-t) + map T (easymotion-T) + call EasyMotion#init() + call AddLine('はー,ビムかわいいよビム') + normal! gg0 + end + + after + close! + let g:clever_f_use_migemo = 0 + end + + " makes f and F mapping match multibyte characters {{{ + it 'makes f and F mapping match multibyte characters' + normal fba + Expect col('.') == 10 + normal fb + Expect col('.') == 31 + normal Fb + Expect col('.') == 10 + normal $ + normal Fba + Expect col('.') == 31 + normal Fb + Expect col('.') == 10 + end + " }}} + + " makes t and T mapping match multibyte characters {{{ + it 'makes t and T mapping match multibyte characters' + normal tba + Expect col('.') == 7 + normal tb + Expect col('.') == 28 + normal Tb + Expect col('.') == 13 + normal $ + normal Tba + Expect col('.') == 13 + normal tb + Expect col('.') == 28 + end + " }}} + +end +"}}} + +" g:EasyMotion_smartcase {{{ +describe 'g:EasyMotion_smartcase' + + before + new + let g:EasyMotion_keys = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' + map s (easymotion-s) + map f (easymotion-f) + map F (easymotion-F) + map t (easymotion-t) + map T (easymotion-T) + call EasyMotion#init() + call AddLine('poHe huga Hiyo hoyo: poyo();') + 1234567890123456789012345678 + normal! gg0 + let g:EasyMotion_smartcase = 1 + end + + after + close! + let g:EasyMotion_smartcase = 0 + end + + " makes f smart case {{{ + it 'makes f smart case' + normal fha + Expect col('.') == 3 + normal fha + Expect col('.') == 6 + normal fha + Expect col('.') == 11 + normal fh + Expect col('.') == 16 + normal Fha + Expect col('.') == 11 + + normal! 0 + normal fHa + Expect col('.') == 3 + normal fH + Expect col('.') == 11 + normal fHa + Expect col('.') == 11 + normal FH + Expect col('.') == 3 + end + "}}} + + " makes t smart case {{{ + it 'makes t smart case' + normal! $ + normal Tha + Expect col('.') == 17 + normal Tha + Expect col('.') == 12 + normal Tha + Expect col('.') == 7 + normal Th + Expect col('.') == 4 + normal tha + Expect col('.') == 5 + + normal! $ + normal THa + Expect col('.') == 12 + normal TH + Expect col('.') == 4 + normal tH + Expect col('.') == 10 + end + " }}} + + " makes no effect on searching signs {{{ + it 'makes no effect on searching signs' + normal! 0 + normal f; + Expect col('.') == 28 + normal! 0 + normal f: + Expect col('.') == 20 + normal f: + Expect col('.') == 20 + end + " }}} +end +"}}} + +" g:EasyMotion_smartsign {{{ +describe 'g:EasyMotion_smartsign' + + before + new + let g:EasyMotion_keys = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' + map s (easymotion-s) + map f (easymotion-f) + map F (easymotion-F) + map t (easymotion-t) + map T (easymotion-T) + call EasyMotion#init() + call AddLine('poHe huga Hiyo hoyo: poyo();') + 1234567890123456789012345678 + normal! gg0 + let g:EasyMotion_smartcase = 1 + let g:EasyMotion_use_smartsign_us = 1 + end + + after + close! + let g:EasyMotion_smartcase = 0 + let g:EasyMotion_use_smartsign_us = 0 + end + + " makes f smart sign {{{ + it 'makes f smart case' + normal! 0 + normal f; + Expect col('.') == 1 + normal f;a + Expect col('.') == 20 + normal f; + Expect col('.') == 28 + + normal! 0 + normal f: + Expect col('.') == 20 + normal f: + Expect col('.') == 20 + end + "}}} + + " makes no effect on searching signs {{{ + " it 'makes no effect on searching signs' + " normal! 0 + " normal f; + " Expect col('.') == 28 + " normal! 0 + " normal f: + " Expect col('.') == 20 + " normal f: + " Expect col('.') == 20 + " end + " }}} +end +"}}} From 6c9ac6ce566c78321a53e184c76406fee7ee4403 Mon Sep 17 00:00:00 2001 From: haya14busa Date: Thu, 16 Jan 2014 20:51:36 +0900 Subject: [PATCH 5/5] Update doc: '.' repeat! --- doc/easymotion.txt | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/doc/easymotion.txt b/doc/easymotion.txt index a09022c..a4e62d1 100644 --- a/doc/easymotion.txt +++ b/doc/easymotion.txt @@ -1,4 +1,4 @@ -*easymotion.txt* Version 2.0 Last change:15 Jan 2014. +*easymotion.txt* Version 2.0 Last change:16 Jan 2014. ______ __ ___ __ _ @@ -255,6 +255,35 @@ Repeat ~ does not repeat motion type (e.g. othrer word motion, (easymotion-j) etc...) but only repeat input characters. + +EasyMotion dot repeat~ + *easymotion-dotrepeat* *easymotion-textobjct* + + This feature requires tpope/vim-repeat + https://github.com/tpope/vim-repeat + + All motion type support '.' repeat. + + Example: +> + " vimrc: + omap z (easymotion-t) + let g:EasyMotion_keys='hklyuiopnm,qwertzxcvbasdgjf;' +< + Text sample: +> + {cursor}Lorem ipsum dolor sit ame*t*, consectetur adipisicing eli*t*, + sed do eiusmod tempor +< + type `dzt` and type first target marker(in this case, `h`) +> + {cursor}*t*, consectetur adipisicing eli*t,* sed do eiusmod tempor +< + just type '`.`' +> + *t,* sed do eiusmod tempor +< + JK Motion ~ *easymotion-jk-motion*