Replies: 11 comments 18 replies
-
Maybe it doesn't work because I use eglot-java, it passes its own options: https://github.com/yveszoundi/eglot-java/blob/main/eglot-java.el#L146 |
Beta Was this translation helpful? Give feedback.
-
I didn't know such a large package existed, but I'd just like to say
it's not an official package, I can't recommend it. As far as I know
everything needed to support LSP jdtls is in eglot.el.
Have you read:
https://joaotavora.github.io/eglot/#Advanced-server-configuration ?
João
…On Thu, May 11, 2023 at 9:22 AM Pär Bohrarper ***@***.***> wrote:
Maybe it doesn't work because I use eglot-java, it passes its own options:
https://github.com/yveszoundi/eglot-java/blob/main/eglot-java.el#L146
—
Reply to this email directly, view it on GitHub
<#1222 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAC6PQYRHI53FLSSA3IUBQTXFSOSTANCNFSM6AAAAAAX5H4OSM>
.
You are receiving this because you are subscribed to this thread.
|
Beta Was this translation helpful? Give feedback.
-
I guess all the stuff I found in forums was outdated. After reading that I tried doing this:
It seems to get sent correctly looking at the eglot logs, but jdtls still formats the same way. |
Beta Was this translation helpful? Give feedback.
-
Many servers don't document exactly the form of :initializationOptions
they support, if any. I suggest you contact the server developers to
know if and how :initializationOptions is supported.
You can also try command-line options too to configure a server
as suggested in "5.2 User-specific configuration" of the Eglot manual.
What to pass there? Maybe
https://github.com/eclipse/eclipse.jdt.ls#running-from-the-command-line
holds clues.
João
|
Beta Was this translation helpful? Give feedback.
-
I think this is related to #1197 (reply in thread) eglot sends empty |
Beta Was this translation helpful? Give feedback.
-
On Thu, May 11, 2023 at 12:53 PM zsxh ***@***.***> wrote:
I think this is related to #1197 (reply in thread)
eglot sends empty didChangeConfiguration to jdtls.
I don't see the relation, can you clarify?
Also didChangeConfiguration is for project-specific
server configuration. Here there is no want for
project specific server configuration -- as far as I can
tell -- rather user-specific configuration
The manual also explains how to to do project-specific
server configuration.
João
|
Beta Was this translation helpful? Give feedback.
-
Yes, I confirm that it's related to (package-initialize)
(global-company-mode)
(yas-global-mode)
(require 'eglot)
(add-to-list
'eglot-server-programs
`(java-mode . ("jdtls"
:initializationOptions
(:settings
(:java
(:completion (:guessMethodArguments t)))
:extendedClientCapabilities (:classFileContentsSupport t)))))
import java.util.ArrayList;
import java.util.List;
/**
* Abc
*/
public class Abc {
public static void main(String[] args) {
String txt = "txt";
List<String> alist = new ArrayList<>();
alist // type dot to trigger completion
}
} open Abc.java, M-x eglot, you can see logs like this:
alist trigger completion When I prevent sending empty didChangeConfiguration, config works fine to me. ;; NOTE: hack workspace/didChangeConfiguration
(define-advice eglot-signal-didChangeConfiguration (:override (server) override)
"Send a `:workspace/didChangeConfiguration' signal to SERVER.
When called interactively, use the currently active server"
(interactive (list (eglot--current-server-or-lose)))
(when-let ((settings (eglot--workspace-configuration-plist server)))
(jsonrpc-notify
server :workspace/didChangeConfiguration
(list :settings settings)))) |
Beta Was this translation helpful? Give feedback.
-
On Thu, May 11, 2023 at 1:50 PM zsxh ***@***.***> wrote:
Yes, I confirm that it's related to didChangeConfiguration.
No, there's absolutely no relation to the link comment
you posted. It would be the same as saying my
washing machine's manual and Mozart's opera are related
because they're both written in German.
:initializationOptions is NOT the same as "workspace
configuration". Please read the manual link I posted.
I just know it is possible to configure servers in two
fundamentally different ways, project-specific and
user-specific, as described in the manual. It shouldn't
-- in theory -- need any hacks.
If user-specific configuration that this OP is trying
to achieve is not supported by jdtls server and only
project-specific configuration is absolutely required
for the jdtls server in particular -- that's for the jdtls
devs to clarify. If that's the case then, again, the manual has
information of how to do that.
João
|
Beta Was this translation helpful? Give feedback.
-
@zsxh I'm sorry if that's what you meant by the relation between user-specific and project-specific configuration. |
Beta Was this translation helpful? Give feedback.
-
I didn't know about this fix; I meant all of this: (define-advice eglot-signal-didChangeConfiguration (:override (server) override)
"Send a `:workspace/didChangeConfiguration' signal to SERVER.
When called interactively, use the currently active server"
(interactive (list (eglot--current-server-or-lose)))
(when-let ((settings (eglot--workspace-configuration-plist server)))
(jsonrpc-notify
server :workspace/didChangeConfiguration
(list :settings settings)))) I've had this enabled since I commented and it hasn't caused any issues. I just tried your suggestion of Caveat lector I haven't looked into any of this deeply enough to see why these configuration snippets would or wouldn't work, I was just looking through the issue tracker and these discussions trying to see if I could find hints on configuring the |
Beta Was this translation helpful? Give feedback.
-
As I went through all that trouble and learned a lot from this thread and others, let me try to summarize my solution:
(add-to-list
'eglot-server-programs
`((java-mode hk-java-mode)
.
("jdtls"
:initializationOptions
(:settings
(:java
(:format (:enabled t :profile "harald-variant" :settings (:url "/home/harald/.emacs.d/eclipse-formatter.xml"))
:settings (:url "/home/harald/.emacs.d/eclipse-settings.prefs")
)))))) The details of how to structure the lispified JSON are documented, though it is no doubt a painful to piece it together from all those interfaces, not the least because a For better control I also did this:
#!/bin/bash
# points to my current used version of jdt.ls
JDTLS=$(readlink -f ~/tools/Store/jdt-language-server)
VERSION=${JDTLS#*-server-}
# set it explicitly to be sure you know where this all ends up
DATA=~/work/jdtls-data
#DEBUG="-agentlib:jdwp=transport=dt_socket,address=127.0.0.1:8888,server=y,suspend=n"
#TRACE=-Djdt.ls.debug=true
cd "$DATA"
exec -a "jdtls($VERSION): java" java \
-Declipse.application=org.eclipse.jdt.ls.core.id1 \
-Dosgi.bundles.defaultStartLevel=4 \
-Declipse.product=org.eclipse.jdt.ls.core.product \
-Dlog.level=ALL \
$DEBUG $TRACE \
-Xmx1G \
--add-modules=ALL-SYSTEM \
--add-opens java.base/java.util=ALL-UNNAMED \
--add-opens java.base/java.lang=ALL-UNNAMED \
-jar "$JDTLS/plugins/org.eclipse.equinox.launcher_"*.jar \
-configuration "$JDTLS/config_linux" \
-data "$DATA" The script assumes that you have set up the JDK you want to use in your
|
Beta Was this translation helpful? Give feedback.
-
I've tried a bunch of different ways i found in old issues/discussions to set the
java.format.settings.url
andjava.format.settings.profile
settings, but I can't get it to work. How do I do it?Beta Was this translation helpful? Give feedback.
All reactions