Merge branch 'handle/avoidhighlight' into master
This commit is contained in:
commit
3980b690bb
@ -3,7 +3,7 @@
|
|||||||
" Author: Kim Silkebækken <kim.silkebaekken+vim@gmail.com>
|
" Author: Kim Silkebækken <kim.silkebaekken+vim@gmail.com>
|
||||||
" haya14busa <hayabusa1419@gmail.com>
|
" haya14busa <hayabusa1419@gmail.com>
|
||||||
" Source: https://github.com/Lokaltog/vim-easymotion
|
" Source: https://github.com/Lokaltog/vim-easymotion
|
||||||
" Last Change: 13 Feb 2014.
|
" Last Change: 15 Feb 2014.
|
||||||
"=============================================================================
|
"=============================================================================
|
||||||
" Saving 'cpoptions' {{{
|
" Saving 'cpoptions' {{{
|
||||||
scriptencoding utf-8
|
scriptencoding utf-8
|
||||||
@ -364,34 +364,21 @@ function! s:RestoreValue() "{{{
|
|||||||
call s:VarReset('&virtualedit')
|
call s:VarReset('&virtualedit')
|
||||||
call s:VarReset('&foldmethod')
|
call s:VarReset('&foldmethod')
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
function! s:turn_on_hl_error() "{{{
|
|
||||||
if exists("s:old_hl_error")
|
|
||||||
execute "highlight Error " . s:old_hl_error
|
|
||||||
unlet s:old_hl_error
|
|
||||||
endif
|
|
||||||
endfunction "}}}
|
|
||||||
function! s:turn_off_hl_error() "{{{
|
function! s:turn_off_hl_error() "{{{
|
||||||
if exists("s:old_hl_error")
|
let s:error_hl = EasyMotion#highlight#capture('Error')
|
||||||
return s:old_hl_error
|
call EasyMotion#highlight#turn_off(s:error_hl)
|
||||||
|
let s:matchparen_hl = EasyMotion#highlight#capture('MatchParen')
|
||||||
|
call EasyMotion#highlight#turn_off(s:matchparen_hl)
|
||||||
|
endfunction "}}}
|
||||||
|
function! s:turn_on_hl_error() "{{{
|
||||||
|
if exists('s:error_hl')
|
||||||
|
call EasyMotion#highlight#turn_on(s:error_hl)
|
||||||
|
unlet s:error_hl
|
||||||
endif
|
endif
|
||||||
if hlexists("Error")
|
|
||||||
let save_verbose = &verbose
|
if exists('s:matchparen_hl')
|
||||||
let &verbose = 0
|
call EasyMotion#highlight#turn_on(s:matchparen_hl)
|
||||||
try
|
unlet s:matchparen_hl
|
||||||
redir => error
|
|
||||||
silent highlight Error
|
|
||||||
redir END
|
|
||||||
finally
|
|
||||||
let &verbose = save_verbose
|
|
||||||
endtry
|
|
||||||
" NOTE: do not match across newlines, to remove 'links to Foo'
|
|
||||||
" (https://github.com/Lokaltog/vim-easymotion/issues/95)
|
|
||||||
let hl = substitute(matchstr(error, 'xxx \zs[^\n]*'), '[ \t\n]\+\|cleared', ' ', 'g')
|
|
||||||
if !empty(substitute(hl, '\s', '', 'g'))
|
|
||||||
let s:old_hl_error = hl
|
|
||||||
endif
|
|
||||||
highlight Error NONE
|
|
||||||
return s:old_hl_error
|
|
||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
" -- Draw --------------------------------
|
" -- Draw --------------------------------
|
||||||
|
@ -193,7 +193,50 @@ function! EasyMotion#highlight#add_color_group(new_groups) "{{{
|
|||||||
endfor
|
endfor
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
|
function! EasyMotion#highlight#capture(hlname) "{{{
|
||||||
|
" Based On: https://github.com/t9md/vim-ezbar
|
||||||
|
" https://github.com/osyo-manga/vital-over
|
||||||
|
let hlname = a:hlname
|
||||||
|
if !hlexists(hlname)
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
while 1
|
||||||
|
let save_verbose = &verbose
|
||||||
|
let &verbose = 0
|
||||||
|
try
|
||||||
|
redir => HL_SAVE
|
||||||
|
execute 'silent! highlight ' . hlname
|
||||||
|
redir END
|
||||||
|
finally
|
||||||
|
let &verbose = save_verbose
|
||||||
|
endtry
|
||||||
|
if !empty(matchstr(HL_SAVE, 'xxx cleared$'))
|
||||||
|
return ''
|
||||||
|
endif
|
||||||
|
" follow highlight link
|
||||||
|
let ml = matchlist(HL_SAVE, 'links to \zs.*')
|
||||||
|
if !empty(ml)
|
||||||
|
let hlname = ml[0]
|
||||||
|
continue
|
||||||
|
endif
|
||||||
|
break
|
||||||
|
endwhile
|
||||||
|
let HL_SAVE = substitute(matchstr(HL_SAVE, 'xxx \zs.*'),
|
||||||
|
\ '[ \t\n]\+', ' ', 'g')
|
||||||
|
return [hlname, HL_SAVE]
|
||||||
|
endfunction "}}}
|
||||||
|
function! EasyMotion#highlight#turn_off(hl) "{{{
|
||||||
|
if type(a:hl) != type([])
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
execute 'highlight ' . a:hl[0] . ' NONE'
|
||||||
|
endfunction "}}}
|
||||||
|
function! EasyMotion#highlight#turn_on(hl) "{{{
|
||||||
|
if type(a:hl) != type([])
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
execute 'highlight ' . a:hl[0] . ' ' . a:hl[1]
|
||||||
|
endfunction "}}}
|
||||||
|
|
||||||
" Restore 'cpoptions' {{{
|
" Restore 'cpoptions' {{{
|
||||||
let &cpo = s:save_cpo
|
let &cpo = s:save_cpo
|
||||||
|
Loading…
x
Reference in New Issue
Block a user