Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python3 compat, Fixes maralla/completor.vim#250 #1

Merged
merged 1 commit into from
May 17, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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