Esempio n. 1
0
def goto_definition():
    source = get_content()
    pos = vim.current.window.cursor
    dpos, fname = env.get().location(source, pos, vim.current.buffer.name)

    if dpos:
        mark()
        if fname and fname != vim.current.buffer.name:
            vim.command(':edit {}'.format(vfunc.fnameescape(fname)))
            vim.current.window.cursor = dpos
        else:
            vim.current.window.cursor = dpos
    else:
        print 'Location not found'
Esempio n. 2
0
def goto_definition():
    source = get_content()
    pos = vim.current.window.cursor
    locs = env.get().location(source, pos, vim.current.buffer.name)

    if locs:
        mark()
        last = locs[-1]
        if isinstance(last, dict):
            head = locs[:-1]
            tail = [last]
        else:
            tail = last
            last = tail[0]
            head = locs[:-1]

        locs = head + tail
        if len(locs) > 1:
            llist = [{
                'bufnr': '',
                'filename': loc['file'],
                'pattern': '',
                'valid': 1,
                'nr': -1,
                'lnum': loc['loc'][0],
                'vcol': 0,
                'col': loc['loc'][1] + 1,
            } for loc in locs]
            vfunc.setloclist(0, llist, ' ')
            vim.command(':ll {}'.format(len(head) + 1))
            redraw()
            if len(tail) > 1:
                print 'Multiple locations'
            else:
                print 'Chained locations'
        else:
            fname = last['file']
            dpos = last['loc']
            if fname and fname != vim.current.buffer.name:
                vim.command(':edit {}'.format(vfunc.fnameescape(fname)))
                vim.current.window.cursor = dpos
            else:
                vim.current.window.cursor = dpos
    else:
        redraw()
        print 'Location not found'
Esempio n. 3
0
def goto_definition():
    source = get_content()
    pos = vim.current.window.cursor
    locs = env.get().location(source, pos, vim.current.buffer.name)

    if locs:
        mark()
        last = locs[-1]
        if isinstance(last, dict):
            head = locs[:-1]
            tail = [last]
        else:
            tail = last
            last = tail[0]
            head = locs[:-1]

        locs = head + tail
        if len(locs) > 1:
            llist = [{
                'bufnr': '',
                'filename': loc['file'],
                'pattern': '',
                'valid': 1,
                'nr': -1,
                'lnum': loc['loc'][0],
                'vcol': 0,
                'col': loc['loc'][1] + 1,
            } for loc in locs]
            vfunc.setloclist(0, llist, ' ')
            vim.command(':ll {}'.format(len(head) + 1))
            redraw()
            if len(tail) > 1:
                print 'Multiple locations'
            else:
                print 'Chained locations'
        else:
            fname = last['file']
            dpos = last['loc']
            if fname and fname != vim.current.buffer.name:
                vim.command(':edit {}'.format(vfunc.fnameescape(fname)))
                vim.current.window.cursor = dpos
            else:
                vim.current.window.cursor = dpos
    else:
        redraw()
        print 'Location not found'
Esempio n. 4
0
def omnifunc(findstart, base):
    global last_result
    if findstart in (0, b'0'):
        return [r for r in last_result[1] if r.startswith(base)]
    else:
        source = get_content()
        pos = vim.current.window.cursor
        try:
            m, _ = last_result = env.get().assist(source, pos,
                                                  vim.current.buffer.name)
        except Exception as e:
            print >>sys.stderr, e.message
            m = None

        if m is None:
            return -3
        else:
            return pos[1] - len(m)
Esempio n. 5
0
def omnifunc(findstart, base):
    global last_result
    if findstart in (0, b'0'):
        return [r for r in last_result[1] if r.startswith(base)]
    else:
        source = get_content()
        pos = vim.current.window.cursor
        try:
            m, _ = last_result = env.get().assist(source, pos,
                                                  vim.current.buffer.name)
        except Exception as e:
            print >> sys.stderr, e.message
            m = None

        if m is None:
            return -3
        else:
            return pos[1] - len(m)
Esempio n. 6
0
def show_outline():
    outline.show(get_outline(get_content(), vfunc.shiftwidth()))
Esempio n. 7
0
def lint(append=False):
    source = get_content()
    errors, warns = _lint(source, vim.current.buffer.name)
    show_lint_result(errors, warns, append)
Esempio n. 8
0
def show_outline():
    outline.show(get_outline(get_content(), vfunc.shiftwidth()))
Esempio n. 9
0
def lint(append=False):
    source = get_content()
    errors, warns = _lint(source, vim.current.buffer.name)
    show_lint_result(errors, warns, append)