2013-12-18 08:41:31 -05:00
|
|
|
" Saving 'cpoptions' {{{
|
|
|
|
let s:save_cpo = &cpo
|
|
|
|
set cpo&vim
|
|
|
|
" }}}
|
|
|
|
|
|
|
|
function! EasyMotion#init#InitHL(group, colors) " {{{
|
2014-01-17 03:39:26 -05:00
|
|
|
let group_default = a:group . 'Default'
|
2013-12-18 08:41:31 -05:00
|
|
|
|
2014-01-17 03:39:26 -05:00
|
|
|
" Prepare highlighting variables
|
|
|
|
let guihl = printf('guibg=%s guifg=%s gui=%s', a:colors.gui[0], a:colors.gui[1], a:colors.gui[2])
|
|
|
|
if !exists('g:CSApprox_loaded')
|
|
|
|
let ctermhl = &t_Co == 256
|
|
|
|
\ ? printf('ctermbg=%s ctermfg=%s cterm=%s', a:colors.cterm256[0], a:colors.cterm256[1], a:colors.cterm256[2])
|
|
|
|
\ : printf('ctermbg=%s ctermfg=%s cterm=%s', a:colors.cterm[0], a:colors.cterm[1], a:colors.cterm[2])
|
|
|
|
else
|
|
|
|
let ctermhl = ''
|
|
|
|
endif
|
2013-12-18 08:41:31 -05:00
|
|
|
|
2014-01-17 03:39:26 -05:00
|
|
|
" Create default highlighting group
|
|
|
|
execute printf('hi default %s %s %s', group_default, guihl, ctermhl)
|
2013-12-18 08:41:31 -05:00
|
|
|
|
2014-01-17 03:39:26 -05:00
|
|
|
" Check if the hl group exists
|
|
|
|
if hlexists(a:group)
|
|
|
|
redir => hlstatus | exec 'silent hi ' . a:group | redir END
|
2013-12-18 08:41:31 -05:00
|
|
|
|
2014-01-17 03:39:26 -05:00
|
|
|
" Return if the group isn't cleared
|
|
|
|
if hlstatus !~ 'cleared'
|
|
|
|
return
|
|
|
|
endif
|
|
|
|
endif
|
2013-12-18 08:41:31 -05:00
|
|
|
|
2014-01-17 03:39:26 -05:00
|
|
|
" No colors are defined for this group, link to defaults
|
|
|
|
execute printf('hi default link %s %s', a:group, group_default)
|
2013-12-18 08:41:31 -05:00
|
|
|
endfunction " }}}
|
|
|
|
|
2013-12-20 02:47:05 -05:00
|
|
|
function! EasyMotion#init#InitMappings(motions, do_mapping) "{{{
|
2014-01-17 03:39:26 -05:00
|
|
|
for [motion, fn] in items(a:motions)
|
|
|
|
" Mapping {{{
|
|
|
|
if exists('g:EasyMotion_mapping_' . motion)
|
|
|
|
" Backward compatible mapping [deprecated]
|
|
|
|
silent exec 'map <silent> ' .
|
|
|
|
\ eval('g:EasyMotion_mapping_' . motion) . ' <Plug>(easymotion-' . motion . ')'
|
|
|
|
elseif a:do_mapping
|
|
|
|
\ && !hasmapto('<Plug>(easymotion-' . motion . ')')
|
|
|
|
\ && empty(maparg('<Plug>(easymotion-prefix)' . motion, 'nov'))
|
2013-12-22 06:49:35 -05:00
|
|
|
|
2014-01-17 03:39:26 -05:00
|
|
|
" Do mapping
|
|
|
|
silent exec 'map <silent> ' .
|
|
|
|
\'<Plug>(easymotion-prefix)' . motion . ' <Plug>(easymotion-' . motion . ')'
|
|
|
|
endif "}}}
|
2013-12-22 06:49:35 -05:00
|
|
|
|
2014-01-17 03:39:26 -05:00
|
|
|
endfor
|
2013-12-18 08:41:31 -05:00
|
|
|
endfunction "}}}
|
|
|
|
|
2013-12-21 07:29:27 -05:00
|
|
|
function! EasyMotion#init#InitSpecialMappings(motions, do_mapping) "{{{
|
2014-01-17 03:39:26 -05:00
|
|
|
for [motion, fn] in items(a:motions)
|
|
|
|
" Do mapping {{{
|
|
|
|
if a:do_mapping
|
|
|
|
\ && !hasmapto('<Plug>(easymotion-special-' . motion . ')')
|
|
|
|
\ && empty(maparg('<Plug>(easymotion-prefix)' . motion, 'ov'))
|
|
|
|
\ && empty(maparg('d<Plug>(easymotion-prefix)'. motion, 'n'))
|
|
|
|
\ && empty(maparg('y<Plug>(easymotion-prefix)'. motion, 'n'))
|
|
|
|
silent exec 'omap <silent> ' .
|
|
|
|
\ '<Plug>(easymotion-prefix)' . motion . ' <Plug>(easymotion-special-' . motion . ')'
|
|
|
|
silent exec 'xmap <silent> ' .
|
|
|
|
\ '<Plug>(easymotion-prefix)' . motion . ' <Plug>(easymotion-special-' . motion . ')'
|
|
|
|
silent exec 'nmap <silent> ' .
|
|
|
|
\ 'd<Plug>(easymotion-prefix)' . motion . ' <Plug>(easymotion-special-' . motion . 'd)'
|
|
|
|
silent exec 'nmap <silent> ' .
|
|
|
|
\ 'y<Plug>(easymotion-prefix)' . motion . ' <Plug>(easymotion-special-' . motion . 'y)'
|
|
|
|
endif "}}}
|
|
|
|
endfor
|
2013-12-18 08:41:31 -05:00
|
|
|
endfunction "}}}
|
|
|
|
|
|
|
|
" Restore 'cpoptions' {{{
|
|
|
|
let &cpo = s:save_cpo
|
|
|
|
unlet s:save_cpo
|
|
|
|
" }}}
|
2014-01-17 03:39:26 -05:00
|
|
|
" vim: fdm=marker:et:ts=4:sw=4:sts=4
|