Thanks to visit codestin.com
Credit goes to Github.com

Skip to content
/ nvrh Public

Aims to be similar to VSCode Remote, but for Neovim

License

Notifications You must be signed in to change notification settings

mikew/nvrh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

86 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nvrh

nvrh.demo.client.open.mov

nvrh (Neovim Remote Helper) aims to provide a simple way of working with a remote Neovim instance, like you would with VSCode Remote.

Installation

Download the nvrh binary for your platform / architecture from the latest release.

Rename the downloaded file to nvrh and put it somewhere on your PATH for convenience.

Features

  • Start Neovim on a remote machine.
  • Tunnel the connection between your local and remote machines.
  • Start your editor locally, talking to your remote Neovim instance.
  • Provide an easy way to tunnel ports.
  • Provide an easy way to open URLs on your local machine.

Usage

nvrh client open

This will open a new Neovim instance on your remote machine and tunnel the socket to your local machine.

NAME:
   nvrh client open - Open a remote nvim instance in a local editor

USAGE:
   nvrh client open [options] <server> [remote-directory]

CATEGORY:
   client

OPTIONS:
   --ssh-path string                                Path to SSH binary. 'binary' will use the default system SSH binary. 'internal' will use the internal SSH client. Anything else will be used as the path to the SSH binary [$NVRH_CLIENT_SSH_PATH] (default: "binary")
   --use-ports                                      Use ports instead of sockets. Defaults to true on Windows [$NVRH_CLIENT_USE_PORTS] (default: false)
   --debug                                          (default: false) [$NVRH_CLIENT_DEBUG]
   --server-env string [ --server-env string ]      Environment variables to set on the remote server [$NVRH_CLIENT_SERVER_ENV]
   --local-editor string [ --local-editor string ]  Local editor to use. {{SOCKET_PATH}} will be replaced with the socket path [$NVRH_CLIENT_LOCAL_EDITOR] (default: "nvim", "--server", "{{SOCKET_PATH}}", "--remote-ui")
   --nvim-cmd nvim [ --nvim-cmd nvim ]              Command to run nvim with. Defaults to nvim [$NVRH_CLIENT_NVIM_CMD] (default: "nvim")
   --ssh-arg string [ --ssh-arg string ]            Additional arguments to pass to the SSH command [$NVRH_CLIENT_SSH_ARG]
   --enable-automap-ports                           Enable automatic port mapping (default: true) [$NVRH_CLIENT_AUTOMAP_PORTS]
   --insecure-direct-connect string                 Opens a public port on the server and connects directly to it. Use 'true' to connect to the server you're already passing
   --help, -h                                       show help

nvrh client reconnect

Reconnect to an existing nvrh session.

NAME:
   nvrh client reconnect - Reconnect to an existing remote nvim instance

USAGE:
   nvrh client reconnect [options] <server> <session-id>

CATEGORY:
   client

OPTIONS:
   --ssh-path string                                Path to SSH binary. 'binary' will use the default system SSH binary. 'internal' will use the internal SSH client. Anything else will be used as the path to the SSH binary [$NVRH_CLIENT_SSH_PATH] (default: "binary")
   --use-ports                                      Use ports instead of sockets. Defaults to true on Windows [$NVRH_CLIENT_USE_PORTS] (default: false)
   --debug                                          (default: false) [$NVRH_CLIENT_DEBUG]
   --local-editor string [ --local-editor string ]  Local editor to use. {{SOCKET_PATH}} will be replaced with the socket path [$NVRH_CLIENT_LOCAL_EDITOR] (default: "nvim", "--server", "{{SOCKET_PATH}}", "--remote-ui")
   --ssh-arg string [ --ssh-arg string ]            Additional arguments to pass to the SSH command [$NVRH_CLIENT_SSH_ARG]
   --insecure-direct-connect string                 Opens a public port on the server and connects directly to it. Use 'true' to connect to the server you're already passing
   --help, -h                                       show help

Launch a different editor

By default nvrh runs nvim, but you can run something else with --local-editor. This example runs nvim-qt:

nvrh client open \
  --local-editor nvim-qt,--nofork,--server,{{SOCKET_PATH}}

Configuration

nvrh can be configured with:

  • Environment variables (see --help to see what's supported)
  • A configuration file at ~/.config/nvrh/config.yaml
  • Command line arguments (see --help)

The configuration file uses the same names as the command line arguments. It supports a default section in addition to the name of any remote server you're connecting to.

default:
  ssh-path: internal

  local-editor:
    - nvim-qt
    - --nofork
    - --server
    - "{{SOCKET_PATH}}"

  server-env:
    - FOO=bar

servers:
  my-remote-server:
    nvim-cmd:
      - /home/linuxbrew/.linuxbrew/bin/nvim

  my-remote-server-requiring-ssh:
    ssh-path: binary

  my-remote-windows-server:
    nvim-cmd:
      - mise
      - exec
      - --
      - nvim

Tunneling Ports

nvrh.demo.tunnel.port.mov

nvrh can tunnel ports between your local and remote machine. This happens either automatically by scanning the output of terminal buffers, or manually with the :NvrhTunnelPort command.

:NvrhTunnelPort 8080
:NvrhTunnelPort 4000

Opening URLs

nvrh.demo.open.url.mov

nvrh can open URLs on your local machine from your remote Neovim instance. There's a few ways to trigger this:

  • vim.ui.open, so gx and :Open https://example.com will work.
  • The BROWSER environment variable for process started from Neovim.
  • The :NvrhOpenUrl command.

Editing Files

540724047-66537ca3-8616-4d3f-80c7-ef0df9630755.mov

nvrh sets the $EDITOR environment variable on the remote machine, so something like git commit will open the file in your current remote session. This also works for UIs that have an "Open in Editor" feature.

Windows Support

nvrh.demo.windows.remote.mov

nvrh supports Windows both locally and remote. If running on Windows, or if nvrh detects the remote machine is Windows --use-ports will default to true.

About

Aims to be similar to VSCode Remote, but for Neovim

Topics

Resources

License

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •