casouri / eldoc-box

childframe doc for eglot and anything that uses eldoc
360 stars 26 forks source link

word wrapping #28

Closed andreyorst closed 2 years ago

andreyorst commented 4 years ago

More like a question, but can wrapping be enabled for eldoc-box?

I want to restrict maximum width to around 600px, an right now words are being wrapped at the middle:

 ___________________
|long line of arbitr|
|ary text           |

I think it would be better to wrap on words, rahter than on chars:

 ___________________
|long line of       |
|arbitrary text     |

I think this could be acheived by using visual line mode, but I don't quite get how to enable it for eldoc

casouri commented 4 years ago

Have you tried eldoc-box-max-pixel-width?

andreyorst commented 4 years ago

well, that's what I was talking about. If I set it to 600px long lines wrap character wise, while it would be better to do word wide wrapping.

вт, 24 мар. 2020 г., 19:18 Yuan Fu notifications@github.com:

Have you tried eldoc-box-max-pixel-width?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/casouri/eldoc-box/issues/28#issuecomment-603340570, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEUROT4ONGUI72O6R2QQOSTRJDMLTANCNFSM4LSRETAA .

casouri commented 4 years ago

Ah, I see. I would try

(add-hook 'eldoc-box-buffer-hook (lambda () (unless word-wrap (toggle-word-wrap))) nil t)
andreyorst commented 4 years ago

It seems it prevents eldoc box from appearing

casouri commented 4 years ago

I made a mistake, it should be

(add-hook 'eldoc-box-buffer-hook (lambda () (unless word-wrap (toggle-word-wrap))) nil t)

It doesn't make sense to add the hook locally.

However, that mistake shouldn't prevent the childframe from appearing. FWIW, I tried the snippet and it seems to work. I couldn't think of a source of your problem on top of my head.

andreyorst commented 4 years ago

these hooks are the same, so I think you've meant:

(add-hook 'eldoc-box-buffer-hook (lambda () (unless word-wrap (toggle-word-wrap))))

This works. Thanks!

yvesnrb commented 2 years ago

The solution posted by @andreyorst works great for word wrapping, thank you!

Just a minor annoyance that is probably not worth opening a new issue over: the arrows that indicate wrapping are getting squished at the edges of the window. Like this:

image

Also consider making word wrapping the default.

casouri commented 2 years ago

Yeah I can fix that. Added to todo ; )

casouri commented 2 years ago

I pushed a change that enables visual-line-mode in child frame, give it a try :-)

yvesnrb commented 2 years ago

I got rid of the hook function suggested earlier and indeed we are still wrapping at word boundaries, as per visual-line-mode. There are no more squished arrows either. Looks great to me!

image