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 not working #476

Closed
Fuco1 opened this issue May 14, 2024 · 3 comments
Closed

eldoc not working #476

Fuco1 opened this issue May 14, 2024 · 3 comments

Comments

@Fuco1
Copy link

Fuco1 commented May 14, 2024

Describe the bug
Eldoc doesn't show anything when I put cursor on a variable / symbol

lsp-mode version 9e36009adc78309954983b045068e9bd05d293c7 (latest commit as of now)
lsp-java version 37c95ef (latest commit as of now)

Note

I have made the following edit to lsp-eldoc-function to make it work. I am not sure what is the difference between lsp--capability and lsp-feature? but one returns nil and the other t

(defun lsp-eldoc-function (cb &rest _ignored)
  "`lsp-mode' eldoc function to display hover info (based on `textDocument/hover')."
  (if (and lsp--hover-saved-bounds
           (lsp--point-in-bounds-p lsp--hover-saved-bounds))
      lsp--eldoc-saved-message
    (setq lsp--hover-saved-bounds nil
          lsp--eldoc-saved-message nil)
    (if (looking-at-p "[[:space:]\n]")
        (setq lsp--eldoc-saved-message nil) ; And returns nil.
      (when (and lsp-eldoc-enable-hover
                 ;; (lsp--capability :hoverProvider)                 ;;;;; removed this and replaced with the next line
                 (lsp-feature? "textDocument/hover"))
        (lsp-request-async
         "textDocument/hover"
         (lsp--text-document-position-params)
         (-lambda ((hover &as &Hover? :range? :contents))
           (setq lsp--hover-saved-bounds (when range?
                                           (lsp--range-to-region range?)))
           (funcall cb (setq lsp--eldoc-saved-message
                             (when contents
                               (lsp--render-on-hover-content
                                contents
                                lsp-eldoc-render-all)))))
         :error-handler #'ignore
         :mode 'tick
         :cancel-token :eldoc-hover)))))

To Reproduce
With the original code, put cursor on a variable, with eldoc-mode on and lsp-managed-mode on, nothing is printed to the minibuffer.

Expected behavior
Type info is shown in the minibuffer

@yyoncho
Copy link
Member

yyoncho commented May 14, 2024

Yep, that is the correct way to test if something is supported.

@Fuco1
Copy link
Author

Fuco1 commented May 15, 2024

Thanks! Glad it works now :)

@sincebyte
Copy link

how? my emacs do not have the eldoc for a long time

cheerio-pixel pushed a commit to cheerio-pixel/lsp-mode that referenced this issue May 29, 2024
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

3 participants