Skip to content

Commit

Permalink
Python3 compat, Fixes maralla/completor.vim#250
Browse files Browse the repository at this point in the history
  • Loading branch information
hoyomal committed May 11, 2019
1 parent 380d699 commit 7f20e45
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions pythonx/completor_vim.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-

import logging, re, itertools
import logging
import re
import itertools
from completor import Completor, vim, get_encoding
from completor.compat import to_bytes, to_unicode
from completers.common.utils import test_subseq, LIMIT
Expand All @@ -9,6 +11,7 @@

logger = logging.getLogger('completor')


class Necovim(Completor):
filetype = 'vim'
sync = True
Expand All @@ -22,7 +25,7 @@ def gen_entry(self, base):

candidates = gather_candidates(binput_data, bbase)
for entry in candidates:
score = test_subseq(base, to_unicode(entry['word'], 'utf-8'))
score = test_subseq(base, to_unicode(entry[b'word'], 'utf-8'))
if score is None:
continue
yield entry, score
Expand All @@ -45,7 +48,8 @@ def parse(self, base):

kw = match.group()

items = list(itertools.islice(itertools.chain(self.gen_entry(kw)), LIMIT))
items = list(itertools.islice(
itertools.chain(self.gen_entry(kw)), LIMIT))
items.sort(key=lambda x: x[1])

index = match.start()
Expand All @@ -55,12 +59,12 @@ def parse(self, base):
prefix = 0

ret = []
for item in items:
for item, _ in items:
ret.append({
'word':item[0]['word'][prefix:],
'abbr':item[0]['word'],
'dub':1,
'menu':'[vim]'
'word': item[b'word'][prefix:],
'abbr': item[b'word'],
'dub': 1,
'menu': '[vim]'
})

return ret

0 comments on commit 7f20e45

Please sign in to comment.