Skip to content

Commit

Permalink
Merge pull request #4164 from ycm-core/fix-custom-props-semantic-high…
Browse files Browse the repository at this point in the history
…lighting

Fix custom text properties for semantic highlighting
  • Loading branch information
mergify[bot] authored Jul 19, 2023
2 parents 142a559 + 1ca1512 commit f09c2f6
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions python/ycm/semantic_highlighting.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
from ycm import text_properties as tp
from ycm import scrolling_range as sr

import vim


HIGHLIGHT_GROUP = {
'namespace': 'Type',
Expand Down Expand Up @@ -107,16 +109,21 @@ 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' ] }"

rng = token[ 'range' ]
self.GrowRangeIfNeeded( rng )
tp.AddTextProperty( self._bufnr, self._prop_id, prop_type, rng )

try:
tp.AddTextProperty( self._bufnr, self._prop_id, prop_type, rng )
except vim.error as e:
if 'E971:' in str( e ): # Text property doesn't exist
if token[ 'type' ] not in REPORTED_MISSING_TYPES:
REPORTED_MISSING_TYPES.add( token[ 'type' ] )
vimsupport.PostVimMessage(
f"Token type { token[ 'type' ] } not supported. "
f"Define property type { prop_type }. "
f"See :help youcompleteme-customising-highlight-groups" )
else:
raise e

tp.ClearTextProperties( self._bufnr, prop_id = prev_prop_id )

0 comments on commit f09c2f6

Please sign in to comment.