How to use the pynvim.attach function in pynvim

To help you get started, we’ve selected a few pynvim examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github numirias / semshi / test / test_plugin.py View on Github external
def vim():
    argv = ['nvim', '-u', VIMRC, '--embed', '--headless']
    vim = neovim.attach('child', argv=argv)
    return WrappedVim(vim)
github numirias / semshi / test / test_plugin.py View on Github external
def f(argv=None, file=None):
        if argv is None:
            argv = []
        argv = ['nvim', '-u', VIMRC, '--embed', '--headless', *argv]
        vim = neovim.attach('child', argv=argv)
        if file is not None:
            fn = file or (tmp_path / 'foo.py')
            vim.command('edit %s' % fn)
        return WrappedVim(vim)
    return f
github sakhnik / nvim-gdb / test / engine.py View on Github external
def __init__(self):
        """Construct an engine."""
        addr = os.environ.get('NVIM_LISTEN_ADDRESS')
        if addr:
            self.nvim = attach('socket', path=addr)
        else:
            args = ["/usr/bin/env", "nvim", "--embed", "--headless", "-n",
                    "-u", "init.vim"]
            self.nvim = attach('child', argv=args)
            # Dummy request to make sure the embedded Nvim proceeds
            # See in neovim bd8d43c6fef868 (startup: wait for embedder
            # before executing)
            self.eval("0")

        # Trusty builds on Travis seem to be more prone to races.
        self.feed_delay = 0.02 if not os.environ.get('TRAVIS') else 0.1
github sakhnik / nvim-gdb / test / engine.py View on Github external
def __init__(self):
        """Construct an engine."""
        addr = os.environ.get('NVIM_LISTEN_ADDRESS')
        if addr:
            self.nvim = attach('socket', path=addr)
        else:
            args = ["/usr/bin/env", "nvim", "--embed", "--headless", "-n",
                    "-u", "init.vim"]
            self.nvim = attach('child', argv=args)
            # Dummy request to make sure the embedded Nvim proceeds
            # See in neovim bd8d43c6fef868 (startup: wait for embedder
            # before executing)
            self.eval("0")

        # Trusty builds on Travis seem to be more prone to races.
        self.feed_delay = 0.02 if not os.environ.get('TRAVIS') else 0.1
github dsanson / termpdf.py / termpdf.py View on Github external
def init_neovim_bridge(self):
        try:
            from pynvim import attach
        except:
            raise SystemExit('pynvim unavailable')
        try:
            self.nvim = attach('socket', path=self.nvim_listen_address)
        except:
            ncmd = 'env NVIM_LISTEN_ADDRESS={} nvim {}'.format(self.nvim_listen_address, config.NOTE_PATH)
            try:
                os.system('{} {}'.format(config.KITTYCMD,ncmd))
            except:
                raise SystemExit('unable to open new kitty window')

            end = monotonic() + 5 # 5 second time out 
            while monotonic() < end:
                try:
                    self.nvim = attach('socket', path=self.nvim_listen_address)
                    break
                except:
                    # keep trying every tenth of a second
                    sleep(0.1)
github Shougo / denite.nvim / autoload / denite / _main.py View on Github external
def attach_vim(serveraddr):
    if len(serveraddr.split(':')) == 2:
        serveraddr, port = serveraddr.split(':')
        port = int(port)
        vim = attach('tcp', address=serveraddr, port=port)
    else:
        vim = attach('socket', path=serveraddr)

    # sync path
    for path in vim.call(
            'globpath', vim.options['runtimepath'],
            'rplugin/python3', 1).split('\n'):
        sys.path.append(path)
    # Remove current path
    del sys.path[0]

    return vim
github Shougo / deoplete.nvim / rplugin / python3 / deoplete / dp_main.py View on Github external
def attach_vim(serveraddr):
    if len(serveraddr.split(':')) == 2:
        serveraddr, port = serveraddr.split(':')
        port = int(port)
        vim = attach('tcp', address=serveraddr, port=port)
    else:
        vim = attach('socket', path=serveraddr)

    # sync path
    for path in vim.call(
            'globpath', vim.options['runtimepath'],
            'rplugin/python3', 1).split('\n'):
        sys.path.append(path)
    # Remove current path
    del sys.path[0]

    return vim
github Shougo / deoplete.nvim / rplugin / python3 / deoplete / dp_main.py View on Github external
def attach_vim(serveraddr):
    if len(serveraddr.split(':')) == 2:
        serveraddr, port = serveraddr.split(':')
        port = int(port)
        vim = attach('tcp', address=serveraddr, port=port)
    else:
        vim = attach('socket', path=serveraddr)

    # sync path
    for path in vim.call(
            'globpath', vim.options['runtimepath'],
            'rplugin/python3', 1).split('\n'):
        sys.path.append(path)
    # Remove current path
    del sys.path[0]

    return vim
github mhinz / neovim-remote / nvr / nvr.py View on Github external
def attach(self):
        try:
            socktype, address, port = parse_address(self.address)
            if socktype == 'tcp':
                self.server = pynvim.attach('tcp', address=address, port=int(port))
            else:
                self.server = pynvim.attach('socket', path=address)
        except OSError:
            # Ignore invalid addresses.
            pass