Esempio n. 1
0
nvim_prog = os.environ.get('NVIM_PROG', 'build/bin/nvim')
nvim_argv = [nvim_prog, '-u', 'NONE', '--embed']

if 'VALGRIND' in os.environ:
    log_file = os.environ.get('VALGRIND_LOG', 'valgrind-%p.log')
    valgrind_argv = [
        'valgrind', '-q', '--tool=memcheck', '--leak-check=yes',
        '--track-origins=yes', '--suppressions=.valgrind.supp',
        '--log-file={0}'.format(log_file)
    ]
    if 'VALGRIND_GDB' in os.environ:
        valgrind_argv += ['--vgdb=yes', '--vgdb-error=0']
    nvim_argv = valgrind_argv + nvim_argv

session = spawn_session(nvim_argv)
nvim = Nvim.from_session(session)


def nvim_command(cmd):
    nvim.command(cmd)


def nvim_eval(expr):
    return to_table(nvim.eval(expr))


def nvim_feed(input, mode=''):
    nvim.feedkeys(input)


def buffer_slice(start=None, stop=None, buffer_idx=None):
Esempio n. 2
0
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
import os
import argparse
from neovim import socket_session, Nvim

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="NeoVim TeX client")
    parser.add_argument('--addr', default='/tmp/nvim_tex.sock',
                        help="NeoVim listen address")
    parser.add_argument('file', help="file")
    parser.add_argument('line', type=int, help="line")
    args = parser.parse_args()

    session = socket_session(args.addr)
    nvim = Nvim.from_session(session)

    if not os.path.samefile(nvim.current.buffer.name, args.file):
        nvim.command("e {}".format(os.path.normpath(args.file)))

    nvim.current.window.cursor = (args.line, 0)
    nvim.feedkeys("zz")

# vim: ts=4 sts=4 sw=4 expandtab
Esempio n. 3
0
(2) recompiling Vim against the Python where you already have IPython
installed. This is only a requirement to allow Vim to speak with an IPython
instance using IPython's own machinery. It does *not* mean that the IPython
instance with which you communicate via vim-ipython needs to be running the
same version of Python.
"""

try:
    import IPython
except ImportError:
    raise ImportError("Could not find kernel. " + _install_instructions)

try:
    from neovim import Nvim
    from neovim.msgpack_rpc import stdio_session
    vim = Nvim.from_session(stdio_session())
except ImportError:
    raise ImportError('vim module only available within vim!')

# ------------------------------------------------------------------------------
#        Read global configuration variables
# ------------------------------------------------------------------------------
is_py3 = sys.version_info[0] >= 3
if is_py3:
    unicode = str

prompt_in = 'In [{line:d}]: '
prompt_out = 'Out[{line:d}]: '

# General message command