Skip to content

Commit

Permalink
fix justinmk#101: 'Cursor' highlight missing ctermbg
Browse files Browse the repository at this point in the history
  • Loading branch information
justinmk committed Apr 11, 2014
1 parent 07cfbd6 commit d45cebd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
9 changes: 4 additions & 5 deletions autoload/sneak/hl.vim
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,18 @@ func! sneak#hl#removehl() "remove highlighting
endf

" gets the 'links to' value of the specified highlight group, if any.
" https://github.com/osyo-manga/vim-over/blob/d8819448fc4074342abd5cb6cb2f0fff47b7aa22/autoload/over/command_line.vim#L225
func! sneak#hl#links_to(hlgroup)
redir => hl | exec 'silent highlight '.a:hlgroup | redir END
let s = substitute(matchstr(hl, 'links to \zs.*'), '\s', '', 'g')
return empty(s) ? 'NONE' : s
endf

func! sneak#hl#is_valid(hlgroup) "avoid junk like 'Cursor xxx cleared'
func! sneak#hl#get(hlgroup) "gets the definition of the specified highlight
if !hlexists(a:hlgroup)
return 0
return ""
endif
redir => hl | exec 'silent highlight '.a:hlgroup | redir END
return !empty(matchstr(hl, '\%(.*xxx\)\?\%(.*cleared\)\?\s*\zs.*'))
return matchstr(hl, '\%(.*xxx\)\?\%(.*cleared\)\?\s*\zs.*')
endf

if 0 == hlID("SneakPluginTarget")
Expand All @@ -44,7 +43,7 @@ if 0 == hlID("SneakStreakStatusLine")
highlight link SneakStreakStatusLine SneakStreakTarget
endif

if sneak#hl#is_valid('Cursor')
if has('gui_running') || -1 != match(sneak#hl#get('Cursor'), 'ctermbg')
highlight link SneakStreakCursor Cursor
else
highlight link SneakStreakCursor SneakPluginScope
Expand Down
8 changes: 6 additions & 2 deletions tests/test.vader
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,12 @@ Execute (hl#links_to() returns NONE if not linked):
hi! link Conceal NONE
Assert "NONE" ==# sneak#hl#links_to('Conceal')

Execute (hl#is_valid() handles non-existent hl group):
Assert 0 == sneak#hl#is_valid('Derp')
Execute (hl#get() handles non-existent hl group):
Assert '' == sneak#hl#get('Derp')

Execute (hl#get() returns text definition of highlight group):
hi Cursor guifg=white guibg=#0a9dff ctermfg=16 ctermbg=253
Assert match(sneak#hl#get('Cursor'), '\Vctermbg=253')

Execute (streak#sanitize_target_labels()):
call sneak#streak#init()
Expand Down

0 comments on commit d45cebd

Please sign in to comment.