Ejemplo n.º 1
0
    def get_cmd_info(self, action):
        """Get command information of this completor action.

        :param action: request action (bytes)
        :rtype: vim.Dictionary (cmd, ftype, is_daemon, is_sync)
        """
        if action == b'complete':
            return vim.Dictionary(cmd=self.format_cmd(),
                                  ftype=self.filetype,
                                  is_daemon=self.daemon,
                                  is_sync=self.sync)
        return vim.Dictionary()
Ejemplo n.º 2
0
def complete():
    '''Finds available completions using Jedi and stores them in a vim
    variable - s:completions.'''
    script = createScript()

    completions = []
    for compl in script.completions():
        docstring = compl.docstring()

        # Check if we can grab a call signature
        signature = ' ' + compl.name
        if '(' in docstring:
            # Split until the first closing bracket
            signature = ' ' + docstring.split(')')[0].replace('\n', ' ') + ')'

        # Create a vim.Dictionary and add it to the list
        # We need a dictionary, so the popup menu can have more than just
        # the text being completet - the type, the signaturem etc.
        completions.append(
            vim.Dictionary({
                'word': compl.complete,
                'abbr': compl.name,
                'info': docstring,
                'kind': compl.type + signature
            }))

    return completions
Ejemplo n.º 3
0
 def get_cmd_info(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,
     )
Ejemplo n.º 4
0
 def get_cmd_info(self, _action):
     return vim.Dictionary(
         cmd='mix run --no-compile',
         ftype=self.filetype,
         is_daemon=self.daemon,
         is_sync=self.sync,
         options={
             'err_io': 'null',
             'cwd': sense_wrapper_dir,
             'env': {
                 'MIX_ENV': 'prod'
             }
         },
     )
Ejemplo n.º 5
0
def get_checkers(args):
    loaded = load_checkers(args['ft'])
    checkers = []
    for c in loaded.values():
        if args['instant'] and not c.instant:
            continue
        checkers.append(
            vim.Dictionary(
                checker=c.checker,
                cwd=c.cwd or '',
                cmd=c.format_cmd(to_unicode(args['tmp'])),
                stdin=c.stdin,
            ))
    return vim.List(checkers)
Ejemplo n.º 6
0
def load_cache():
    type_index_file = vim.eval("a:type_index_file")

    cache = []
    with open(type_index_file) as f:
        for t in f.readlines():
            t = t.strip()
            if len(t) == 0:
                continue
            components = t.split('\t')
            name, page = components[0], components[1]
            entry = vim.Dictionary(
                word=name,
                kind='common',
                source='unitydoc',
                action__page=page,
            )
            cache.append(entry)

    p = vim.Function('unite#sources#unitydoc#set_cache', args=[cache])
    p()
Ejemplo n.º 7
0
def setup_buffer_log(filepath, limit, showdiff):
    """
    setup_buffer_log(string, int, int) -> None
    """
    r = _get_repo(filepath, vim.current.buffer)
    qf_items = r.get_log_text(filepath, limit=limit, include_diff=showdiff)
    items = []

    old_lazyredraw = vim.options['lazyredraw']
    for commit in qf_items:
        # TODO:
        # * Add svndiff format that's based on diff, but lets you navigate
        #   revisions? fugitive has 'git' filetype.
        # * Make navigating the quickfix use the same window like fugitive. Not
        #   sure how? It uses bufhidden=delete instead of hide.
        # * Load diff on buffer load instead of buffer creation (to speed up processing).
        commit['bufnr'] = _create_scratch_buffer(commit['filecontents'].split('\n'), 'diff', filepath, should_stay_open=False)

    vim.options['lazyredraw'] = old_lazyredraw

    qf_what = { 'items': qf_items }
    qf_what['title'] = ':Slog '+ filepath

    # log == [{
    # 'filecontents': '\nr9\nauthor dbriscoe Sun, 09 Feb 2020 06:32:54 +0000\n\nfrom vim\n\n\ndiff --git a/hello b/hello\n--- a/hello\t(revision 8)\n+++ b/hello\t(revision 9)\n@@ -1,3 +1,4 @@\n hello\n hi there\n hi again\n+and more content\n\n',
    # 'col': 0,
    # 'lnum': 0,
    # 'module': 9,
    # 'nr': 0,
    # 'pattern': '',
    # 'text': 'from vim\n',
    # 'type': '',
    # 'valid': 1,
    # 'vcol': 0
    # },

    vim.vars['sovereign_qf_scratch'] = vim.Dictionary(qf_what)
    vim.eval('setqflist([], " ", g:sovereign_qf_scratch)')
    vim.command('unlet g:sovereign_qf_scratch')
    vim.command('copen')
Ejemplo n.º 8
0
 def get_cmd_info(self, action):
     binary = self.get_option('racer_binary') or 'racer'
     return vim.Dictionary(cmd=[binary, 'daemon'],
                           is_daemon=True,
                           ftype=self.filetype,
                           is_sync=False)
Ejemplo n.º 9
0
def load(args):
    c = _load(args['ft'], args['inputted'])
    ctx.current_completer = c
    return c.get_cmd_info(args['action']) if c else vim.Dictionary()
Ejemplo n.º 10
0
def get_completer(args):
    c = load_completer(args['ft'], args['inputted'])
    ctx.current_completer = c
    return c.get_cmd_info(b'complete') if c else vim.Dictionary()