Exemple #1
0
    def UpdateMatches(self):
        if not self._user_options['enable_diagnostic_highlighting']:
            return

        # Vim doesn't provide a way to update the matches for a different window
        # than the current one (which is a view of the current buffer).
        if vimsupport.GetCurrentBufferNumber() != self._bufnr:
            return

        matches_to_remove = vimsupport.GetDiagnosticMatchesInCurrentWindow()

        for diags in self._line_to_diags.values():
            # Insert squiggles in reverse order so that errors overlap warnings.
            for diag in reversed(diags):
                group = ('YcmErrorSection'
                         if _DiagnosticIsError(diag) else 'YcmWarningSection')

                for pattern in _ConvertDiagnosticToMatchPatterns(diag):
                    # The id doesn't matter for matches that we may add.
                    match = vimsupport.DiagnosticMatch(0, group, pattern)
                    try:
                        matches_to_remove.remove(match)
                    except ValueError:
                        vimsupport.AddDiagnosticMatch(match)

        for match in matches_to_remove:
            vimsupport.RemoveDiagnosticMatch(match)
  def ShowDetailedDiagnostic( self, message_in_popup ):
    detailed_diagnostic = BaseRequest().PostDataToHandler(
        BuildRequestData(), 'detailed_diagnostic' )
    if detailed_diagnostic and 'message' in detailed_diagnostic:
      message = detailed_diagnostic[ 'message' ]
      if message_in_popup and vimsupport.VimSupportsPopupWindows():
        window = vim.current.window
        buffer_number = vimsupport.GetCurrentBufferNumber()
        diags_on_this_line = self._buffers[ buffer_number ].DiagnosticsForLine(
            window.cursor[ 0 ] )

        lines = message.split( '\n' )
        available_columns = vimsupport.GetIntValue( '&columns' )
        col = window.cursor[ 1 ] + 1
        if col > available_columns - 2: # -2 accounts for padding.
          col = 0
        options = {
          'col': col,
          'padding': [ 0, 1, 0, 1 ],
          'maxwidth': available_columns,
          'close': 'click',
          'fixed': 0,
          'highlight': 'ErrorMsg',
          'border': [ 1, 1, 1, 1 ],
          # Close when moving cursor
          'moved': 'expr',
        }
        popup_func = 'popup_atcursor'
        for diag in diags_on_this_line:
          if message == diag[ 'text' ]:
            popup_func = 'popup_create'
            prop = vimsupport.GetTextPropertyForDiag( buffer_number,
                                                      window.cursor[ 0 ],
                                                      diag )
            options.update( {
              'textpropid': prop[ 'id' ],
              'textprop': prop[ 'type' ],
            } )
            options.pop( 'col' )
        vim.eval( f'{ popup_func }( { lines }, { options } )' )
      else:
        vimsupport.PostVimMessage( message, warning = False )
Exemple #3
0
 def CurrentBuffer(self):
     return self._buffers[vimsupport.GetCurrentBufferNumber()]
Exemple #4
0
 def OnFileTypeSet(self):
     buffer_number = vimsupport.GetCurrentBufferNumber()
     filetypes = vimsupport.CurrentFiletypes()
     self._buffers[buffer_number].UpdateFromFileTypes(filetypes)
     self.OnBufferVisit()
 def CurrentBuffer( self ):
   return self.Buffer( vimsupport.GetCurrentBufferNumber() )
 def SetCurrentBuffer(self):
     self._current_buffer = self._buffers[
         vimsupport.GetCurrentBufferNumber()]