function! GetLinkTarget(group)
let l:groupID = hlID(a:group)
" Get the group this highlight group links to
let l:linkedGroupID = synIDtrans(l:groupID)
let l:linkedGroupName = synIDattr(l:linkedGroupID, 'name')
echom a:group . " → " . l:linkedGroupName
endfunction
Example usage:
:call GetLinkTarget("vim9Comment")
Output:
vim9Comment → Comment