示例#1
0
def scoreMatches(q, c, limit, ispath):
    if useNative:
        idxArr = fruzzy_mod.scoreMatchesStr(q, c, limit, ispath)
        results = []
        for i in idxArr:
            results.append((c[i[0]], i[1]))
        return results
    else:
        return fruzzy.scoreMatches(q, c, limit, ispath=ispath)
示例#2
0
def scoreMatchesProxy(q, c, limit, key=None, ispath=True):
    def idfn(x):
        return x
    if key is None:
        key = idfn
    if useNative:
        idxArr = scoreMatchesStr(q, idfn(c), limit, ispath)
        results = []
        for i in idxArr:
            results.append((c[i[0]], i[1]))
        return results
    else:
        return scoreMatches(q, c, limit, key, ispath)
示例#3
0
def fruzzy_match():
    """The wrapper for fruzzy matcher"""
    args = vim.eval('input')
    args['limit'] = int(args['limit'])
    args['ispath'] = int(args['ispath'])

    if USE_NATIVE:
        output = scoreMatchesStr(args['query'], args['candidates'],
                                 args['current'], args['limit'],
                                 args['ispath'])
        matches = [args['candidates'][i[0]] for i in output]
    else:
        matches = [c[0] for c in scoreMatches(**args)]

    return matches
示例#4
0
 def scoreMatchesProxy(self, q, c, limit, key=None, ispath=True, buffer=0):
     relname = ""
     if ispath and buffer > 0 and q == "":
         fname = self.vim.buffers[buffer].name
         relname = relpath(self.vim, fname)
     if self.useNative:
         idxArr = self.nativeMethod(q, [key(d) for d in c], relname, limit,
                                    ispath)
         results = []
         for i in idxArr:
             idx, score = i
             results.append((c[idx], score))
         return results
     else:
         return fruzzy.scoreMatches(q, c, relname, limit, key, ispath)
示例#5
0
 def scoreMatchesProxy(self, q, c, limit, key=None, ispath=True, buffer=0):
     relname = ""
     if ispath and buffer > 0 and q == "":
         fname = self.vim.buffers[buffer].name
         d = self.vim.command("pwd")
         relname = path.relpath(fname, start=d)
         self.debug("buffer: %s, '%s'" % (relname, q))
     if self.useNative:
         idxArr = self.nativeMethod(q, [key(d) for d in c],
                                    relname, limit, ispath)
         results = []
         for i in idxArr:
             idx, score = i
             results.append((c[idx], score))
         return results
     else:
         return fruzzy.scoreMatches(q, c, relname, limit, key, ispath)