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

* bug#69989: [PATCH] Fix invocation of Java Language Server
  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
  1 sibling, 0 replies; 4+ messages in thread
From: Philip Kaludercic @ 2024-03-24 20:45 UTC (permalink / raw)
  To: 69989; +Cc: João Távora

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

Philip Kaludercic <philipk@posteo.net> writes:

> 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.

Apparently my patch did not arrive on the mailing list, so I am
attaching it again here:


[-- Attachment #2: 0001-Add-Compat-as-an-Eglot-dependency.patch --]
[-- Type: text/x-diff, Size: 2355 bytes --]

From 8c1613a500a617c72b49905968c04e855fee9ee5 Mon Sep 17 00:00:00 2001
From: Philip Kaludercic <philipk@posteo.net>
Date: Sat, 9 Mar 2024 08:11:03 +0100
Subject: [PATCH] Add Compat as an Eglot dependency

* lisp/progmodes/eglot.el (eglot--format-markup): Remove fboundp
check for 'text-property-search-forward'.

Additionally this should make 'package-get-version' available
for releases of Emacs previous to 27.1.  (bug#62198)
---
 lisp/progmodes/eglot.el | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el
index 50820e81107..62606d8dbb2 100644
--- a/lisp/progmodes/eglot.el
+++ b/lisp/progmodes/eglot.el
@@ -7,7 +7,7 @@
 ;; Maintainer: João Távora <joaotavora@gmail.com>
 ;; URL: https://github.com/joaotavora/eglot
 ;; Keywords: convenience, languages
-;; Package-Requires: ((emacs "26.3") (jsonrpc "1.0.24") (flymake "1.2.1") (project "0.9.8") (xref "1.6.2") (eldoc "1.14.0") (seq "2.23") (external-completion "0.1"))
+;; Package-Requires: ((emacs "26.1") (jsonrpc "1.0.24") (flymake "1.2.1") (project "0.9.8") (xref "1.6.2") (eldoc "1.14.0") (seq "2.23") (external-completion "0.1") (compat "27.1"))
 
 ;; This is a GNU ELPA :core package.  Avoid adding functionality
 ;; that is not available in the version of Emacs recorded above or any
@@ -110,6 +110,7 @@
 (require 'text-property-search nil t)
 (require 'diff-mode)
 (require 'diff)
+(require 'compat)
 
 ;; These dependencies are also GNU ELPA core packages.  Because of
 ;; bug#62576, since there is a risk that M-x package-install, despite
@@ -1831,10 +1832,9 @@ eglot--format-markup
         (font-lock-ensure)
         (goto-char (point-min))
         (let ((inhibit-read-only t))
-          (when (fboundp 'text-property-search-forward) ;; FIXME: use compat
-            (while (setq match (text-property-search-forward 'invisible))
-              (delete-region (prop-match-beginning match)
-                             (prop-match-end match)))))
+          (while (setq match (text-property-search-forward 'invisible))
+            (delete-region (prop-match-beginning match)
+                           (prop-match-end match))))
         (string-trim (buffer-string))))))
 
 (defun eglot--read-server (prompt &optional dont-if-just-the-one)
-- 
2.44.0


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


-- 
	Philip Kaludercic on icterid

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

* bug#69989: [PATCH] Fix invocation of Java Language Server
  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
  1 sibling, 1 reply; 4+ messages in thread
From: Felician Nemeth @ 2024-03-24 21:35 UTC (permalink / raw)
  To: Philip Kaludercic; +Cc: João Távora, 69989

> 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].

I don't use jdtls, but it seems the upstream fixed this issue and there
is no need to modify Eglot.

https://github.com/eclipse-jdtls/eclipse.jdt.ls/pull/2207
https://github.com/eclipse-jdtls/eclipse.jdt.ls/commit/b93370662a8e4e552dc2af162eb9510b276e0203





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

* bug#69989: [PATCH] Fix invocation of Java Language Server
  2024-03-24 21:35 ` Felician Nemeth
@ 2024-03-25  7:11   ` Philip Kaludercic
  0 siblings, 0 replies; 4+ messages in thread
From: Philip Kaludercic @ 2024-03-25  7:11 UTC (permalink / raw)
  To: Felician Nemeth; +Cc: João Távora, 69989-done

Felician Nemeth <felician.nemeth@gmail.com> writes:

>> 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].
>
> I don't use jdtls, but it seems the upstream fixed this issue and there
> is no need to modify Eglot.
>
> https://github.com/eclipse-jdtls/eclipse.jdt.ls/pull/2207
> https://github.com/eclipse-jdtls/eclipse.jdt.ls/commit/b93370662a8e4e552dc2af162eb9510b276e0203

Turns out I had an older installation of jdtls.  I have upgraded it and
can confirm that it works without the patch.  So I'll be closing this
report.

-- 
	Philip Kaludercic on icterid





^ permalink raw reply	[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).