def get_cmd_info(self, action): if action == b'format': return vim.Dictionary(cmd=self._format(), is_daemon=False, ftype=self.filetype, is_sync=False) binary = self.get_option('racer_binary') or 'racer' return vim.Dictionary(cmd=[binary, 'daemon'], is_daemon=True, ftype=self.filetype, is_sync=False)
def get_cmd_info(self, action): if action == b'complete': args = self._gen_complete_args() elif action == b'definition': args = self._gen_definition_args() else: return vim.Dictionary() return vim.Dictionary(cmd=args, is_daemon=False, ftype=self.filetype, is_sync=False)
def get_cmd_info(self, action): ft = self.ft_orig args = self.ft_args lsp_cmd = args.get(b'cmd') if not lsp_cmd: return vim.Dictionary() if action == b'format' and ft != self.ft: import_completer(ft) c = get(ft, ft, self.input_data) if not c: return '' return c.get_cmd_info(action) return vim.Dictionary(cmd=lsp_cmd.split(), is_daemon=True, ftype=self.filetype + '_' + ft, is_sync=False)
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)
def _jedi_cmd(self, action): binary = self.get_option('python_binary') or 'python' cmd = [binary, os.path.join(DIRNAME, 'python_jedi.py')] return vim.Dictionary( cmd=cmd, ftype=self.filetype, is_daemon=True, is_sync=False, )
def _yapf_cmd(self): if vim.current.buffer.options['modified']: echo('Save file to format.', severity='warn') return vim.Dictionary() binary = self.get_option('yapf_binary') or 'yapf' line_range = self.meta.get('range') if not line_range: return vim.Dictionary() cmd = [binary, '--in-place'] start, end = line_range if start != end: cmd.extend(['--lines', '{}-{}'.format(start, end)]) cmd.append(self.filename) return vim.Dictionary( cmd=cmd, ftype=self.filetype, is_daemon=False, is_sync=False, )
def get_cmd_info(self, action): if action == b'complete': cmd, input_content = self._complete_cmd() elif action == b'doc': cmd, input_content = self._doc_cmd() elif action == b'definition': cmd, input_content = self._def_cmd() else: cmd, input_content = [], '' return vim.Dictionary( cmd=cmd, ftype=self.filetype, is_daemon=False, is_sync=False, input_content=input_content, )
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)