2
0
mirror of https://github.com/mhinz/neovim-remote synced 2024-11-11 13:10:34 +00:00

Clean up --help

This commit is contained in:
Marco Hinz 2015-12-16 19:32:36 +01:00
parent 8e649507b3
commit dc41ddec88

67
nvr
View File

@ -73,6 +73,9 @@ def parse_args():
epilog = epilog, epilog = epilog,
description = desc) description = desc)
# The following options are similar to their vim equivalents,
# but work on the remote instance instead.
parser.add_argument('-o', parser.add_argument('-o',
action = 'append', action = 'append',
metavar = '<files>', metavar = '<files>',
@ -81,39 +84,38 @@ def parse_args():
action = 'append', action = 'append',
metavar = '<files>', metavar = '<files>',
help = 'open files via :vsplit') help = 'open files via :vsplit')
parser.add_argument('-p',
action = 'append', # The following options exactly emulate their vim equivalents.
metavar = '<files>',
help = 'open files via :tabedit')
parser.add_argument('--remote', parser.add_argument('--remote',
action = 'append', action = 'append',
metavar = '<file>', metavar = '<files>',
help = 'open file in new buffer [ASYNC]') help = 'open files via :edit')
parser.add_argument('--remote-wait', parser.add_argument('--remote-wait',
action = 'append', action = 'append',
metavar = '<file>', metavar = '<files>',
help = 'as --remote [SYNC]') help = 'as --remote')
parser.add_argument('--remote-silent', parser.add_argument('--remote-silent',
action = 'append', action = 'append',
metavar = '<file>', metavar = '<files>',
help = "as --remote, but don't throw error if no server is found [ASYNC]") help = "as --remote, but don't throw error if no server is found")
parser.add_argument('--remote-wait-silent', parser.add_argument('--remote-wait-silent',
action = 'append', action = 'append',
metavar = '<file>', metavar = '<files>',
help = "as --remote, but don't throw error if no server is found [SYNC]") help = "as --remote, but don't throw error if no server is found")
parser.add_argument('--remote-tab', parser.add_argument('--remote-tab', '-p',
action = 'append', action = 'append',
metavar = '<file>', metavar = '<files>',
help = 'open file in new tab [SYNC]') help = 'open files via :tabedit')
parser.add_argument('--remote-send', parser.add_argument('--remote-send',
action = 'append', action = 'append',
metavar = '<keys>', metavar = '<keys>',
help = 'send keys to server [SYNC]') help = 'send key presses')
parser.add_argument('--remote-expr', parser.add_argument('--remote-expr',
action = 'append', action ='append',
metavar = '<expr>', nargs = '+',
help = 'evaluate expression and print result [SYNC]') metavar = '<exprs>',
help = 'evaluate expressions in server and print result')
parser.add_argument('--servername', parser.add_argument('--servername',
metavar = '<sock>', metavar = '<sock>',
help = 'path to unix socket (overrides $NVIM_LISTEN_ADDRESS)') help = 'path to unix socket (overrides $NVIM_LISTEN_ADDRESS)')
@ -145,23 +147,6 @@ def main():
n = Neovim(sockpath) n = Neovim(sockpath)
# The following options are similar to their vim equivalents,
# but work on the remote instance instead.
if args.o and n.attached():
for fname in args.o:
n.server.command('split {}'.format(fname.replace(" ", "\ ")), async=True)
if args.O and n.attached():
for fname in args.O:
n.server.command('vsplit {}'.format(fname.replace(" ", "\ ")), async=True)
if args.p and n.attached():
for fname in args.p:
n.server.command('tabedit {}'.format(fname.replace(" ", "\ ")), async=True)
# The following options exactly emulate their vim equivalents.
if args.remote_silent and n.attached(silent=True): if args.remote_silent and n.attached(silent=True):
for fname in args.remote_silent: for fname in args.remote_silent:
n.server.command('edit {}'.format(fname.replace(" ", "\ ")), async=True) n.server.command('edit {}'.format(fname.replace(" ", "\ ")), async=True)
@ -187,7 +172,7 @@ def main():
n.server.input(keys) n.server.input(keys)
if args.remote_expr and n.attached(): if args.remote_expr and n.attached():
for expr in args.remote_expr: for expr in args.remote_expr[0]:
result = n.server.eval(expr) result = n.server.eval(expr)
if type(result) is bytes: if type(result) is bytes:
print(result.decode()) print(result.decode())
@ -198,6 +183,14 @@ def main():
else: else:
print(result) print(result)
if args.o and n.attached():
for fname in args.o:
n.server.command('split {}'.format(fname.replace(" ", "\ ")), async=True)
if args.O and n.attached():
for fname in args.O:
n.server.command('vsplit {}'.format(fname.replace(" ", "\ ")), async=True)
if unused and n.attached(silent=True): if unused and n.attached(silent=True):
for fname in unused: for fname in unused:
n.server.command('edit {}'.format(fname.replace(" ", "\ ")), async=True) n.server.command('edit {}'.format(fname.replace(" ", "\ ")), async=True)