mirror of
https://github.com/mhinz/neovim-remote
synced 2024-11-11 13:10:34 +00:00
parent
c7a52cb453
commit
172ee11a13
17
nvr/nvr.py
17
nvr/nvr.py
@ -81,6 +81,11 @@ class Nvr():
|
|||||||
format(line.rstrip().replace("'", "''")))
|
format(line.rstrip().replace("'", "''")))
|
||||||
self.server.command('silent 1delete _ | set nomodified')
|
self.server.command('silent 1delete _ | set nomodified')
|
||||||
|
|
||||||
|
def fnameescaped_command(self, cmd, fname):
|
||||||
|
path = os.path.abspath(fname)
|
||||||
|
path = self.server.eval("fnameescape('{}')".format(path))
|
||||||
|
self.server.command('{} {}'.format(cmd, path))
|
||||||
|
|
||||||
def execute(self, arguments, cmd='edit', silent=False, wait=False):
|
def execute(self, arguments, cmd='edit', silent=False, wait=False):
|
||||||
cmds, files = split_cmds_from_files(arguments)
|
cmds, files = split_cmds_from_files(arguments)
|
||||||
|
|
||||||
@ -89,7 +94,7 @@ class Nvr():
|
|||||||
self.read_stdin_into_buffer('enew' if cmd == 'edit' else cmd)
|
self.read_stdin_into_buffer('enew' if cmd == 'edit' else cmd)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
self.server.command('{} {}'.format(cmd, prepare_filename(fname)))
|
self.fnameescaped_command(cmd, fname)
|
||||||
except neovim.api.nvim.NvimError as e:
|
except neovim.api.nvim.NvimError as e:
|
||||||
if not re.search('E37', e.args[0].decode()):
|
if not re.search('E37', e.args[0].decode()):
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
@ -297,10 +302,6 @@ def split_cmds_from_files(args):
|
|||||||
return [], []
|
return [], []
|
||||||
|
|
||||||
|
|
||||||
def prepare_filename(fname):
|
|
||||||
return os.path.abspath(fname).replace(" ", "\ ")
|
|
||||||
|
|
||||||
|
|
||||||
def print_sockaddrs():
|
def print_sockaddrs():
|
||||||
sockaddrs = []
|
sockaddrs = []
|
||||||
|
|
||||||
@ -417,20 +418,20 @@ def main(argv=sys.argv, env=os.environ):
|
|||||||
if fname == '-':
|
if fname == '-':
|
||||||
nvr.read_stdin_into_buffer('new')
|
nvr.read_stdin_into_buffer('new')
|
||||||
else:
|
else:
|
||||||
nvr.server.command('split {}'.format(prepare_filename(fname)))
|
nvr.fnameescaped_command('split', fname)
|
||||||
if options.O:
|
if options.O:
|
||||||
for fname in options.O:
|
for fname in options.O:
|
||||||
if fname == '-':
|
if fname == '-':
|
||||||
nvr.read_stdin_into_buffer('vnew')
|
nvr.read_stdin_into_buffer('vnew')
|
||||||
else:
|
else:
|
||||||
nvr.server.command('vsplit {}'.format(prepare_filename(fname)))
|
nvr.fnameescaped_command('vsplit', fname)
|
||||||
|
|
||||||
if options.p:
|
if options.p:
|
||||||
for fname in options.p:
|
for fname in options.p:
|
||||||
if fname == '-':
|
if fname == '-':
|
||||||
nvr.read_stdin_into_buffer('tabnew')
|
nvr.read_stdin_into_buffer('tabnew')
|
||||||
else:
|
else:
|
||||||
nvr.server.command('tabedit {}'.format(prepare_filename(fname)))
|
nvr.fnameescaped_command('tabedit', fname)
|
||||||
|
|
||||||
if options.t:
|
if options.t:
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user