@ -62,8 +62,7 @@ class Nvr():
self . started_new_process = True
return main2 ( nvr , options , arguments )
time . sleep ( 0.2 )
print ( ' [!] Unable to attach to the new nvim process. Is ` {} ` working? '
. format ( " " . join ( args ) ) )
print ( f ' [!] Unable to attach to the new nvim process. Is ` { " " . join ( args ) } ` working? ' )
sys . exit ( 1 )
def execute_new_nvim_process ( self , silent , nvr , options , arguments ) :
@ -83,7 +82,7 @@ class Nvr():
try :
os . execvpe ( args [ 0 ] , args , os . environ )
except FileNotFoundError :
print ( " [!] Can ' t start new nvim process: ' {} ' is not in $PATH. " . format ( args [ 0 ] ) )
print ( f' [!] Can \' t start new nvim process: ` { args [ 0 ] } ` is not in $PATH. ' )
sys . exit ( 1 )
def read_stdin_into_buffer ( self , cmd ) :
@ -98,7 +97,7 @@ class Nvr():
path = self . server . funcs . fnameescape ( path )
shortmess = self . server . options [ ' shortmess ' ]
self . server . options [ ' shortmess ' ] = shortmess . replace ( ' F ' , ' ' )
self . server . command ( ' {} {} ' . format ( cmd , path ) )
self . server . command ( f' { cmd } { path } ' )
self . server . options [ ' shortmess ' ] = shortmess
def diffthis ( self ) :
@ -112,8 +111,8 @@ class Nvr():
chanid = self . server . channel_id
self . server . command ( ' augroup nvr ' )
self . server . command ( ' autocmd BufDelete <buffer> silent! call rpcnotify( { }, " BufDelete " ) ' . format ( chanid ) )
self . server . command ( ' autocmd VimLeave * if exists( " v:exiting " ) && v:exiting > 0 | silent! call rpcnotify( { }, " Exit " , v:exiting) | endif ' . format ( chanid ) )
self . server . command ( f ' autocmd BufDelete <buffer> silent! call rpcnotify( { chanid }, " BufDelete " ) ' )
self . server . command ( f ' autocmd VimLeave * if exists( " v:exiting " ) && v:exiting > 0 | silent! call rpcnotify( { chanid }, " Exit " , v:exiting) | endif ' )
self . server . command ( ' augroup END ' )
if ' nvr ' in bvars :
@ -178,7 +177,7 @@ def is_netrw_protocol(path):
def parse_args ( argv ) :
form_class = argparse . RawDescriptionHelpFormatter
usage = ' {} [arguments] ' . format ( argv [ 0 ] )
usage = argv [ 0 ] + ' [arguments] '
epilog = ' Development: https://github.com/mhinz/neovim-remote \n \n Happy hacking! '
desc = textwrap . dedent ( """
Remote control Neovim processes .
@ -309,36 +308,40 @@ def parse_args(argv):
def show_message ( address ) :
print ( textwrap . dedent ( '''
[ ! ] Can ' t connect to: { }
print ( textwrap . dedent ( f '''
[ ! ] Can ' t connect to: { address }
The server ( nvim ) and client ( nvr ) have to use the same address .
Server :
Expose $ NVIM_LISTEN_ADDRESS to the environment before
starting nvim :
Specify the server address when starting nvim :
$ NVIM_LISTEN_ADDRESS= { } nvim
$ nvim - - listen { address }
Use ` : echo v : servername ` to verify the address .
Security : When using Unix domain sockets on a multi - user system ,
the socket should have proper permissions so that it is only
accessible by your user .
Alternatively , run nvr without arguments . It defaults to
starting a new nvim process with the server name set to
" /tmp/nvimsocket " .
Security : When using an Unix domain socket , that socket should
have proper permissions so that it is only accessible by your
user .
Client :
Expose $ NVIM_LISTEN_ADDRESS to the environment before
using nvr or use its - - servername option . If neither
is given , nvr assumes \" /tmp/nvimsocket \" .
Expose $ NVIM_LISTEN_ADDRESS ( obsolete in nvim but still
supported by nvr ) to the environment before using nvr or use
its - - servername option . If neither is given , nvr assumes
\" /tmp/nvimsocket \" .
$ NVIM_LISTEN_ADDRESS = { } nvr file1 file2
$ nvr - - servername { } file1 file2
$ NVIM_LISTEN_ADDRESS = { address } nvr file1 file2
$ nvr - - servername { address } file1 file2
$ nvr - - servername 127.0 .0 .1 : 6789 file1 file2
Use - s to suppress this message .
''' .format(address, address, address, address) ))
''' ))
def split_cmds_from_files ( args ) :
@ -358,10 +361,10 @@ def split_cmds_from_files(args):
def print_versions ( ) :
import pkg_resources
print ( ' nvr {} ' . format ( pkg_resources . require ( ' neovim-remote ' ) [ 0 ] . version ) )
print ( ' pynvim {} ' . format ( pkg_resources . require ( ' pynvim ' ) [ 0 ] . version ) )
print ( ' psutil {} ' . format ( pkg_resources . require ( ' psutil ' ) [ 0 ] . version ) )
print ( ' Python {} ' . format ( sys . version . split ( ' \n ' ) [ 0 ] ) )
print ( ' nvr ' + pkg_resources . require ( " neovim-remote " ) [ 0 ] . version )
print ( ' pynvim ' + pkg_resources . require ( ' pynvim ' ) [ 0 ] . version )
print ( ' psutil ' + pkg_resources . require ( ' psutil ' ) [ 0 ] . version )
print ( ' Python ' + sys . version . split ( ' \n ' ) [ 0 ] )
def print_addresses ( ) :
@ -379,7 +382,7 @@ def print_addresses():
if conn . laddr :
addresses . insert ( 0 , conn . laddr )
except psutil . AccessDenied :
errors . insert ( 0 , ' Access denied for nvim ( { }) ' . format ( proc . pid ) )
errors . insert ( 0 , f ' Access denied for nvim ( { proc . pid } ) ' )
for addr in sorted ( addresses ) :
print ( addr )
@ -408,7 +411,7 @@ def main(argv=sys.argv, env=os.environ):
print_addresses ( )
return
address = options . servername or env . get ( ' NVIM _LISTEN_ADDRESS' ) or ' /tmp/nvimsocket '
address = options . servername or env . get ( ' NVIM ' ) or env . get ( ' NVIM _LISTEN_ADDRESS' ) or ' /tmp/nvimsocket '
nvr = Nvr ( address , options . s )
nvr . attach ( )
@ -468,11 +471,11 @@ def main2(nvr, options, arguments):
try :
result = nvr . server . eval ( options . remote_expr )
except :
print ( textwrap . dedent ( """
No valid expression : { }
print ( textwrap . dedent ( f """
No valid expression : { options . remote_expr }
Test it in Neovim : : echo eval ( ' ... ' )
If you want to execute a command , use - c or - cc instead .
""" ) .format(options.remote_expr) )
""" ) )
if type ( result ) is bytes :
print ( result . decode ( ) )
elif type ( result ) is list :
@ -509,14 +512,14 @@ def main2(nvr, options, arguments):
if options . t :
try :
nvr . server . command ( " tag {} " . format ( options . t ) )
nvr . server . command ( ' tag ' + options . t )
except nvr . server . error as e :
print ( e )
sys . exit ( 1 )
if options . q :
path = nvr . server . funcs . fnameescape ( os . environ [ ' PWD ' ] )
nvr . server . command ( ' lcd {} ' . format ( path ) )
nvr . server . command ( ' lcd ' + path )
nvr . server . funcs . setqflist ( [ ] )
if options . q == ' - ' :
for line in sys . stdin :