Skip to content

Commit f292de3

Browse files
authored
feat: Add plugin with :NvrhOpen command (#86)
The other side of #83. Add `mikew/nvrh` to your neovim plugins and then you can call `:NvrhOpen SERVER [DIRECTORY]` Config is still done in `nvrh.yml`, not really sure how much this will be used because it's a new thing Neovim UIs need to handle, and the only one that does (that I've found? so far?) is neovim itself. `nvrh` is still required to be on your `PATH`, it doesn't do any downloading. Need file signatures in releases before I'll attempt something like that. neovide/neovide#3469 equalsraf/neovim-qt#1158
1 parent 4011e96 commit f292de3

2 files changed

Lines changed: 78 additions & 0 deletions

File tree

README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ OPTIONS:
4848
--ssh-arg string [ --ssh-arg string ] Additional arguments to pass to the SSH command [$NVRH_CLIENT_SSH_ARG]
4949
--enable-automap-ports Enable automatic port mapping (default: true) [$NVRH_CLIENT_AUTOMAP_PORTS]
5050
--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
51+
--use-nvim-embed Whether to use --embed instead of --headless (default: false)
5152
--help, -h show help
5253
```
5354

@@ -75,6 +76,51 @@ OPTIONS:
7576
--help, -h show help
7677
```
7778

79+
### `nvrh client from-neovim`
80+
81+
```
82+
NAME:
83+
nvrh client from-neovim - Attach a running local neovim UI to a remote nvim instance via SSH
84+
85+
USAGE:
86+
nvrh client from-neovim [options] <original-server> <server> [remote-directory]
87+
88+
CATEGORY:
89+
client
90+
91+
OPTIONS:
92+
--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")
93+
--use-ports Use ports instead of sockets. Defaults to true on Windows [$NVRH_CLIENT_USE_PORTS] (default: false)
94+
--debug (default: false) [$NVRH_CLIENT_DEBUG]
95+
--server-env string [ --server-env string ] Environment variables to set on the remote server [$NVRH_CLIENT_SERVER_ENV]
96+
--nvim-cmd nvim [ --nvim-cmd nvim ] Command to run nvim with. Defaults to nvim [$NVRH_CLIENT_NVIM_CMD] (default: "nvim")
97+
--ssh-arg string [ --ssh-arg string ] Additional arguments to pass to the SSH command [$NVRH_CLIENT_SSH_ARG]
98+
--enable-automap-ports Enable automatic port mapping (default: true) [$NVRH_CLIENT_AUTOMAP_PORTS]
99+
--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
100+
--use-nvim-embed Whether to use --embed instead of --headless (default: false)
101+
--help, -h show help
102+
```
103+
104+
### Neovim Plugin
105+
106+
If your Neovim UI supports `:connect`, you can add nvrh to get an `:NvrhConnect`
107+
command that will connect your currently running Neovim UI to a remote.
108+
109+
```lua
110+
vim.pack.add({
111+
{
112+
src = 'https://github.com/mikew/nvrh',
113+
version = vim.version.range('*'),
114+
},
115+
})
116+
```
117+
118+
Then
119+
120+
```vim
121+
:NvrhConnect my-remote-server path/to/project
122+
```
123+
78124
### Launch a different editor
79125

80126
By default nvrh runs `nvim`, but you can run something else with

plugin/nvrh.lua

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
--- @param args string[]
2+
local function nvrh_connect(args)
3+
if _G._nvrh then
4+
local hint_cmd = { 'nvrh', 'client', 'open' }
5+
for _, arg in ipairs(args) do
6+
table.insert(hint_cmd, arg)
7+
end
8+
9+
vim.notify(
10+
'Already connected to nvrh, please manually run `'
11+
.. table.concat(hint_cmd, ' ')
12+
.. '` in your terminal to start a new session.',
13+
vim.log.levels.WARN
14+
)
15+
return
16+
end
17+
18+
local cmd = { 'nvrh', 'client', 'from-neovim', vim.v.servername }
19+
20+
for _, arg in ipairs(args) do
21+
table.insert(cmd, arg)
22+
end
23+
24+
vim.system(cmd, { detach = true })
25+
end
26+
27+
vim.api.nvim_create_user_command('NvrhConnect', function(args)
28+
nvrh_connect(args.fargs)
29+
end, {
30+
nargs = '*',
31+
force = true,
32+
})

0 commit comments

Comments
 (0)