From 6fc0ebb0e4ff6ec96d4c1f5c7f90f8775f607a17 Mon Sep 17 00:00:00 2001 From: andrejlevkovitch Date: Mon, 17 Jul 2023 21:27:01 +0200 Subject: [PATCH 1/2] allow using not registered highlighting groups --- python/ycm/semantic_highlighting.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/python/ycm/semantic_highlighting.py b/python/ycm/semantic_highlighting.py index b96c28fbed..cad96b4a33 100644 --- a/python/ycm/semantic_highlighting.py +++ b/python/ycm/semantic_highlighting.py @@ -107,14 +107,19 @@ def _Draw( self ): self._prop_id = NextPropID() for token in tokens: - if token[ 'type' ] not in HIGHLIGHT_GROUP: - if token[ 'type' ] not in REPORTED_MISSING_TYPES: - REPORTED_MISSING_TYPES.add( token[ 'type' ] ) - vimsupport.PostVimMessage( - f"Missing property type for { token[ 'type' ] }" ) - continue prop_type = f"YCM_HL_{ token[ 'type' ] }" + if token[ 'type' ] not in HIGHLIGHT_GROUP: + props = tp.GetTextPropertyTypes() + if prop_type in props: + HIGHLIGHT_GROUP[token['type']] = '' + else: + if token[ 'type' ] not in REPORTED_MISSING_TYPES: + REPORTED_MISSING_TYPES.add( token[ 'type' ] ) + vimsupport.PostVimMessage( + f"Missing property type for { token[ 'type' ] }" ) + continue + rng = token[ 'range' ] self.GrowRangeIfNeeded( rng ) tp.AddTextProperty( self._bufnr, self._prop_id, prop_type, rng ) From f041d0d00a9dd3dd4216c35941e12de8aab80134 Mon Sep 17 00:00:00 2001 From: andrejlevkovitch Date: Tue, 18 Jul 2023 15:34:58 +0200 Subject: [PATCH 2/2] check user defined text property at initialization --- python/ycm/semantic_highlighting.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/python/ycm/semantic_highlighting.py b/python/ycm/semantic_highlighting.py index cad96b4a33..5b468f755e 100644 --- a/python/ycm/semantic_highlighting.py +++ b/python/ycm/semantic_highlighting.py @@ -71,6 +71,14 @@ def Initialise(): highlight = group, priority = 0 ) + # add user defined properties + ycm_prop_suffix = f'YCM_HL_' + for prop in props: + if prop[0:len(ycm_prop_suffix)] == ycm_prop_suffix: + name = prop[len(ycm_prop_suffix):] + if name not in HIGHLIGHT_GROUP.keys(): + HIGHLIGHT_GROUP[name] = '' + # "arbitrary" base id NEXT_TEXT_PROP_ID = 70784 @@ -107,18 +115,13 @@ def _Draw( self ): self._prop_id = NextPropID() for token in tokens: - prop_type = f"YCM_HL_{ token[ 'type' ] }" - if token[ 'type' ] not in HIGHLIGHT_GROUP: - props = tp.GetTextPropertyTypes() - if prop_type in props: - HIGHLIGHT_GROUP[token['type']] = '' - else: - if token[ 'type' ] not in REPORTED_MISSING_TYPES: - REPORTED_MISSING_TYPES.add( token[ 'type' ] ) - vimsupport.PostVimMessage( - f"Missing property type for { token[ 'type' ] }" ) - continue + if token[ 'type' ] not in REPORTED_MISSING_TYPES: + REPORTED_MISSING_TYPES.add( token[ 'type' ] ) + vimsupport.PostVimMessage( + f"Missing property type for { token[ 'type' ] }" ) + continue + prop_type = f"YCM_HL_{ token[ 'type' ] }" rng = token[ 'range' ] self.GrowRangeIfNeeded( rng )