From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.bugs Subject: bug#69989: [PATCH] Fix invocation of Java Language Server Date: Sun, 24 Mar 2024 20:34:26 +0000 Message-ID: <87y1a78j3h.fsf@posteo.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="27145"; mail-complaints-to="usenet@ciao.gmane.io" Cc: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= To: 69989@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Mar 24 21:36:38 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1roUa3-0006o3-NP for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 24 Mar 2024 21:36:35 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1roUZq-000253-Kn; Sun, 24 Mar 2024 16:36:22 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1roUZp-00024v-ED for bug-gnu-emacs@gnu.org; Sun, 24 Mar 2024 16:36:21 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1roUZp-0003CB-63 for bug-gnu-emacs@gnu.org; Sun, 24 Mar 2024 16:36:21 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1roUaU-0002P9-LD; Sun, 24 Mar 2024 16:37:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Philip Kaludercic Original-Sender: "Debbugs-submit" Resent-CC: joaotavora@gmail.com, bug-gnu-emacs@gnu.org Resent-Date: Sun, 24 Mar 2024 20:37:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 69989 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org X-Debbugs-Original-Xcc: =?UTF-8?Q?Jo=C3=A3o_?= =?UTF-8?Q?T=C3=A1vora?= Original-Received: via spool by submit@debbugs.gnu.org id=B.17113125659162 (code B ref -1); Sun, 24 Mar 2024 20:37:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 24 Mar 2024 20:36:05 +0000 Original-Received: from localhost ([127.0.0.1]:47460 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1roUZY-0002Nh-Em for submit@debbugs.gnu.org; Sun, 24 Mar 2024 16:36:04 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:50096) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1roUZT-0002NG-DP for submit@debbugs.gnu.org; Sun, 24 Mar 2024 16:36:03 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1roUYn-0001ua-55 for bug-gnu-emacs@gnu.org; Sun, 24 Mar 2024 16:35:17 -0400 Original-Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1roUYk-0002zO-VC for bug-gnu-emacs@gnu.org; Sun, 24 Mar 2024 16:35:16 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id BEC27240028 for ; Sun, 24 Mar 2024 21:35:08 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1711312508; bh=zc7jkoplGzodrl9j5IJ+3TSPq/Q9PyHOfK0geNqoB8s=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=LWpMSDCec5eSZG2+OKhamGdVkBY2r+9KlyMuntEP6yOz87R7Dz2PlumT3HT5I2jn9 W3iyUUS9bRkTopy+x7UNxKluMlJLjJ+7mxzazwBk87jethqM8oS9FwxAHXRqeASkkY OeOoIqPbeh1EFxb0W2OxiBKIEkwM8XRutHnuBMIegXCBnS1tZ5XQi63tUAc4GnGjhT wl8JDxxYXVFi1Vs5NIWbVOY9OyVevnzAUUATo5Ngiuzahe++ckwPtkeZAqvp5ehauS kin3ETHborXavgswq57udkano3Gn4+kNx7ACBL6ahGG+R3IKzh/qT65HgP1+AA0EJH 2nQVo4K6m9Nwg== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4V2nqw0pQWz6tvh for ; Sun, 24 Mar 2024 21:35:07 +0100 (CET) X-Hashcash: 1:20:240324:bug-gnu-emacs@gnu.org::8glFO+QRq+tDHsNO:0EQZ Received-SPF: pass client-ip=185.67.36.65; envelope-from=philipk@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:282034 Archived-At: --=-=-= Content-Type: text/plain 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? --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Fix-invocation-of-Java-Language-Server.patch Content-Description: [PATCH] Fix invocation of Java Language Server >From dae847f979084134effa256b95de7219c1d5dbf6 Mon Sep 17 00:00:00 2001 From: Philip Kaludercic 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 --=-=-= Content-Type: text/plain 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 --=-=-=--