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'
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'
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)
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)
def show_outline(): outline.show(get_outline(get_content(), vfunc.shiftwidth()))
def lint(append=False): source = get_content() errors, warns = _lint(source, vim.current.buffer.name) show_lint_result(errors, warns, append)