From 70cffa224344101e8476050345255aba3702469b Mon Sep 17 00:00:00 2001 From: paraduxos Date: Thu, 7 Jan 2021 15:14:58 +0700 Subject: [PATCH 1/5] Add iskeyword option --- autoload/EasyMotion.vim | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/autoload/EasyMotion.vim b/autoload/EasyMotion.vim index 2a472237..8af8ad9d 100644 --- a/autoload/EasyMotion.vim +++ b/autoload/EasyMotion.vim @@ -21,6 +21,12 @@ function! EasyMotion#init() if s:loaded return endif + " iskeyword for EasyMotion + if exists("g:EasyMotion_is_not_keyword") + let s:tmp_keyword = &iskeyword + silent! execute "set iskeyword-=".g:EasyMotion_is_not_keyword + autocmd User EasyMotionPromptEnd silent! execute "set iskeyword=".s:tmp_keyword + endif let s:loaded = s:TRUE call EasyMotion#highlight#load() " Store previous motion info @@ -1196,6 +1202,9 @@ function! s:DotPromptUser(groups) "{{{ endfunction "}}} function! s:EasyMotion(regexp, direction, visualmode, is_inclusive, ...) " {{{ + if exists("g:EasyMotion_is_not_keyword") + execute "set iskeyword-=".g:EasyMotion_is_not_keyword + endif let config = extend(s:default_config(), get(a:, 1, {})) " Store s:current original_position & cursor_position {{{ " current cursor pos. @@ -1598,6 +1607,9 @@ function! s:EasyMotion(regexp, direction, visualmode, is_inclusive, ...) " {{{ call EasyMotion#attach_active_autocmd() "}}} endif endtry + if exists("g:EasyMotion_is_not_keyword") + execute "set iskeyword+=".g:EasyMotion_is_not_keyword + endif endfunction " }}} "}}} " }}} From e3f94b2e42e81ed0ad4e93cecdc73bbc20129c6c Mon Sep 17 00:00:00 2001 From: paraduxos Date: Thu, 7 Jan 2021 15:17:12 +0700 Subject: [PATCH 2/5] Add iskeyword option --- autoload/EasyMotion.vim | 6 ------ 1 file changed, 6 deletions(-) diff --git a/autoload/EasyMotion.vim b/autoload/EasyMotion.vim index 8af8ad9d..35f2eba0 100644 --- a/autoload/EasyMotion.vim +++ b/autoload/EasyMotion.vim @@ -21,12 +21,6 @@ function! EasyMotion#init() if s:loaded return endif - " iskeyword for EasyMotion - if exists("g:EasyMotion_is_not_keyword") - let s:tmp_keyword = &iskeyword - silent! execute "set iskeyword-=".g:EasyMotion_is_not_keyword - autocmd User EasyMotionPromptEnd silent! execute "set iskeyword=".s:tmp_keyword - endif let s:loaded = s:TRUE call EasyMotion#highlight#load() " Store previous motion info From 4aa6b26cebe10b3a87f5e062a85737f24a15db28 Mon Sep 17 00:00:00 2001 From: paraduxos Date: Thu, 7 Jan 2021 15:32:11 +0700 Subject: [PATCH 3/5] Add documentation and comment --- autoload/EasyMotion.vim | 2 ++ doc/easymotion.txt | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/autoload/EasyMotion.vim b/autoload/EasyMotion.vim index 35f2eba0..c1e4c7db 100644 --- a/autoload/EasyMotion.vim +++ b/autoload/EasyMotion.vim @@ -1196,6 +1196,7 @@ function! s:DotPromptUser(groups) "{{{ endfunction "}}} function! s:EasyMotion(regexp, direction, visualmode, is_inclusive, ...) " {{{ + " Set local iskeyword for EasyMotion if exists("g:EasyMotion_is_not_keyword") execute "set iskeyword-=".g:EasyMotion_is_not_keyword endif @@ -1601,6 +1602,7 @@ function! s:EasyMotion(regexp, direction, visualmode, is_inclusive, ...) " {{{ call EasyMotion#attach_active_autocmd() "}}} endif endtry + " Turn iskeyword back to normal setting if exists("g:EasyMotion_is_not_keyword") execute "set iskeyword+=".g:EasyMotion_is_not_keyword endif diff --git a/doc/easymotion.txt b/doc/easymotion.txt index 1998112f..4df06835 100644 --- a/doc/easymotion.txt +++ b/doc/easymotion.txt @@ -475,6 +475,13 @@ iskeyword compatible word motions *(easymotion-iskeyword-w)* map b (easymotion-iskeyword-b) < NOTE: Within line motions are compatible with |iskeyword| by default. + If you want separated |iskeyword| for EasyMotion, you can use default + |iskeyword| option. + + Example: +> + let g:EasyMotion_is_not_keyword = "-_" +< Search motion respect previous direction From c86d4ef86fb75fbbf596f708d17485d2d5ea1457 Mon Sep 17 00:00:00 2001 From: paraduxos Date: Thu, 7 Jan 2021 16:08:28 +0700 Subject: [PATCH 4/5] Fix bug: loop through string --- autoload/EasyMotion.vim | 8 ++++++-- doc/easymotion.txt | 5 +++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/autoload/EasyMotion.vim b/autoload/EasyMotion.vim index c1e4c7db..3cae392e 100644 --- a/autoload/EasyMotion.vim +++ b/autoload/EasyMotion.vim @@ -1198,7 +1198,11 @@ endfunction "}}} function! s:EasyMotion(regexp, direction, visualmode, is_inclusive, ...) " {{{ " Set local iskeyword for EasyMotion if exists("g:EasyMotion_is_not_keyword") - execute "set iskeyword-=".g:EasyMotion_is_not_keyword + let s:initial_keyword = &iskeyword + let s:exclude_keyword = split(g:EasyMotion_is_not_keyword, ",") + for item in s:exclude_keyword + execute "set iskeyword-=".item + endfor endif let config = extend(s:default_config(), get(a:, 1, {})) " Store s:current original_position & cursor_position {{{ @@ -1604,7 +1608,7 @@ function! s:EasyMotion(regexp, direction, visualmode, is_inclusive, ...) " {{{ endtry " Turn iskeyword back to normal setting if exists("g:EasyMotion_is_not_keyword") - execute "set iskeyword+=".g:EasyMotion_is_not_keyword + execute "set iskeyword=".s:initial_keyword endif endfunction " }}} "}}} diff --git a/doc/easymotion.txt b/doc/easymotion.txt index 4df06835..9c65826c 100644 --- a/doc/easymotion.txt +++ b/doc/easymotion.txt @@ -476,11 +476,12 @@ iskeyword compatible word motions *(easymotion-iskeyword-w)* < NOTE: Within line motions are compatible with |iskeyword| by default. If you want separated |iskeyword| for EasyMotion, you can use default - |iskeyword| option. + |iskeyword| option separated by comma. Example: > - let g:EasyMotion_is_not_keyword = "-_" + " Exclude - and _ (dash and underscore) + let g:EasyMotion_is_not_keyword = "-,_" < Search motion respect previous direction From bfa406e5f28af071ff758f2b0e5f619870669d33 Mon Sep 17 00:00:00 2001 From: paraduxos Date: Thu, 7 Jan 2021 19:08:27 +0700 Subject: [PATCH 5/5] Fix styling --- autoload/EasyMotion.vim | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/autoload/EasyMotion.vim b/autoload/EasyMotion.vim index 3cae392e..f1ea97b9 100644 --- a/autoload/EasyMotion.vim +++ b/autoload/EasyMotion.vim @@ -1197,11 +1197,11 @@ endfunction "}}} function! s:EasyMotion(regexp, direction, visualmode, is_inclusive, ...) " {{{ " Set local iskeyword for EasyMotion - if exists("g:EasyMotion_is_not_keyword") + if exists('g:EasyMotion_is_not_keyword') let s:initial_keyword = &iskeyword - let s:exclude_keyword = split(g:EasyMotion_is_not_keyword, ",") + let s:exclude_keyword = split(g:EasyMotion_is_not_keyword, ',') for item in s:exclude_keyword - execute "set iskeyword-=".item + execute 'set iskeyword-='.item endfor endif let config = extend(s:default_config(), get(a:, 1, {})) @@ -1607,8 +1607,8 @@ function! s:EasyMotion(regexp, direction, visualmode, is_inclusive, ...) " {{{ endif endtry " Turn iskeyword back to normal setting - if exists("g:EasyMotion_is_not_keyword") - execute "set iskeyword=".s:initial_keyword + if exists('g:EasyMotion_is_not_keyword') + execute 'set iskeyword='.s:initial_keyword endif endfunction " }}} "}}}