Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
 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"
Ejemplo n.º 3
0
 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)
Ejemplo n.º 4
0
    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)
Ejemplo n.º 5
0
 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)
Ejemplo n.º 6
0
 def search(self, symbol):
     symbol = symbol.strip() or vim.eval('expand("<cword>")')
     candidates = self._createTagCandidate(symbol, vim.current.buffer)
     SearchBackend.showSearchResult(candidates)
Ejemplo n.º 7
0
 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)
Ejemplo n.º 8
0
 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)