From 4d75c9940c3b4bc0d144bb199839eee2bad084ac Mon Sep 17 00:00:00 2001 From: Christian Date: Wed, 18 Nov 2020 08:44:27 +0100 Subject: [PATCH] highlighter: vim9 script implementation of s:get_syn --- autoload/airline/highlighter.vim | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/autoload/airline/highlighter.vim b/autoload/airline/highlighter.vim index 833ba534..5edd950d 100644 --- a/autoload/airline/highlighter.vim +++ b/autoload/airline/highlighter.vim @@ -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