#!/usr/bin/env python
from neovim import attach
import os
import sys
import os.path

args = sys.argv[1:]
if not args:
    print("Usage: {} <filename> ...".format(sys.argv[0]))
    sys.exit(1)

addr = os.environ["NVIM_LISTEN_ADDRESS"]
if not addr:
    # TODO: Open a new nvim instance if no addr
    sys.exit(2)

nvim = attach("socket", path=addr)

def normalizePath(name):
    return os.path.abspath(name).replace(" ", "\\ ")

def request_callback(*args):
    return

def notification_callback(event_type, *args):
    if 'nvim_buf_detach_event' == event_type:
        nvim.stop_loop()

def openFiles():
    # To escape terminal mode. Not sure if bug.
    nvim.feedkeys('', "n")
    for x in args:
        nvim.command("drop {}".format(normalizePath(x)))
        nvim.current.buffer.api.attach(True, {})
        nvim.run_loop(request_callback, notification_callback)


openFiles()

1323e075cbb0a0c2149934dfcf9d81ac241494b1
<mask token>


def normalizePath(name):
    return os.path.abspath(name).replace(' ', '\\ ')


def request_callback(*args):
    return


def notification_callback(event_type, *args):
    if 'nvim_buf_detach_event' == event_type:
        nvim.stop_loop()


def openFiles():
    nvim.feedkeys('\x1c\x0e', 'n')
    for x in args:
        nvim.command('drop {}'.format(normalizePath(x)))
        nvim.current.buffer.api.attach(True, {})
        nvim.run_loop(request_callback, notification_callback)


<mask token>

<mask token>
if not args:
    print('Usage: {} <filename> ...'.format(sys.argv[0]))
    sys.exit(1)
<mask token>
if not addr:
    sys.exit(2)
<mask token>


def normalizePath(name):
    return os.path.abspath(name).replace(' ', '\\ ')


def request_callback(*args):
    return


def notification_callback(event_type, *args):
    if 'nvim_buf_detach_event' == event_type:
        nvim.stop_loop()


def openFiles():
    nvim.feedkeys('\x1c\x0e', 'n')
    for x in args:
        nvim.command('drop {}'.format(normalizePath(x)))
        nvim.current.buffer.api.attach(True, {})
        nvim.run_loop(request_callback, notification_callback)


openFiles()

<mask token>
args = sys.argv[1:]
if not args:
    print('Usage: {} <filename> ...'.format(sys.argv[0]))
    sys.exit(1)
addr = os.environ['NVIM_LISTEN_ADDRESS']
if not addr:
    sys.exit(2)
nvim = attach('socket', path=addr)


def normalizePath(name):
    return os.path.abspath(name).replace(' ', '\\ ')


def request_callback(*args):
    return


def notification_callback(event_type, *args):
    if 'nvim_buf_detach_event' == event_type:
        nvim.stop_loop()


def openFiles():
    nvim.feedkeys('\x1c\x0e', 'n')
    for x in args:
        nvim.command('drop {}'.format(normalizePath(x)))
        nvim.current.buffer.api.attach(True, {})
        nvim.run_loop(request_callback, notification_callback)


openFiles()

from neovim import attach
import os
import sys
import os.path
args = sys.argv[1:]
if not args:
    print('Usage: {} <filename> ...'.format(sys.argv[0]))
    sys.exit(1)
addr = os.environ['NVIM_LISTEN_ADDRESS']
if not addr:
    sys.exit(2)
nvim = attach('socket', path=addr)


def normalizePath(name):
    return os.path.abspath(name).replace(' ', '\\ ')


def request_callback(*args):
    return


def notification_callback(event_type, *args):
    if 'nvim_buf_detach_event' == event_type:
        nvim.stop_loop()


def openFiles():
    nvim.feedkeys('\x1c\x0e', 'n')
    for x in args:
        nvim.command('drop {}'.format(normalizePath(x)))
        nvim.current.buffer.api.attach(True, {})
        nvim.run_loop(request_callback, notification_callback)


openFiles()

#!/usr/bin/env python
from neovim import attach
import os
import sys
import os.path

args = sys.argv[1:]
if not args:
    print("Usage: {} <filename> ...".format(sys.argv[0]))
    sys.exit(1)

addr = os.environ["NVIM_LISTEN_ADDRESS"]
if not addr:
    # TODO: Open a new nvim instance if no addr
    sys.exit(2)

nvim = attach("socket", path=addr)

def normalizePath(name):
    return os.path.abspath(name).replace(" ", "\\ ")

def request_callback(*args):
    return

def notification_callback(event_type, *args):
    if 'nvim_buf_detach_event' == event_type:
        nvim.stop_loop()

def openFiles():
    # To escape terminal mode. Not sure if bug.
    nvim.feedkeys('', "n")
    for x in args:
        nvim.command("drop {}".format(normalizePath(x)))
        nvim.current.buffer.api.attach(True, {})
        nvim.run_loop(request_callback, notification_callback)


openFiles()
