-
Notifications
You must be signed in to change notification settings - Fork 200
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
Tramp support, fixes #84 #463
Conversation
I don't know where to look at in order to fix the checks |
It would be super cool if this, or a followup to it, would enable using Windows Emacs with a Linux/WSL project (toolchain running in WSL). Currently it doesn't work because of the pathname differences; the WSL toolchain sees "/c/my/project/foo.ts" but Emacs sees "c:/my/project/foo.ts". Because of this I run an extra copy of my toolchain on Windows just for LSP. Even if this PR only supports tramp mode, maybe an extension to it would help me. Interested in your thoughts, @FelipeLema . |
let's do it, I like the patch, but we have to conditionalize this on Emacs-27. And clean up the commit messages etc. And get someone to test. I suppose you would @garyo ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty good, I don't even think we need to do any checking on Emacs version.
But I think we need a test or two. if you can't program that test please describe how I can test this in my local machine.
Yes, I'll try it -- not a tramp expert, and tramp isn't needed for Windows->WSL (just filename mapping) but it would be cool to see it working. |
will add unit tests next, yo |
@garyo
See #350 (comment) |
don't test remoteness on process… that doesn't make any sense
huh? travis CI wasn't triggered? |
I activated this PR to get Travis CI to compile, although this is not working in my current setup (hint: it should). Now it just waits forever for an answer from the server. I wanted to activate Travis to check output from the tests. Maybe get something more helpful than "eglot timed out". |
@FelipeLema don't worry much about Travis. The important thing is to have tests running with So we need elisp tests that check tramp-related scenarios in Although, it's certainly nice to have them passing in Travis, if you feel you're getting somewhere. But just so you understand the priorities, Travis CI isn't one of them. It's likely that Eglot's tests suite will move from Travis CI to something else soon. |
Makefile
Outdated
@@ -43,6 +43,7 @@ eglot-check: compile | |||
-l eglot \ | |||
-l eglot-tests \ | |||
--eval '(setq ert-batch-backtrace-right-margin 200)' \ | |||
--eval '(setq default-directory (concat "/ssh:localhost:" default-directory))' \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this? We don't want to run all the tests through a loopback ssh Tramp connection. We just want to do that maybe, for a couple (or more) of tests that are related to Tramp. What if the user running the tests doesn't have the ssh program?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't need this: I'm leveraging Travis to run the tests for me (setups several LSP servers). I wanted to keep this as draft PR, but Travis stopped working.
see my comments above as I've explained
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So what you're saying is that your idea is to run all the tests in a Tramp setting?
@@ -69,7 +69,11 @@ then restored." | |||
|
|||
(defun eglot--call-with-fixture (fixture fn) | |||
"Helper for `eglot--with-fixture'. Run FN under FIXTURE." | |||
(let* ((fixture-directory (make-temp-file "eglot--fixture" t)) | |||
(let* ((temporary-file-directory ;; ensure tmp directory respects remote |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar comment here, though maybe this makes sense. However, it is only in the subset of Tram tests that we need to worry about these things. So a second macro like eglot--with-tramp-fixure
or just directly let-binding this in the new Tramp-related tests, would be sufficient.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to do a second macro, simply let
-ing default-directory
to something remote (ie: with tramp prefix) before calling this function should do the trick.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to do a second macro, simply let-ing default-directory to something remote (ie: with tramp prefix) before calling this function should do the trick.
Yes, that works fine too. That's what I meant by "directly let-binding this" in the new tests.
it was originally there and using `delete-trailing-whitespace` in `before-save-hook` would erase it
The purpose of calling `eglot--maybe-activate-editing-mode` here is to handle all buffers that could've been handled by the server we've just set up *and* hadn't been doing so. However, it wouldn't make sense to try to manage / edit a buffer that is not reachable by the server. This happens when we're editing tramp / remote files, in which the server may be running in one machine (say, my-remote-server) and a buffer is running in another one (say, localhost)
Hi Felipe. I won't be able to review this PR thoroughly or even try it out. Additionally, I won't use this feature. Nevertheless, I'd like to see this merged. However, it will make my life a bit harder, because I rely on the x-files LSP extension (implemented in eglot-x.el) that allows us to work on tramp files using a local LSP server. But your approach is definitely better for larger projects. This PR interferes with eglot-x, but do not worry about that. I'll fix elgot-x when necessary. Regarding the documentation in README.md, I don't see why users should configure anything if clangd is in the users' (remote) path. Can the tramp support work out-of-the box for simple cases? I don't understand this comment: "activate managed mode on other buffers in the same machine this server is running in". Why do you need special treatment for remote files? What happens if you have an emacs session with two projects on the same remote machine but with different LSP servers, or an independently opened remote file not belonging to any of those projects? |
What's this eglot-x thing, I don't see such a file in the project? @nemethf I'd advise against supporting so many features in eglot - is there any value in allowing multiple options to work over tramp? Would be confusing for the user, hard for the maintainer |
@FelipeLema I tested your branch on emacs 26.3 - I get an error for wrong number of args passed to I assume emacs 27 has signature trace:
|
@edkolev yes, you're right. Perhaps this feature can be backported into eglot (like |
Let me know if I can help of that. I had no idea of this eglot-x project you mention.
Yes, it will support simple cases where the command (say Perhaps it's too aggressive to put it there in the readme / front page and maybe that info should go somewhere else. Would you have somewhere specific in mind?
Let's say you are working on laptop L and you have remote connections to machines A in Armenia, B in Belarus and C in Chile. For simplicity, you start with Emacs with no opened files. So you start editing a python file The way it works is that tramp uses a prefix for paths, ( I can't think of a re-phrasing of this comment that can a) be more clear about it b) uses one or two lines. Suggestions are welcome. |
This helps when dealing with same basename-directory in different servers
It helps readibility since it's closer to tramp naming scheme in which the hostname goes at the beginning of the filepath.
Elgot-x is a project of mine. I mentioned it because its remote server support is the reason I don't follow your work closely. You shouldn't worry about eglot-x at this point. (Although it would make my life easier later if eglot--path-to-uri only used file-local-name if the server is a tramp remote server.)
I don't know. Maybe stating this is only necessary for explicitly specifying a remote full path is enough.
I think the approach you described is problematic. This is the correct approach: two files should be served by the same server if they belong to the same project. They belong to the same project if their |
will update the README accordingly, then.
I understand where you're coming from. This is actually an optimization to reduce the number of calls to each function in However, calls to functions in |
Now that I've actually read the code, I think I understand it. The code below the comment pre-filters What do you think about something like the following comment instead:
Additionally, the white-space changes right below this change are unnecessary and confusing. Also, it's not a big deal, but somehow I'd like to avoid non-ascii chars when possible. Can you replace «» with something simpler? Thanks. |
no problem, applying changes |
@FelipeLema what's pending to move this PR forward? If you need help with testing - I can pull the branch and test |
I've compiled the pending items in the first post of this PR |
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.
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.
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
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
fixes #84
beware: this is only supported in Emacs 27 onwards. I may have used things from nightly, but I'm not certain about it
Pending items: