unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#69989: [PATCH] Fix invocation of Java Language Server
@ 2024-03-24 20:34 Philip Kaludercic
  2024-03-24 20:45 ` Philip Kaludercic
  2024-03-24 21:35 ` Felician Nemeth
  0 siblings, 2 replies; 4+ messages in thread
From: Philip Kaludercic @ 2024-03-24 20:34 UTC (permalink / raw)
  To: 69989; +Cc: João Távora

[-- Attachment #1: Type: text/plain, Size: 582 bytes --]

It appears that the Java Language Server "jdtls" unfortunately requires
a "-data" flag to be passed along with some directory to function
properly.  Otherwise it fails or only provides primitive syntax
checking, and no completion or other warnings.  This was discussed on
the Eglot issue tracker [0].

The following patch would invoke the server properly, passing
project-specific cache directory for the program to use.  I use
`xdg-cache-home' to determine what directory to use, but didn't want to
load it at the top of the file.  Are there any strong opinions on that
question?


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: [PATCH] Fix invocation of Java Language Server --]
[-- Type: text/x-patch, Size: 2042 bytes --]

From dae847f979084134effa256b95de7219c1d5dbf6 Mon Sep 17 00:00:00 2001
From: Philip Kaludercic <philipk@posteo.net>
Date: Sun, 24 Mar 2024 21:26:08 +0100
Subject: [PATCH] Fix invocation of Java Language Server

* lisp/progmodes/eglot.el (eglot-server-programs): Invoke
"jdtls" with a "-data" flag, passing a project-specific cache
directory.
---
 lisp/progmodes/eglot.el | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index f341428cac3..f2298b2e079 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -226,6 +226,7 @@ eglot-alternatives
                       when probe return (cons probe args)
                       finally (funcall err)))))))
 
+(declare-function xdg-cache-home "xdg" ())
 (defvar eglot-server-programs `(((rust-ts-mode rust-mode) . ("rust-analyzer"))
                                 ((cmake-mode cmake-ts-mode) . ("cmake-language-server"))
                                 (vimrc-mode . ("vim-language-server" "--stdio"))
@@ -264,7 +265,13 @@ eglot-server-programs
                                  . ("gopls"))
                                 ((R-mode ess-r-mode) . ("R" "--slave" "-e"
                                                         "languageserver::run()"))
-                                ((java-mode java-ts-mode) . ("jdtls"))
+                                ((java-mode java-ts-mode) .
+                                 ,(lambda (_interactive project) ;see github#1008
+                                    (require 'xdg)
+                                    (let ((cache (file-name-concat
+		                                  (xdg-cache-home) "jdtls-cache"
+		                                  (sha1 (project-root project)))))
+                                      (list  "jdtls" "-data" cache))))
                                 ((dart-mode dart-ts-mode)
                                  . ("dart" "language-server"
                                     "--client-id" "emacs.eglot-dart"))
-- 
2.39.2


[-- Attachment #3: Type: text/plain, Size: 242 bytes --]


Oh and this patch uses functions that are not available in Emacs 26.3,
so it would make sense to apply my patch that adds Compat support to
Eglot first.

[0] https://github.com/joaotavora/eglot/issues/1008

-- 
	Philip Kaludercic on icterid

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-03-25  7:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-24 20:34 bug#69989: [PATCH] Fix invocation of Java Language Server Philip Kaludercic
2024-03-24 20:45 ` Philip Kaludercic
2024-03-24 21:35 ` Felician Nemeth
2024-03-25  7:11   ` Philip Kaludercic

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).