def ShowDetailedDiagnostic(self): current_line, current_column = vimsupport.CurrentLineAndColumn() # CurrentLineAndColumn() numbers are 0-based, clang numbers are 1-based current_line += 1 current_column += 1 current_file = vim.current.buffer.name if not self.diagnostic_store: vimsupport.PostVimMessage("No diagnostic for current line!") return diagnostics = self.diagnostic_store[current_file][current_line] if not diagnostics: vimsupport.PostVimMessage("No diagnostic for current line!") return closest_diagnostic = None distance_to_closest_diagnostic = 999 for diagnostic in diagnostics: distance = abs(current_column - diagnostic.column_number_) if distance < distance_to_closest_diagnostic: distance_to_closest_diagnostic = distance closest_diagnostic = diagnostic vimsupport.EchoText(closest_diagnostic.long_formatted_text_)
def PreviousIdentifier(): line_num, column_num = vimsupport.CurrentLineAndColumn() buffer = vim.current.buffer line = buffer[line_num] end_column = column_num while end_column > 0 and not utils.IsIdentifierChar(line[end_column - 1]): end_column -= 1 # Look at the previous line if we reached the end of the current one if end_column == 0: try: line = buffer[line_num - 1] except: return "" end_column = len(line) while end_column > 0 and not utils.IsIdentifierChar( line[end_column - 1]): end_column -= 1 start_column = end_column while start_column > 0 and utils.IsIdentifierChar(line[start_column - 1]): start_column -= 1 if end_column - start_column < MIN_NUM_CHARS: return "" return line[start_column:end_column]
def _GetJediScript(self): contents = '\n'.join(vim.current.buffer) line, column = vimsupport.CurrentLineAndColumn() # Jedi expects lines to start at 1, not 0 line += 1 filename = vim.current.buffer.name return jedi.Script(contents, line, column, filename)
def CandidatesFromStoredRequest(self): if self.completions_cache: return self.completions_cache.filtered_completions else: self.completions_cache = CompletionsCache() self.completions_cache.raw_completions = self.CandidatesFromStoredRequestInner( ) self.completions_cache.line, _ = vimsupport.CurrentLineAndColumn() self.completions_cache.column = self.completion_start_column return self.completions_cache.raw_completions
def ComputeCandidates(self, unused_query, unused_start_column): filename = vim.current.buffer.name line, column = vimsupport.CurrentLineAndColumn() # Jedi expects lines to start at 1, not 0 line += 1 contents = '\n'.join(vim.current.buffer) script = Script(contents, line, column, filename) return [{ 'word': str(completion.word), 'menu': str(completion.description), 'info': str(completion.doc) } for completion in script.complete()]
def BuildRequestData(buffer_number=None): working_dir = GetCurrentDirectory() #TODO current_buffer = vim.current.buffer #TODO: vim # We're going to assume that we only care about the current buffer. current_filepath = vimsupport.GetBufferFilepath(current_buffer) line, column = vimsupport.CurrentLineAndColumn() return { 'filepath': current_filepath, 'line_num': line + 1, 'column_num': column + 1, 'working_dir': working_dir, 'file_data': vimsupport.GetUnsavedAndSpecifiedBufferData( current_buffer, current_filepath ) }
def _LocationForGoTo(self, goto_function): filename = vim.current.buffer.name if not filename: return None flags = self.flags.FlagsForFile(filename) if not flags: vimsupport.PostVimMessage( 'Still no compile flags, can\'t compile.') return None files = self.GetUnsavedFilesVector() line, column = vimsupport.CurrentLineAndColumn() # Making the line & column 1-based instead of 0-based line += 1 column += 1 return getattr(self.completer, goto_function)(filename, line, column, files, flags)
def SetCandidates( self ): while True: try: WaitAndClear( self._query_ready ) filename = vim.current.buffer.name line, column = vimsupport.CurrentLineAndColumn() # Jedi expects lines to start at 1, not 0 line += 1 contents = '\n'.join( vim.current.buffer ) script = Script( contents, line, column, filename ) self._candidates = [ { 'word': str( completion.word ), 'menu': str( completion.description ), 'info': str( completion.doc ) } for completion in script.complete() ] except: self._query_ready.clear() self._candidates = [] self._candidates_ready.set()
def CacheValid(self, start_column): completion_line, _ = vimsupport.CurrentLineAndColumn() completion_column = start_column return completion_line == self.line and completion_column == self.column
def CacheValid(self): completion_line, _ = vimsupport.CurrentLineAndColumn() completion_column = int(vim.eval("s:completion_start_column")) return completion_line == self.line and completion_column == self.column