Compare commits

...

6 Commits

@ -291,9 +291,12 @@ Using nvr from within `:terminal`: ![Demo 2](https://github.com/mhinz/neovim-rem
\| endif
```
- **Can I have auto-completion for bash?**
- **Can I have auto-completion for bash/fish?**
If you want basic auto-completion for bash, you can source [this
script](contrib/completion.bash) in your .bashrc.
This also completes server names with the `--servername` option.
If you want auto-completion for fish, you can add [this
file](contrib/completion.fish) to your fish completions dir.

@ -1,4 +1,4 @@
#/usr/bin/env bash
#!/usr/bin/env bash
# bash command completion for neovim remote.
# Source that file in your bashrc to use it.
@ -40,13 +40,17 @@ _nvr_opts_completions()
COMPREPLY=( $(compgen -W "${srvlist}" -- "$cur") )
return 0
;;
-[oOpq])
# These options require at least one argument.
COMPREPLY=( $(compgen -A file -- "$cur") )
return 0
;;
esac
if [[ "$cur" =~ ^- ]]; then
COMPREPLY=( $(compgen -W "${opts[*]}" -- "$cur") )
return 0
else
COMPREPLY=( $(compgen -A file -- "$cur") )
fi
COMPREPLY=()
return 0
}

@ -0,0 +1,28 @@
# Completions for nvr in fish shell
# To install, save file to completions directory of fish config (e.g. ~/.config/fish/completions/nvr.fish)
complete --command=nvr --long-option=remote --description='Use :edit to open files. If no process is found, throw an error and start a new one'
complete --command=nvr --long-option=remote-wait --description='Like --remote, but block until all buffers opened by this option get deleted or the process exits'
complete --command=nvr --long-option=remote-silent --description='Like --remote, but throw no error if no process is found'
complete --command=nvr --long-option=remote-wait-silent --description='Combines --remote-wait and --remote-silent'
complete --command=nvr --long-option=remote-tab --description='Like --remote, but use :tabedit'
complete --command=nvr --long-option=remote-tab-wait --description='Like --remote-wait, but use :tabedit'
complete --command=nvr --long-option=remote-tab-silent --description='Like --remote-silent, but use :tabedit'
complete --command=nvr --long-option=remote-tab-wait-silent --description='Like --remote-wait-silent, but use :tabedit'
complete --command=nvr --long-option=remote-send --no-files --description='Send key presses'
complete --command=nvr --long-option=remote-expr --no-files --description='Evaluate expression and print result in shell'
complete --command=nvr --long-option=servername --no-files --arguments='(nvr --serverlist)' --description='Set the address to be used. This overrides the default "/tmp/nvimsocket" and $NVIM_LISTEN_ADDRESS'
complete --command=nvr --long-option=serverlist --description='Print the TCPv4 and Unix domain socket addresses of all nvim processes'
complete --command=nvr --short-option=h --long-option=help --description='show help message and exit'
complete --command=nvr --short-option=c --no-files --description='Execute a command after every other option'
complete --command=nvr --short-option=d --description='Diff mode. Use :diffthis on all to be opened buffers'
complete --command=nvr --short-option=l --description='Change to previous window via ":wincmd p"'
complete --command=nvr --short-option=o --description='Open files via ":split"'
complete --command=nvr --short-option=O --description='Open files via ":vsplit"'
complete --command=nvr --short-option=p --description='Open files via ":tabedit"'
complete --command=nvr --short-option=q --description='Read errorfile into quickfix list and display first error'
complete --command=nvr --short-option=s --description='Silence "no server found" message'
complete --command=nvr --short-option=t --no-files --description='Jump to file and position of given tag'
complete --command=nvr --long-option=nostart --description='If no process is found, do not start a new one'
complete --command=nvr --long-option=version --description='Show the nvr version'
complete --command=nvr --old-option=cc --description='Execute a command before every other option'

@ -88,7 +88,7 @@ class Nvr():
def read_stdin_into_buffer(self, cmd):
self.server.command(cmd)
for line in sys.stdin:
self.server.funcs.append('$', line.rstrip())
self.server.funcs.append('$', line[:-1])
self.server.command('silent 1delete _ | set nomodified')
def fnameescaped_command(self, cmd, path):
@ -378,9 +378,14 @@ def print_addresses():
addresses.insert(0, ':'.join(map(str, conn.laddr)))
for conn in proc.connections('inet6'):
addresses.insert(0, ':'.join(map(str, conn.laddr)))
for conn in proc.connections('unix'):
if conn.laddr:
addresses.insert(0, conn.laddr)
try:
for conn in proc.connections('unix'):
if conn.laddr:
addresses.insert(0, conn.laddr)
except FileNotFoundError:
# Windows does not support Unix domain sockets and WSL1
# does not implement /proc/net/unix
pass
except psutil.AccessDenied:
errors.insert(0, f'Access denied for nvim ({proc.pid})')
@ -417,6 +422,15 @@ def main(argv=sys.argv, env=os.environ):
nvr.attach()
if not nvr.server:
if os.path.exists(nvr.address):
print(textwrap.dedent(f'''
[!] A file {nvr.address} exists, but we failed to attach to it.
Is it a Unix domain socket? Either remove that file and try
again or choose another address with --servername.
'''))
return
silent = options.remote_silent or options.remote_wait_silent or options.remote_tab_silent or options.remote_tab_wait_silent or options.s
if not silent:
show_message(address)
@ -491,7 +505,7 @@ def main2(nvr, options, arguments):
if options.o:
args = options.o + arguments
if nvr.diffmode and not nvr.started_new_process:
nvr.fnameescaped_command('tabedit', args[0])
nvr.execute(args[:1], 'tabedit', silent=True, wait=False)
nvr.execute(args[1:], 'split', silent=True, wait=False)
else:
nvr.execute(args, 'split', silent=True, wait=False)
@ -499,7 +513,7 @@ def main2(nvr, options, arguments):
elif options.O:
args = options.O + arguments
if nvr.diffmode and not nvr.started_new_process:
nvr.fnameescaped_command('tabedit', args[0])
nvr.execute(args[:1], 'tabedit', silent=True, wait=False)
nvr.execute(args[1:], 'vsplit', silent=True, wait=False)
else:
nvr.execute(args, 'vsplit', silent=True, wait=False)

Loading…
Cancel
Save