Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

eglot only shows documentation for the function call under the cursor #1171

Closed
bit69tream opened this issue Feb 20, 2023 · 9 comments
Closed

Comments

@bit69tream
Copy link

I am using eglot that came with my emacs build (GNU Emacs 29.0.60 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.35, cairo version 1.17.6) of 2023-02-03).
I believe it should contain the last stable version of eglot.

My issue is that when I try to lookup documentation for a variable which is used as a function argument I only get documentation for that function. Doesn't matter if I just hover over it with my cursor or press the eglot-doc-buffer keybind.
20-02-23--22-25-28

So if I ever want to look at the variable(or even like an enum value, etc), I must copy its name and paste it somewhere else before I can see its docs.

Like this:
20-02-23--22-50-26

And I checked if lsp-mode can achieve what I want, and it can. So its not impossible.

@joaotavora
Copy link
Owner

This is a known problem that I've been trying to solve, but it's not incredibly easy (although it looks easy)

For now, you can do this workaround.

(add-hook 'eglot-managed-mode-hook 
          (lambda () (setq eldoc-documentation-strategy 
                           #'eldoc-documentation-compose))

It should do what you want.

It's possible or even likely that, if you're into having all possible information at point be available through ElDoc, you also want

(add-hook 'eglot-managed-mode-hook
          (lambda () (setq eldoc-documentation-functions
                           '(flymake-eldoc-function
                             eglot-signature-eldoc-function
                             eglot-hover-eldoc-function))))

Then if you happen to have some syntax error or diagnostic at point, that information will also be displayed in Eldoc outlets.

The thing is, I want you and many others to not need this workaround anymore. This eldoc-documentation-compose should be the default anyway, as it is the one which naturally provides most information. And then Eglot wouldn't need to mess with it, which is the right thing.

But if we make it the default, it has subtle implications in emacs-lisp-mode, unless we also change the default of eldoc-echo-area-use-multiline-p in Emacs Lisp mode.

This will take some discussion in the Emacs bug tracker, probably. But I think I can do part of this change soon anyway.

@joaotavora
Copy link
Owner

Related #894, #920, #648 and possibly some others.

@joaotavora
Copy link
Owner

Yep, also #1031

@6b6279
Copy link

6b6279 commented Feb 20, 2023

Does eglot set eldoc-documentation-strategy at all? Is the work-around with the hook necessary, even when the user explicitly calls (setq eldoc-documentation-strategy #'eldoc-documentation-compose) elsewhere in their init file?

@joaotavora
Copy link
Owner

Is the work-around with the hook necessary, even when the user explicitly calls (setq eldoc-documentation-strategy #'eldoc-documentation-compose) elsewhere in their init file?

Yes it is, because eglot sets it buffer-locally. Go ahead and test. But I'm about to change that, so that that very line in the init file will be enough.

Then I will argue in emacs-devel or bug-gnu-emacs that the global default for eldoc-documentation-strategy should be eldoc-documentation-compose to start with.

@joaotavora
Copy link
Owner

But that change, if it happens, is probably not going to be so sudden.

@6b6279
Copy link

6b6279 commented Feb 20, 2023

I think eglot respecting the user’s choice of eldoc-documentation-strategy is definitely a good idea. Thanks a lot for the change!

jollaitbot pushed a commit to sailfishos-mirror/emacs that referenced this issue Feb 21, 2023
This change addresses the problems reported in many Elglot reports
dating back to early 2021 at least:

  joaotavora/eglot#648
  joaotavora/eglot#894
  joaotavora/eglot#920
  joaotavora/eglot#1031
  joaotavora/eglot#1171

In one form or another, the reports point out that the multiple pieces
of information about the "thing at point" made available by the LSP
server are not all being considered by the ElDoc system.

The reason for this is Eglot setting/trampling the variables
'eldoc-documentation-strategy' and 'eldoc-documentation-functions' in
its minor more entry function.

The reason it did that is historical and is partially described in the
issues above.  But, evidently, it never made much sense, because so
many people want to override it, which requires setting
'eldoc-documentation-strategy' to the non-default value
'eldoc-documentation-compose'.

The problem was made worse by the fact that setting it as usual in
either the Customize menu or their init file didn't work, requiring a
fairly complex Elisp snippet.  That is now solved as of this commit.

If the user does not do any setting, then Eglot works basically the
same as before (i.e. shows only one piece of information).

It is arguable that the default value for
'eldoc-documentation-strategy' should change globally to
'eldoc-documentation-compose', but that has other subtle implications
and is not part of this commit.

* lisp/progmodes/eglot.el (eglot--managed-mode): Don't set Eldoc
variables greedily.
@bit69tream
Copy link
Author

@joaotavora Thanks for the solution, everything works now!

@joaotavora
Copy link
Owner

Thanks. By the way, this should have been a discussion, not an issue report. Moving to discussion.

Repository owner locked and limited conversation to collaborators Feb 21, 2023
@joaotavora joaotavora converted this issue into discussion #1173 Feb 21, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants