Reset default highlighting after loading a color scheme
Color schemes use `hi clear`, which clears the EasyMotion syntax highlighting when a new color scheme is loaded. This change introduces `autocmd`s which reset the default colors after loading a new color scheme. Closes #6.
This commit is contained in:
parent
c48db22d4c
commit
a7b7becea4
@ -16,15 +16,13 @@
|
|||||||
exec 'let g:EasyMotion_' . a:option . ' = ' . string(a:default)
|
exec 'let g:EasyMotion_' . a:option . ' = ' . string(a:default)
|
||||||
endif
|
endif
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
function! s:InitHL(group, gui, cterm256, cterm) " {{{
|
function! s:InitHL(group, colors) " {{{
|
||||||
if ! hlexists(a:group)
|
let guihl = printf('guibg=%s guifg=#%s gui=%s', a:colors.gui[0], a:colors.gui[1], a:colors.gui[2])
|
||||||
let guihl = printf('guibg=%s guifg=#%s gui=%s', a:gui[0], a:gui[1], a:gui[2])
|
let ctermhl = &t_Co == 256
|
||||||
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:cterm256[0], a:cterm256[1], a:cterm256[2])
|
\ : printf('ctermbg=%s ctermfg=%s cterm=%s', a:colors.cterm[0], a:colors.cterm[1], a:colors.cterm[2])
|
||||||
\ : printf('ctermbg=%s ctermfg=%s cterm=%s', a:cterm[0], a:cterm[1], a:cterm[2])
|
|
||||||
|
|
||||||
execute printf('hi %s %s %s', a:group, guihl, ctermhl)
|
execute printf('hi default %s %s %s', a:group, guihl, ctermhl)
|
||||||
endif
|
|
||||||
endfunction " }}}
|
endfunction " }}}
|
||||||
|
|
||||||
call s:InitOption('keys', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ')
|
call s:InitOption('keys', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ')
|
||||||
@ -33,8 +31,31 @@
|
|||||||
call s:InitOption('do_shade', 1)
|
call s:InitOption('do_shade', 1)
|
||||||
call s:InitOption('do_mapping', 1)
|
call s:InitOption('do_mapping', 1)
|
||||||
|
|
||||||
call s:InitHL(g:EasyMotion_target_hl, ['NONE', 'ff0000', 'bold'], ['NONE', '196', 'bold'], ['NONE', 'red', 'bold'])
|
" Init highlighting {{{
|
||||||
call s:InitHL(g:EasyMotion_shade_hl, ['NONE', '585858', 'NONE'], ['NONE', '240', 'NONE'], ['NONE', 'darkgrey', 'NONE'])
|
let s:target_hl_defaults = {
|
||||||
|
\ 'gui' : ['NONE', 'ff0000' , 'bold']
|
||||||
|
\ , 'cterm256': ['NONE', '196' , 'bold']
|
||||||
|
\ , 'cterm' : ['NONE', 'red' , 'bold']
|
||||||
|
\ }
|
||||||
|
|
||||||
|
let s:shade_hl_defaults = {
|
||||||
|
\ 'gui' : ['NONE', '585858' , 'NONE']
|
||||||
|
\ , 'cterm256': ['NONE', '240' , 'NONE']
|
||||||
|
\ , 'cterm' : ['NONE', 'darkgrey', 'NONE']
|
||||||
|
\ }
|
||||||
|
|
||||||
|
call s:InitHL(g:EasyMotion_target_hl, s:target_hl_defaults)
|
||||||
|
call s:InitHL(g:EasyMotion_shade_hl, s:shade_hl_defaults)
|
||||||
|
|
||||||
|
" Reset highlighting after loading a new color scheme {{{
|
||||||
|
augroup EasyMotionInitHL
|
||||||
|
autocmd!
|
||||||
|
|
||||||
|
autocmd ColorScheme * call s:InitHL(g:EasyMotion_target_hl, s:target_hl_defaults)
|
||||||
|
autocmd ColorScheme * call s:InitHL(g:EasyMotion_shade_hl, s:shade_hl_defaults)
|
||||||
|
augroup end
|
||||||
|
" }}}
|
||||||
|
" }}}
|
||||||
" }}}
|
" }}}
|
||||||
" Default key mapping {{{
|
" Default key mapping {{{
|
||||||
if g:EasyMotion_do_mapping
|
if g:EasyMotion_do_mapping
|
||||||
|
Loading…
x
Reference in New Issue
Block a user