joaotavora / eglot

A client for Language Server Protocol servers
GNU General Public License v3.0
2.25k stars 200 forks source link

eglot-extend-to-xref shouldn't activate Eglot in files other than the managed modes #1275

Open sg-qwt opened 1 year ago

sg-qwt commented 1 year ago

https://github.com/sg-qwt/debuglsp

  1. run nix develop to start a devshell
  2. run emacs-bad inside that devshell
  3. hover on one of the java class in the clojure file and xref-find-definitons on it
  4. in the minimal emacs eglot+clojure-lsp setup(./emacs-bad/init.el), eglot-extend-to-xref is set to t
  5. when jumped to java source, you can see eglot enabled on the destination java file even though I've got nothing setup for java lsp and with no eglot-ensure on java-mode.

I'd expect eglot-extend-to-xref shoud only work (as extend) for whatever mode I've setup for. In this case, I've only setup a hook for clojure-lsp with clojure-mode on eglot-ensure for example. But as long as I enabled eglot-extend-to-xref and jump definiton from the clojure source file to java source file, eglot is enabled(extended) to this java source file.

But that's unexpected and not desired this case: a. Because I don't have any java lsp installed and setup b. clojure-lsp won't work on java source file.

Better document why eglot-extend-to-xref would extend on unsetup mode or just let eglot-extend-to-xref extend itself to some new mode(from clojure mode to java mode this case) behave same as it'd prompt you to install java lsp as if you just open a fresh java file without setup lsp/eglot this case.

cross ref: https://github.com/clojure-lsp/clojure-lsp/issues/1656

joaotavora commented 1 year ago

I think I get it, no need to reproduce (recipes based on nix are fairly useless to me anyway).

This is unusual though, as most servers link to files in the same language. I guess some extra checks for the eglot-extend-to-xref behavior can be added.