reddit / emacs

How to use eglot over TRAMP and lsp-mode on local files?

mklsls · 2022-09-28 17:57
Hi all! I have this in my doom config `init.el` (lsp +eglot +peek) Basically, I've installed `lsp-mode` and `eglot` at the same time. The reason is that `eglot` works over TRAMP, while `lsp-mode` not. Also, I use a lot [lsp-ltex](https://github.com/emacs-languagetool/lsp-ltex) and it depends directly of `lsp-mode` My question is: how could I disable `eglot` when using my local files and let that `lsp-mode` takes charge of everything, BUT reverse the roles when I'm in a remote file over TRAMP and shutdown `lsp-mode` and make `eglot` the lsp manager? Is it so hard to do or not? Thanks.
fisxoj · 2022-09-28 21:31
You might need to write some elisp to check if the buffer is using tramp and then activate either eglot or lsp based on that info and then have that as a hook in whatever major mode(s) you're using. I only use eglot, so I don't know how well the two coexist in any capacity, but it sounds like an interesting project.
FreeAd7233 · 2022-09-29 09:01
If you are using own config. I think this would be trivial, a hook on tramp mode solves everything, as both LSP-mode and eglot can work locally on buffer, they can coexist perfectly. But with doom, if you want all the LSP integration with all the doom modules and it just seamlessly and dynamically choose between two LSP clients, I think this is hard. Unless you don’t use doom’s LSP module and write your own module. This is the price of using a configuration framework, powerful but less flexible. I think you can use lsp module with lsp-mode and use your own eglot configuration in tramp mode, since lsp-mode can’t work in tramp mode, I suppose doom’s LSP configuration won’t conflict with your configuration for eglot if eglot is only activated in tramp mode.