-
Notifications
You must be signed in to change notification settings - Fork 199
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
Truncate hovering information in echo area #111
Conversation
This appears to be related to #97. Both issues are on my radar, though I've been very busy lately. Thanks. |
5c7207a
to
a7566a6
Compare
The string passed to eldoc-message needs to be truncated, otherwise eldoc-last-message will be displayed with multiple lines.
a7566a6
to
dd45f05
Compare
@joaotavora are you interested in this patch, or should I close it? |
I don't know yet, but leave it open. |
Okay, so the current behavior keeps annoying me. I'm not sure if it's a problem with other servers, but with python I think it is. When you hover a module, you get the entire docstring of the module printed in the echo area, which is sometimes rather long. If this docstring doesn't fit, you can only see the last part of it. When navigating through the code, the echo area jumps a lot, which is distracting. If I want to see the entire documentation, I prefer to call How about adding a variable
And replacing Then I can have in my own config (or the function may be suitable to have in eglot)
and It would also be easier to display hover information with tooltips, if some users prefer that. |
@fbergroth Take a look here, maybe it will be helpful. #112 (comment)
Looks like there's interest in other display mechanisms. I personally have |
Thanks, that lead me to |
Hi @fbergroth, sorry for being so late to the party. I had a look at the problem and this indeed as @mkcms says, it looks like something that could be made with
Furthermore, you probably want to do this only when Eglot is active, right? For now you probably need to use Also, can you post a screenshot or describe in some more detail exactly what the bother is with the jumping eldoc? Perhaps you could do something like @casouri does in https://github.com/casouri/eglot-doc, but simpler, and completely based on |
Sure, here's a gif demonstrating the hovering docs being cut off. On a larger display, the echo area takes up a lot more space, and is appearing/disappearing ("jumping") a lot as you navigate through the code. |
Really? |
Yes really :-) In lisp, we rather look at it as a symbol which has a variable binding to some value. In this case Emacs guarantees that type of that value is a function (named or unnamed, doesn't matter). So you can use Try this in your python mode buffers (add-function :around (local 'eldoc-message-function)
(lambda (oldfun format-string &rest args)
(if-let (frame (and
(string-match "\n" format-string)
(cdr (assoc "*eldoc frame*" (make-frame-names-alist)))))
(with-selected-frame frame
(delete-other-windows)
(with-current-buffer (get-buffer-create " *eldoc big doc*")
(erase-buffer)
(insert (apply #'format format-string args))
(switch-to-buffer (current-buffer))))
(apply oldfun args)))
'((name . joaot/use-separate-frame-maybe))) Won't do anything unless the frame exists, which you can make with
If you are using If you are using (add-function :before-until (local 'eldoc-message-function)
(lambda (format-string &rest args)
(when-let (frame (and
(string-match "\n" format-string)
(cdr (assoc "*eldoc frame*" (make-frame-names-alist)))))
(with-selected-frame frame
(delete-other-windows)
(with-current-buffer (get-buffer-create " *eldoc big doc*")
(erase-buffer)
(save-excursion (insert (apply #'format format-string args)))
(switch-to-buffer (current-buffer))))))
'((name . joaot/use-separate-frame-maybe))) Anyway:
|
Thanks for the detailed answer. I learned something new :-) Just to make it clear, I don't want a frame that displays documentation during hover. I would find that as distracting as eldoc being hammered with pages of text. I do think that eglot should support a lighter variant of hover documentation, instead of passing the entire thing (my suggestion is still to only display the first line with |
You're welcome.
But am I mistaken in thinking this is something you would want for any eldoc thing, and not necessarily related to eglot? If I'm not, then you should request that option of eldoc, i.e. Emacs itself. Use |
I've only encountered this in eglot, so I'm not sure if it applies elsewhere. Also as I mentioned in my first post, I only want this for hovering, not for signatureHelp, so some change would have to bemade in eglot. Maybe it's not worth fixing unless more people find it distracting. |
By your description, it applies to every user of eldoc that uses it to issue longer-than-one-line messages.
So if a signatureHelp is longer than one line that's OK?
You can M-x report-emacs-bug anyway. |
I guess the modes that I've previously used only sent short text to eldoc, or it was customizable (i.e.
Yeah, for most cases I just see two lines here, the first being the function signature, and the latter information about the parameter I'm about to type. I think that's sensible. |
I added a commit to eldoc-box(eglot-doc) so you can chose to leave one line messages in minibuffer and display multi-line messages in childframe. Basically that leaves function signatures in minibuffer and documentations in childframe. Maybe that's something you want? |
@casouri eldoc-box looks very nice! For some reason child frames causes my emacs to flicker, but I'll probably dig into why, since I'd like to use eldoc-box. I don't think I'd use |
Yes, I tried it too. It's a very good first start. It's kind of unusably slow on Windows, but that's probably fixable. Why does one have to close the new frame everytime? There are some mentions of |
Does this fix it?
That can be changed to
I went to lsp-ui-doc.el and copied a bunch of code. Is there anything I need to do? |
Cool.
Well IANAL, but there's a bit there at the top that says that the code is your copyright... |
Oops! I'll remove that... That's embarrassing... |
Don't worry too much, just add your name to the old copyright notice. We
can evaluate later if that's a problem for integrating into ELPA or
something like that
On Dec 11, 2018 20:44, "Yuan Fu" <notifications@github.com> wrote:
Oops! I'll remove that... That's embarrassing...
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#111 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAXnwziw4QdWnDdpVR1zSj7xRzGOHk9wks5u4BkxgaJpZM4WlKEi>
.
|
@fbergroth @joaotavora I've fixed the lagging and flicker problem and the copyright portion. It runs smoothly on my machine, could you give another try and see if it works? There are another problem, though, if you have time and interest, could you have a look at casouri/eldoc-box#1 ? |
Currently, hovering symbols with multiple lines of hover-info makes the echo area jump around a bit much.
I'm not sure if this should be customizable, we could check
eldoc-echo-area-use-multiline-p
, but I'd like this behavior only for hovering, and not for signatureHelp.