Skip to content

Commit 291d92b

Browse files
committed
Merge branch 'overwin' #130
2 parents 019fc00 + c3d7bae commit 291d92b

File tree

15 files changed

+1765
-44
lines changed

15 files changed

+1765
-44
lines changed

Diff for: README.md

+51
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,57 @@ Jeffrey Way of Nettuts+ has also [written
101101
a tutorial](http://net.tutsplus.com/tutorials/other/vim-essential-plugin-easymotion/)
102102
about EasyMotion.
103103

104+
New features in version 3.0
105+
====
106+
107+
### Overwin motions
108+
![](https://raw.githubusercontent.com/haya14busa/i/2753bd4dd1dfdf5962dbdbffabf24244e4e14243/easymotion/overwin-motions.gif)
109+
110+
EasyMotion now supports moving cursor across/over window.
111+
Since it doesn't make sense that moving cursor to other window while Visual or
112+
Operator-pending mode, overwin motions only provides mappings for Normal
113+
mode. Please use `nmap` to use overwin motions. Overwin motions only
114+
supports bi-directional motions.
115+
116+
#### Example configuration
117+
118+
```vim
119+
" <Leader>f{char} to move to {char}
120+
map <Leader>f <Plug>(easymotion-bd-f)
121+
nmap <Leader>f <Plug>(easymotion-overwin-f)
122+
123+
" s{char}{char} to move to {char}{char}
124+
nmap s <Plug>(easymotion-overwin-f2)
125+
126+
" Move to line
127+
map <Leader>L <Plug>(easymotion-bd-jk)
128+
nmap <Leader>L <Plug>(easymotion-overwin-line)
129+
130+
" Move to word
131+
map <Leader>w <Plug>(easymotion-bd-w)
132+
nmap <Leader>w <Plug>(easymotion-overwin-w)
133+
```
134+
135+
#### Integration with incsearch.vim
136+
137+
```vim
138+
" You can use other keymappings like <C-l> instead of <CR> if you want to
139+
" use these mappings as default search and somtimes want to move cursor with
140+
" EasyMotion.
141+
function! s:incsearch_config(...) abort
142+
return incsearch#util#deepextend(deepcopy({
143+
\ 'modules': [incsearch#config#easymotion#module({'overwin': 1)],
144+
\ 'keymap': {
145+
\ "\<CR>": '<Over>(easymotion)'
146+
\ },
147+
\ 'is_expr': 0
148+
\ }), get(a:, 1, {}))
149+
endfunction
150+
151+
noremap <silent><expr> / incsearch#go(<SID>incsearch_config())
152+
noremap <silent><expr> ? incsearch#go(<SID>incsearch_config({'command': '?'}))
153+
noremap <silent><expr> g/ incsearch#go(<SID>incsearch_config({'is_stay': 1}))
154+
```
104155

105156
New features in version 2.0
106157
====

Diff for: autoload/EasyMotion.vim

+13-4
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ function! EasyMotion#S(num_strokes, visualmode, direction) " {{{
138138
call s:EasyMotion(re, a:direction, a:visualmode ? visualmode() : '', is_inclusive)
139139
return s:EasyMotion_is_cancelled
140140
endfunction " }}}
141+
function! EasyMotion#OverwinF(num_strokes) " {{{
142+
let re = s:findMotion(a:num_strokes, s:DIRECTION.bidirection)
143+
return EasyMotion#overwin#move(re)
144+
endfunction "}}}
141145
function! EasyMotion#T(num_strokes, visualmode, direction) " {{{
142146
if a:direction == 1
143147
let is_inclusive = 0
@@ -272,7 +276,8 @@ let s:config = {
272276
\ 'visualmode': s:FALSE,
273277
\ 'direction': s:DIRECTION.forward,
274278
\ 'inclusive': s:FALSE,
275-
\ 'accept_cursor_pos': s:FALSE
279+
\ 'accept_cursor_pos': s:FALSE,
280+
\ 'overwin': s:FALSE
276281
\ }
277282

278283
function! s:default_config() abort
@@ -284,9 +289,13 @@ endfunction
284289

285290
function! EasyMotion#go(...) abort
286291
let c = extend(s:default_config(), get(a:, 1, {}))
287-
let s:current.is_operator = mode(1) ==# 'no' ? 1: 0
288-
call s:EasyMotion(c.pattern, c.direction, c.visualmode ? visualmode() : '', c.inclusive, c)
289-
return s:EasyMotion_is_cancelled
292+
if c.overwin
293+
return EasyMotion#overwin#move(c.pattern)
294+
else
295+
let s:current.is_operator = mode(1) ==# 'no' ? 1: 0
296+
call s:EasyMotion(c.pattern, c.direction, c.visualmode ? visualmode() : '', c.inclusive, c)
297+
return s:EasyMotion_is_cancelled
298+
endif
290299
endfunction
291300
function! EasyMotion#User(pattern, visualmode, direction, inclusive, ...) " {{{
292301
let s:current.is_operator = mode(1) ==# 'no' ? 1: 0

Diff for: autoload/EasyMotion/command_line.vim

+6
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,12 @@ endfunction "}}}
137137
function! s:search.on_leave(cmdline) "{{{
138138
if s:num_strokes == -1
139139
call EasyMotion#highlight#delete_highlight(g:EasyMotion_hl_inc_search)
140+
if g:EasyMotion_do_shade
141+
call EasyMotion#highlight#delete_highlight(g:EasyMotion_hl_group_shade)
142+
endif
143+
endif
144+
if g:EasyMotion_cursor_highlight
145+
call EasyMotion#highlight#delete_highlight(g:EasyMotion_hl_inc_cursor)
140146
endif
141147
endfunction "}}}
142148
function! s:search.on_char(cmdline) "{{{

Diff for: autoload/EasyMotion/overwin.vim

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
let s:V = vital#of('easymotion')
2+
let s:HitAHintMotion = s:V.import('HitAHint.Motion')
3+
4+
function! EasyMotion#overwin#move(pattern) abort
5+
return s:HitAHintMotion.move(a:pattern, {
6+
\ 'keys': g:EasyMotion_keys,
7+
\ 'use_upper': g:EasyMotion_use_upper,
8+
\ 'highlight': {
9+
\ 'shade': g:EasyMotion_hl_group_shade,
10+
\ 'target': g:EasyMotion_hl_group_target,
11+
\ },
12+
\ 'jump_first_target_keys':
13+
\ (g:EasyMotion_enter_jump_first ? ["\<CR>"] : []) +
14+
\ (g:EasyMotion_space_jump_first ? ["\<Space>"] : [])
15+
\ })
16+
endfunction
17+
18+
function! EasyMotion#overwin#line() abort
19+
return EasyMotion#overwin#move('^')
20+
endfunction
21+
22+
function! EasyMotion#overwin#w() abort
23+
return EasyMotion#overwin#move('\(\<.\|^$\)')
24+
endfunction

Diff for: autoload/vital/_easymotion.vim

+7-17
Original file line numberDiff line numberDiff line change
@@ -237,26 +237,16 @@ function! s:_build_module(sid) abort
237237
for func in functions
238238
let module[func] = function(prefix . func)
239239
endfor
240+
if has_key(module, '_vital_created')
241+
call module._vital_created(module)
242+
endif
243+
let export_module = filter(copy(module), 'v:key =~# "^\\a"')
244+
let s:loaded[a:sid] = get(g:, 'vital_debug', 0) ? module : export_module
240245
if has_key(module, '_vital_loaded')
241246
let V = vital#{s:self_version}#new()
242-
if has_key(module, '_vital_depends')
243-
let all = {}
244-
let modules =
245-
\ s:_concat(map(module._vital_depends(),
246-
\ 's:expand_modules(v:val, all)'))
247-
call call(V.load, modules, V)
248-
endif
249-
try
250-
call module._vital_loaded(V)
251-
catch
252-
" FIXME: Show an error message for debug.
253-
endtry
254-
endif
255-
if !get(g:, 'vital_debug', 0)
256-
call filter(module, 'v:key =~# "^\\a"')
247+
call module._vital_loaded(V)
257248
endif
258-
let s:loaded[a:sid] = module
259-
return copy(module)
249+
return copy(s:loaded[a:sid])
260250
endfunction
261251

262252
if exists('+regexpengine')

Diff for: autoload/vital/_easymotion/Data/List.vim

+3-3
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ endfunction
225225
" similar to Haskell's Prelude.foldl1
226226
function! s:foldl1(f, xs) abort
227227
if len(a:xs) == 0
228-
throw 'foldl1'
228+
throw 'vital: Data.List: foldl1'
229229
endif
230230
return s:foldl(a:f, a:xs[0], a:xs[1:])
231231
endfunction
@@ -238,7 +238,7 @@ endfunction
238238
" similar to Haskell's Prelude.fold11
239239
function! s:foldr1(f, xs) abort
240240
if len(a:xs) == 0
241-
throw 'foldr1'
241+
throw 'vital: Data.List: foldr1'
242242
endif
243243
return s:foldr(a:f, a:xs[-1], a:xs[0:-2])
244244
endfunction
@@ -264,7 +264,7 @@ endfunction
264264
" Inspired by Ruby's with_index method.
265265
function! s:with_index(list, ...) abort
266266
let base = a:0 > 0 ? a:1 : 0
267-
return s:zip(a:list, range(base, len(a:list)+base-1))
267+
return map(copy(a:list), '[v:val, v:key + base]')
268268
endfunction
269269

270270
" similar to Ruby's detect or Haskell's find.

0 commit comments

Comments
 (0)