def ConvertCompletionData(completion_data): return responses.BuildCompletionData( insertion_text=completion_data.TextToInsertInBuffer(), menu_text=completion_data.MainCompletionText(), extra_menu_info=completion_data.ExtraMenuInfo(), kind=completion_data.kind_, detailed_info=completion_data.DetailedInfoForPreviewWindow())
def ComputeCandidatesInner( self, request_data ): script = self._GetJediScript( request_data ) return [ responses.BuildCompletionData( str( completion.name ), str( completion.description ), str( completion.doc ) ) for completion in script.completions() ]
def ComputeCandidatesInner(self, request_data): return [ responses.BuildCompletionData(completion['CompletionText'], completion['DisplayText'], completion['Description']) for completion in self._GetCompletions(request_data) ]
def _FindLabels(self): """ Find LaTeX labels for \ref{} completion. This time we scan through all .tex files in the current directory and extract the content of all \label{} commands as sources for completion. """ texs = " ".join(glob.glob("*.tex")) cat_process = subprocess.Popen(shlex.split("cat %s" % texs), stdout=subprocess.PIPE) grep_process = subprocess.Popen(shlex.split(r"grep \\\\label"), stdin=cat_process.stdout, stdout=subprocess.PIPE) cat_process.stdout.close() lines = grep_process.communicate()[0] ret = [] for label in lines.split("\n"): ret.append( responses.BuildCompletionData( re.sub(r".*\label{(.*)}.*", r"\1", label))) return ret
def OnBufferVisit(self, request_data): raw_candidates = request_data.get('ultisnips_snippets', []) self._candidates = [ responses.BuildCompletionData( str(snip['trigger']), str('<snip> ' + snip['description'].encode('utf-8'))) for snip in raw_candidates ]
def ComputeCandidates( self, request_data ): if not self.ShouldUseNow( request_data ): return [] completions = self._completer.CandidatesForQueryAndType( ToUtf8IfNeeded( utils.SanitizeQuery( request_data[ 'query' ] ) ), ToUtf8IfNeeded( request_data[ 'filetypes' ][ 0 ] ) ) completions = completions[ : MAX_IDENTIFIER_COMPLETIONS_RETURNED ] completions = _RemoveSmallCandidates( completions, self.user_options[ 'min_num_identifier_candidate_chars' ] ) return [ responses.BuildCompletionData( x ) for x in completions ]
def _GenerateCandidatesForPaths(absolute_paths): seen_basenames = set() completion_dicts = [] for absolute_path in absolute_paths: basename = os.path.basename(absolute_path) if basename in seen_basenames: continue seen_basenames.add(basename) is_dir = os.path.isdir(absolute_path) completion_dicts.append( responses.BuildCompletionData(basename, '[Dir]' if is_dir else '[File]')) return completion_dicts
def _FindBibEntries(self): """ Find BIBtex entries. I'm currently assuming, that Bib entries have the format ^@<articletype> {<ID>, <bibtex properties> [..] } Hence, to find IDs for completion, I scan for lines starting with an @ character and extract the ID from there. The search is done by a shell pipe: cat *.bib | grep ^@ | grep -v @string """ # bibs = " ".join(glob.glob("*.bib")) # cat_process = subprocess.Popen(shlex.split("cat %s" % bibs), # stdout=subprocess.PIPE) # grep_process = subprocess.Popen(shlex.split("grep ^@"), # stdin=cat_process.stdout, # stdout=subprocess.PIPE) # cat_process.stdout.close() # grep2_process = subprocess.Popen(shlex.split("grep -vi @string"), # stdin=grep_process.stdout, # stdout=subprocess.PIPE) # grep_process.stdout.close() # # lines = grep2_process.communicate()[0] # ret = [] # for l in lines.split("\n"): # ret.append(responses.BuildCompletionData( # re.sub(r"@(.*){([^,]*).*", r"\2", l) # ) # ) regex = re.compile(r"@([A-Za-z]*)\s*{\s*([^,]*),.*") for bibfile in self._FindBibFiles('/dev/null'): for key in self._FindBibEntries(bibfile): ret.append(responses.BuildCompletionData(key)) return ret