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

could eglot work with remote project? #84

Closed
zhongweiy opened this issue Aug 22, 2018 · 5 comments
Closed

could eglot work with remote project? #84

zhongweiy opened this issue Aug 22, 2018 · 5 comments

Comments

@zhongweiy
Copy link

hi,
Say a project is on a remote raspberry pi, I have emacs installed on local desktop. When the project file is opened by the desktop emacs (say using tramp), can I get the open file indexed?

Specificly, the project is a cpp project, the toolchain is only availabe on the remote pi. So the lsp server is better running on the remote pi. Can I get it work by eglot?

Thanks!

@joaotavora
Copy link
Owner

Hi, this is a very good question.

When the project file is opened by the desktop emacs (say using tramp), can I get the open file indexed?

Yes, I suppose so. Although it depends on how the server interprets the resulting file URLs. Eglot could, if the spec allows it (or even if it doesn't) implement a customization point for this.

So the lsp server is better running on the remote pi.

You can, assuming you have TCP/IP on the pi and start the server with this option. See the docstring of eglot-server-programs for details.

@zhongweiy
Copy link
Author

Thanks! I'll give a try.

@slippycheeze
Copy link

FWIW, I'd be ... quite in favor, shall we say, of this happening. For "local", as in stdio style, servers, switching to just using start-file-process instead of start-process would be sufficient; interpreting the filenames reported as (expand-file-name FROM-SERVER default-directory) in the file buffer should work to get a tramp-suitable name for them -- or you can use file-remote-p on the buffer filename to get a "truthy" value that is the remote host prefix. (eg: for tramp /ssh:example.com:~/src that'd return /ssh:example.com:, which you can paste to the front of an absolute remote path.

I'm glad to hear you are open to the idea, as depending how things go, I may end up with submittable patches; do you require confirmation of FSF contribution papers, or another agreement for them?

Please do not take this as any sort of promise about when, or if, I will do anything, though. :/

@joaotavora
Copy link
Owner

switching to just using start-file-process instead of start-process

This comment made me realize that this is better implemented in Emacs's jsonrpc.el, rather than in eglot.el (although it could be experimentally implemented in eglot).

do you require confirmation of FSF contribution papers,

I require that you start the copyright paperwork process, but you can contribute before you get the official confirmation.

@zhongweiy
Copy link
Author

zhongweiy commented Aug 25, 2018

@joaotavora

Although it depends on how the server interprets the resulting file URLs. Eglot could, if the spec allows it (or even if it doesn't) implement a customization point for this.

By following your suggestion, I took a try by providing a LSP remote server (a Cquery server) to Eglot and converting the tramp file URL to local file URL back and forth. And I check some functions (xref-find-definitions) works with my ugly hacking patch to Eglot.

I have not tried the approach @slippycheeze mentioned (start the Cquery server by start-file-process seems much more convenient.)

Here are some details:

  1. Get Cquery installed on my remote server (192.168.1.50). And run it by nc -l -p 5010 -e cquery to redirect stdout to socket.
  2. Open a cpp file in the remote server by the local desktop Emacs by tramp ssh. And start the Eglot with server: 192.168.1.50:5010. Done.

@FelipeLema FelipeLema mentioned this issue May 8, 2020
2 tasks
@bjc bjc mentioned this issue Mar 3, 2021
bhankas pushed a commit to bhankas/emacs that referenced this issue Sep 18, 2022
Also close joaotavora/eglot#463, close joaotavora/eglot#84.

Thanks to Brian Cully for the original simple idea.  The basic
technique is to pass :file-handler t to make-process, then tweak
eglot--uri-to-path and eglot--path-to-uri, along with some other
functions, to be aware of "trampy" paths".

Crucially, a "stty hack" was needed.  It has been encapsulated in a
new a new eglot--cmd helper, which contains a comment explaining the
hack.

Co-authored-by: João Távora <joaotavora@gmail.com>

* eglot.el (eglot--executable-find): Shim two-arg executable-find
function only available on Emacs 27.
(eglot--guess-contact): Use eglot--executable-find.
(eglot--cmd): New helper.
(eglot--connect): Use eglot--cmd.  Use :file-handler arg to
make-process.
(eglot--connect, eglot--path-to-uri): Be aware of trampy file
names.

* eglot-tests.el (eglot-tests--auto-detect-running-server-1): New helper.
(eglot--guessing-contact): Better mock for executable-find.
(eglot--tramp-test): New test.

* NEWS.md: mention TRAMP support.

* README.md: mention TRAMP support.
bhankas pushed a commit to bhankas/emacs that referenced this issue Sep 19, 2022
Also close joaotavora/eglot#463, close joaotavora/eglot#84.

Thanks to Brian Cully for the original simple idea.  The basic
technique is to pass :file-handler t to make-process, then tweak
eglot--uri-to-path and eglot--path-to-uri, along with some other
functions, to be aware of "trampy" paths".

Crucially, a "stty hack" was needed.  It has been encapsulated in a
new a new eglot--cmd helper, which contains a comment explaining the
hack.

Co-authored-by: João Távora <joaotavora@gmail.com>

* eglot.el (eglot--executable-find): Shim two-arg executable-find
function only available on Emacs 27.
(eglot--guess-contact): Use eglot--executable-find.
(eglot--cmd): New helper.
(eglot--connect): Use eglot--cmd.  Use :file-handler arg to
make-process.
(eglot--connect, eglot--path-to-uri): Be aware of trampy file
names.

* eglot-tests.el (eglot-tests--auto-detect-running-server-1): New helper.
(eglot--guessing-contact): Better mock for executable-find.
(eglot--tramp-test): New test.

* NEWS.md: mention TRAMP support.

* README.md: mention TRAMP support.
bhankas pushed a commit to bhankas/emacs that referenced this issue Sep 19, 2022
Also close #463, close #84.

Thanks to Brian Cully for the original simple idea.  The basic
technique is to pass :file-handler t to make-process, then tweak
eglot--uri-to-path and eglot--path-to-uri, along with some other
functions, to be aware of "trampy" paths".

Crucially, a "stty hack" was needed.  It has been encapsulated in a
new a new eglot--cmd helper, which contains a comment explaining the
hack.

Co-authored-by: João Távora <joaotavora@gmail.com>

* eglot.el (eglot--executable-find): Shim two-arg executable-find
function only available on Emacs 27.
(eglot--guess-contact): Use eglot--executable-find.
(eglot--cmd): New helper.
(eglot--connect): Use eglot--cmd.  Use :file-handler arg to
make-process.
(eglot--connect, eglot--path-to-uri): Be aware of trampy file
names.

* eglot-tests.el (eglot-tests--auto-detect-running-server-1): New helper.
(eglot--guessing-contact): Better mock for executable-find.
(eglot--tramp-test): New test.

* NEWS.md: mention TRAMP support.

* README.md: mention TRAMP support.

#637: joaotavora/eglot#637
#463: joaotavora/eglot#463
#84: joaotavora/eglot#84
jollaitbot pushed a commit to sailfishos-mirror/emacs that referenced this issue Oct 12, 2022
Also close joaotavora/eglot#463, close joaotavora/eglot#84.

Thanks to Brian Cully for the original simple idea.  The basic
technique is to pass :file-handler t to make-process, then tweak
eglot--uri-to-path and eglot--path-to-uri, along with some other
functions, to be aware of "trampy" paths".

Crucially, a "stty hack" was needed.  It has been encapsulated in a
new a new eglot--cmd helper, which contains a comment explaining the
hack.

Co-authored-by: João Távora <joaotavora@gmail.com>

* eglot.el (eglot--executable-find): Shim two-arg executable-find
function only available on Emacs 27.
(eglot--guess-contact): Use eglot--executable-find.
(eglot--cmd): New helper.
(eglot--connect): Use eglot--cmd.  Use :file-handler arg to
make-process.
(eglot--connect, eglot--path-to-uri): Be aware of trampy file
names.

* eglot-tests.el (eglot-tests--auto-detect-running-server-1): New helper.
(eglot--guessing-contact): Better mock for executable-find.
(eglot--tramp-test): New test.

* NEWS.md: mention TRAMP support.

* README.md: mention TRAMP support.

GitHub-reference: close joaotavora/eglot#637
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

Successfully merging a pull request may close this issue.

3 participants