Support jump to first target feature for overwin motions

This commit is contained in:
haya14busa 2016-01-19 03:02:44 +09:00
parent 69753395d0
commit 7578ffe479
2 changed files with 11 additions and 2 deletions

View File

@ -9,6 +9,9 @@ function! EasyMotion#overwin#move(pattern) abort
\ 'shade': g:EasyMotion_hl_group_shade,
\ 'target': g:EasyMotion_hl_group_target,
\ },
\ 'jump_first_target_keys':
\ (g:EasyMotion_enter_jump_first ? ["\<CR>"] : []) +
\ (g:EasyMotion_space_jump_first ? ["\<Space>"] : [])
\ })
endfunction

View File

@ -53,12 +53,13 @@ let s:overwin = {
\ 'shade': 'HitAHintShade',
\ 'target': 'HitAHintTarget',
\ },
\ 'jump_first_target_keys': [],
\ }
\ }
function! s:_init_hl() abort
highlight HitAHintShade ctermfg=242 guifg=#777777
highlight HitAHintTarget ctermfg=81 guifg=#66D9EF
highlight default HitAHintShade ctermfg=242 guifg=#777777
highlight default HitAHintTarget ctermfg=81 guifg=#66D9EF
endfunction
call s:_init_hl()
@ -181,6 +182,11 @@ function! s:overwin.choose_prompt(hint_dict) abort
call hinter.after()
endtry
" Jump to first target if target key is in config.jump_first_target_keys.
if index(self.config.jump_first_target_keys, c) isnot# -1
let c = split(self.config.keys, '\zs')[0]
endif
if has_key(a:hint_dict, c)
let target = a:hint_dict[c]
return type(target) is# type({}) ? self.choose_prompt(target) : target