def switchHeadAndImpl(self): ''' switch between [.h|.hpp] with [.cpp|.m|.c|.cc] ''' try: filename = os.path.basename(vim.current.buffer.name) except: return s = [] extentions = [".cpp", ".c", ".cc", ".m"] if re.search("\.(h|hpp)$", filename): for ext in extentions: s.append(re.sub("\.(h|hpp)$", ext, filename)) elif re.search("\.(c|cpp|cc|m)$", filename): s.append(re.sub("\.(c|cpp|cc)$", ".h", filename)) s.append(re.sub("\.(c|cpp|cc)$", ".hpp", filename)) candidates = getattr(self, "cachedCandidates", self.makeIndex()) matchedCandidates = [] for candidate in candidates: for pattern in s: if CommonUtil.fileMatch(pattern + "$", candidate.path): matchedCandidates.append(candidate) break if len(matchedCandidates) == 1: matchedCandidates[0].onAction("close") else: SearchBackend.showSearchResult(matchedCandidates)
def showEditHistory(self): editHistory = StoreManager.load(self.editHistoryKey) editHistory.reverse() if editHistory: candidates = [FileCandidate(str(path)) for path in editHistory] SearchBackend.showSearchResult(candidates) else: print "empty history"
def search(self, symbol): symbol = symbol.strip() or vim.eval('expand("<cword>")') prefix = "-n" if hasattr(self, "searchDir"): prefix = "-n -f %s" %(self.searchDir) cmdArg = "%s %s" % (prefix, symbol) output = self.makeSearch(cmdArg) candidates = self._createTagCandidate(output) SearchBackend.showSearchResult(candidates)
def search(self, symbol): candidates = getattr(self, "cachedCandidates", self.makeIndex()) matchedCandidates = [] for candidate in candidates: if CommonUtil.fileMatch(symbol, candidate.path): matchedCandidates.append(candidate) if len(matchedCandidates) == 1: matchedCandidates[0].onAction("close") else: SearchBackend.showSearchResult(matchedCandidates)
def searchAll(self, symbol): buffers =[buffer for buffer in vim.buffers if buffer.name and os.path.exists(buffer.name)] candidates = [] for buffer in buffers: candidates.extend(self._createTagCandidate(symbol, buffer)) SearchBackend.showSearchResult(candidates)
def search(self, symbol): symbol = symbol.strip() or vim.eval('expand("<cword>")') candidates = self._createTagCandidate(symbol, vim.current.buffer) SearchBackend.showSearchResult(candidates)
def searchBuffer(self, symbol): candidates = [FileCandidate(buffer.name) for buffer in vim.buffers if buffer.name and symbol in buffer.name] if len(candidates) == 1: candidates[0].onAction("close") SearchBackend.showSearchResult(candidates)
def showFilterCdHistory(self, symbol): history = StoreManager.load(self.storeKey) candidates = [LocateCdCandidate(str(path)) for path in history if symbol in path] SearchBackend.showSearchResult(candidates, filterCheck=locatefilterCheck)