highlighter: vim9 script implementation of s:get_syn

This commit is contained in:
Christian 2020-11-18 08:44:27 +01:00 committed by Christian Brabandt
parent ae3af85ca2
commit 4d75c9940c
No known key found for this signature in database
GPG Key ID: F3F92DA383FDDE09

View File

@ -332,4 +332,19 @@ else
return false
endif
enddef
def s:get_syn(group: string, what: string, mode: string): string # {{{2
var color = ''
if hlexists(group)
color = hlID(group)->synIDtrans()->synIDattr(what, mode)
endif
if empty(color) || str2nr(color) == -1
# Normal highlighting group should always exist
color = hlID('Normal')->synIDtrans()->synIDattr(what, mode)
# however, just in case
if empty(color) || str2nr(color) == -1
color = 'NONE'
endif
endif
return color
enddef
endif