Пример #1
0
    def on_complete(self, data):
        logger.info("complete %r", data)
        if not data:
            return []
        res = []
        candidates = data[0] or []
        items = []
        if isinstance(candidates, list):
            items = candidates
        elif 'items' in candidates:
            items = candidates['items']

        completions = []

        for item in items:
            label = item['label'].strip()
            word, offset = get_completion_word(item,
                                               self.ft_args.get(b'insertText'))
            completions.append((label, word, offset, item.get('detail')))

        completions = filter_items(completions, self.input_data)

        for label, word, offset, detail in completions:
            d = vim.Dictionary(abbr=label, word=word, category='lsp')
            if detail:
                d['menu'] = detail
            if offset != -1:
                d['offset'] = offset
            res.append(d)

        return vim.List(res)
Пример #2
0
 def on_complete(self, data):
     logger.info("complete %r", data)
     if not data:
         return []
     res = []
     candidates = data[0]
     items = []
     if isinstance(candidates, list):
         items = candidates
     elif 'items' in candidates:
         items = candidates['items']
     for item in items:
         label = item['label'].strip()
         word = get_completion_word(item)
         d = vim.Dictionary(abbr=label, word=word)
         if 'detail' in item:
             d['menu'] = item['detail']
         res.append(d)
     return vim.List(res)