Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

load file with command on remote to open in Neovim locally #130

Open
vm-wylbur opened this issue Feb 28, 2024 · 2 comments
Open

load file with command on remote to open in Neovim locally #130

vm-wylbur opened this issue Feb 28, 2024 · 2 comments

Comments

@vm-wylbur
Copy link

I wonder if there would be a way to give a command to the server to load a file from the remote machine to a buffer in neovim on the local machine. I imagine semantics something like this:

# this is a remote server 
pball@snowball🌐:~
❯ distant server nvim-open path/to/myfile 

And a buffer for path/to/myfile opens in the local Neovim. This would be in some sense the inverse of distant spawn. SublimeText has a version of this but it has the "hang while a synchronous copy happens"/sshfs issue. Following up #129.

@chipsenkbeil
Copy link
Owner

Today there is not. The architecture works like this, where UDS is Unix Domain Socket (Mac/Linux/Unix), or a named pipe for Windows.

image

The protocol doesn't have any mechanism to send arbitrary data back from the server to the client that isn't associated with a running process, file IO, active search, or a couple of other APIs we provide.

The closest thing I could think of that could be done would be to start a remote process from distant.nvim where the remote process listens for commands you send it on the server and relays them back to neovim. Here's an example using netcat (BSD version):

  1. Use distant.nvim to spawn a netcat instance on some port that only listens locally: nc -kluw 0 localhost 8888
  2. When on your server, send a message to it to be echoed over stdout: echo nvim-open path/to/myfile | nc -uw 0 localhost 8888
  3. Receive the output from within distant.nvim and parse it to understand what you want to do
  4. Do whatever that is. In this case, use distant.nvim's API to open the file.

@vm-wylbur
Copy link
Author

Interesting! I'm a little stuck because somehow what I was doing in #129 to get connected has stopped working. I'll try this as soon as I get connections going again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants