Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eldoc signatures still not working in Java #481

Open
sdhoward opened this issue Jun 24, 2024 · 2 comments
Open

eldoc signatures still not working in Java #481

sdhoward opened this issue Jun 24, 2024 · 2 comments

Comments

@sdhoward
Copy link

Describe the bug

I have Emacs 29.3 on MacOS, and lsp-java 20240524.2207 installed from Melpa.

Within the past year, perhaps in an older Emacs or an older lsp-mode, the type signature of the Java variable or method would appear, in the fixed-pitch font, in the minibuffer, when the cursor was over the function name. There was no mouse hovering or UI involved.

In fact, I still have this behavior in lsp-mode for Golang variables and functions. A screenshot is attached. If I set lsp-eldoc-enable-hover to nil, the behavior in Golang mode becomes disabled. So I think this feature is related to eldoc.

I read one recent bug report and I installed the fixed version that was released and it's not resolving my issue.

Please help to point out which setting re-enables this, or whether a regression has appeared. Thanks.

To Reproduce

The simple init.el that I use to reproduce this is:

(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(package-initialize)

(custom-set-variables
 ;; custom-set-variables was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(package-selected-packages '(go-mode lsp-java)))
(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 )

Screenshots

Screenshot 2024-06-23 at 00 39 28

^ the signatures appear in go-mode but not java-mode

@Horrih
Copy link

Horrih commented Jul 31, 2024

I am encountering this issue as well.

Turning off textDocument/hover dynamicRegistration works around the issue

I investigated a bit, comparing eglot (where it works)/lsp-mode (where is does not) : The main difference I saw was that lsp-mode declares textDocument/hover with dynamicRegistration: true where as eglot sets it to nil.

Setting this in lsp-mode.el : `lsp--client-capabilities()' to t seems to fix the issue for me.

 (hover . ((contentFormat . ["markdown" "plaintext"])
               (dynamicRegistration . nil)))

Speculation for a durable fix.

My guess would be that with dynamic registration, lsp-mode is notified too late that the server supports hover.

lsp-mode seems to enable eldoc at startup only, when `lsp-managed-mode' is turned on.

(when (lsp-feature? "textDocument/hover")
      (add-hook 'eldoc-documentation-functions #'lsp-eldoc-function nil t)
      (eldoc-mode 1))

With dynamic registration, I guess it would have to be turned on when receiving the message instead of at startup time ?

@yyoncho , would you have some advice on how to proceed with this ?

@sdhoward
Copy link
Author

I appreciate the workaround. I edited the file in my melpa directory and byte-compiled it again. Works well.

I forgot to include which version of jdtls I'm on - right now it's 1.37.0. I don't know which version I had when it was working. Did the behavior change from a previous version of jdtls?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants