def UpdateMatches( self ): if not self._user_options[ 'enable_diagnostic_highlighting' ]: return props_to_remove = vimsupport.GetTextProperties( self._bufnr ) for diags in self._line_to_diags.values(): # Insert squiggles in reverse order so that errors overlap warnings. for diag in reversed( diags ): for line, column, name, extras in _ConvertDiagnosticToTextProperties( self._bufnr, diag ): global YCM_VIM_PROPERTY_ID diag_prop = vimsupport.DiagnosticProperty( YCM_VIM_PROPERTY_ID, name, line, column, extras[ 'end_col' ] - column if 'end_col' in extras else column ) try: props_to_remove.remove( diag_prop ) except ValueError: vimsupport.AddTextProperty( self._bufnr, line, column, name, extras, YCM_VIM_PROPERTY_ID ) YCM_VIM_PROPERTY_ID += 1 for prop in props_to_remove: vimsupport.RemoveTextProperty( self._bufnr, prop )
def UpdateMatches(self): if not self._user_options['enable_diagnostic_highlighting']: return props_to_remove = vimsupport.GetTextProperties(self._bufnr) for diags in self._line_to_diags.values(): # Insert squiggles in reverse order so that errors overlap warnings. for diag in reversed(diags): for line, column, name, extras in _ConvertDiagnosticToTextProperties( self._bufnr, diag): global YCM_VIM_PROPERTY_ID # FIXME: This remove() gambit probably never works because the IDs are # almost certain to not match # Perhaps we should have AddTextProperty return the ID? diag_prop = vimsupport.DiagnosticProperty( YCM_VIM_PROPERTY_ID, name, line, column, extras['end_col'] - column if 'end_col' in extras else column) try: props_to_remove.remove(diag_prop) except ValueError: vimsupport.AddTextProperty(self._bufnr, line, column, name, extras, YCM_VIM_PROPERTY_ID) YCM_VIM_PROPERTY_ID += 1 for prop in props_to_remove: vimsupport.RemoveTextProperty(self._bufnr, prop)
def MakeVritualTextProperty(prop_type, text, position='after'): vimsupport.AddTextProperty(self._bufnr, line_num, 0, prop_type, { 'text': text, 'text_align': position, 'text_wrap': 'wrap' })
def UpdateMatches(self): if not self._user_options['enable_diagnostic_highlighting']: return props_to_remove = vimsupport.GetTextProperties(self._bufnr) for diags in self._line_to_diags.values(): # Insert squiggles in reverse order so that errors overlap warnings. for diag in reversed(diags): for line, column, name, extras in _ConvertDiagnosticToTextProperties( self._bufnr, diag): global YCM_VIM_PROPERTY_ID # Note the following .remove() works because the __eq__ on # DiagnosticProperty does not actually check the IDs match... diag_prop = vimsupport.DiagnosticProperty( YCM_VIM_PROPERTY_ID, name, line, column, extras['end_col'] - column if 'end_col' in extras else column) try: props_to_remove.remove(diag_prop) except ValueError: extras.update({'id': YCM_VIM_PROPERTY_ID}) vimsupport.AddTextProperty(self._bufnr, line, column, name, extras) YCM_VIM_PROPERTY_ID += 1 for prop in props_to_remove: vimsupport.RemoveDiagnosticProperty(self._bufnr, prop)
def Update(self): if not self.IsResponseReady(): # Not ready - poll return False if self.tick != vimsupport.GetBufferChangedTick(self._bufnr): # Buffer has changed, we should ignore the data and retry # self.SendRequest() return False # We requested a snapshot response = self._request.Response() self._request = None tokens = response.get('tokens', []) prev_prop_id = self._prop_id self._prop_id = NextPropID() for token in tokens: if token['type'] not in HIGHLIGHT_GROUP: continue prop_type = f"YCM_HL_{ token[ 'type' ] }" vimsupport.AddTextProperty(self._bufnr, self._prop_id, prop_type, token['range']) vimsupport.ClearTextProperties(self._bufnr, prev_prop_id) # No need to re-poll return False