Eglot-java would not start when open java file
eugeneandrienko opened this issue · 3 comments
Eglot and eglot-java didn't start when I open any file with java source code from my project.
Steps to reproduce:
- Install eglot and eglot-java
- Go to folder with java project and open any java file
- Got message:
File mode specification error: (wrong-type-argument consp nil)
- Eclipse Java Language Server didn't installs automatically.
Emacs 28.2
Eglot 1.10
Eglot-java 20221218.1809 from MELPA
Му configuration:
(use-package eglot)
(use-package eglot-java
:requires eglot
:config
(progn
(add-hook 'java-mode-hook 'eglot-java-mode)))
I found (via M-x toggle-debug-on-error
) what problem also reproduces, when I call M-x eglot-java-mode
after open the java file.
Debugger entered--Lisp error: (wrong-type-argument consp nil)
eglot-java--init()
eglot-java-mode(toggle)
funcall-interactively(eglot-java-mode toggle)
call-interactively(eglot-java-mode record nil)
command-execute(eglot-java-mode record)
execute-extended-command(nil "eglot-java-mode" "eglot-java-m")
funcall-interactively(execute-extended-command nil "eglot-java-mode" "eglot-java-m")
call-interactively(execute-extended-command nil nil)
command-execute(execute-extended-command)
I've made a little research and found the roots of problem.
Don't know how, but in ELPA there is a eglot version "from future". Depending on releases, commits and issues from the joaotavora/eglot, the latest official version of eglot is 1.9.
But in ELPA there is a version 1.10!
In sources of that version, which I got when installing eglot-1.10, record about Java in eglot-server-programs
is the next:
((java-mode java-ts-mode)
"Initialize the library for use with the Eclipse JDT language server."
"jdtls")
In sources of eglot from official GitHub-repositry that record differs:
(java-mode . ("jdtls"))
And, of course eglot-java fails when eglot-java--init
tried to find 'java-mode
record, which is not exists in eglot-1.10.
When I removed that version of eglot "from future" and install the normal eglot 1.9 — eglot-java works correctly!
Thanks for reporting this issue.
I think that it's a valid concern though, as there could be several java-related modes associated to eglot
and the "version of the future" will eventually become "actual" for everyone (including on MELPA
).
eglot
upstream could make any changes related to those modes: a new hypothetical "java-ex-mode" could be added and then this package would just break again. I had never heard aboutjava-ts-mode
until today...- users might have their own customization of java-related modes (known modes or homegrown modes)
Here's what will be implemented for mitigation
eglot-java
will account for the fact that there could be multiple java-related mode associations ineglot
:eglot-java
will manageeglot
initialization for java-related modes found ineglot-server-programs
- users are still expected to register java related modes that they care about through a
eglot-java-mode-hook
(java-ts-mode
or anything other java editing mode).
- a new flag
eglot-java-eglot-server-programs-manual-updates
will allow further user control:- By default the flag is set to false and can be changed via
M-x customize-variable
- If one day upstream
eglot
changes drastically how it initializes LSP servers, users might still be able to update their configuration without waiting for this package to catch up. - If you have a heavily customized
eglot
configuration, you might not necessarily wanteglot-java
to "magically" updateeglot-server-programs
behind the scenes.
- By default the flag is set to false and can be changed via