When thanks to its developers I added support for jdtls
in
Eglot, I did it by
removing a lot of boilerplate in the package devised to accommodate the complex
setup needed for Eclipse JDT to start the language server. This made the
java-mode
entry in eglot-server-programs
simpler and it also moved the
responsibility of providing the correct defaults to the jdtls
script itself.
However, recent versions of jdtls
seem to still require extra configuration,
in particular with regards to the -data
argument that before my change was
tweaked within Eglot.
Understandably, Eglot’s maintainer cannot spend all his time hunting down random
quirks for every LSP server out
there.
Therefore, it’s up to the users to update their configuration at least until
jdtls
takes care of this
problem once and for
all.
The small hack I added to my init.el
is the following:
(with-eval-after-load 'eglot
(let ((cache (expand-file-name (md5 (project-root (project-current t)))
(locate-user-emacs-file "jdtls-cache"))))
(add-to-list 'eglot-server-programs `(java-mode "jdtls" "-data" ,cache))))
The above snippet works fine with the latest jdtls
(as of 2022-08-11 14:25)
and OpenJDK 18.0.2-ea. I updated the relevant Eglot
discussion as well, so
refer to it if you need more details.