We can write a function that parses the output of :highlight
command for "links to" string and follows the link recursively.
function! HiThere(group) abort
let out = trim(execute('hi ' .. a:group))
let splits = split(out, ' \+')
echon splits[0] .. ' '
execute 'echohl ' .. splits[0]
echon splits[1] .. ' '
echohl None
echon join(splits[2:])
if out =~ 'links to'
echom ''
call HiThere(split(out, ' \+')[-1])
endif
endfunction
command! -nargs=1 -complete=highlight HiThere call HiThere(<q-args>)
If we don't want the links in the output, i.e., if we only want the colors of the deepest highlight-group, we can bring the echo
block in the else part of the if condition below it. I'll leave that for others unless and until someone expresses the need for it.