From d45cebd1da6f179b76fe5b3676d7ab4261a68f3c Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Fri, 11 Apr 2014 10:32:18 -0400 Subject: [PATCH] fix #101: 'Cursor' highlight missing ctermbg --- autoload/sneak/hl.vim | 9 ++++----- tests/test.vader | 8 ++++++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/autoload/sneak/hl.vim b/autoload/sneak/hl.vim index fec1775..c4882d7 100644 --- a/autoload/sneak/hl.vim +++ b/autoload/sneak/hl.vim @@ -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") @@ -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 diff --git a/tests/test.vader b/tests/test.vader index 4360630..c0f6500 100644 --- a/tests/test.vader +++ b/tests/test.vader @@ -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()