emacs-lsp / lsp-ui

UI integrations for lsp-mode
https://emacs-lsp.github.io/lsp-ui
GNU General Public License v3.0
1.04k stars 139 forks source link

Problem with display-line-number on emacs -nw or emacs-nox (no window) #489

Closed apiraino closed 3 years ago

apiraino commented 4 years ago

Hi,

I use emacs 26.3 without graphical environment, have the Ubuntu emacs-nox package which basically corresponds to running emacs -nw. I've realized that lsp-ui is not looking great without GUI, the sideline is broken (while lsp-ui works perfectly on stardard graphical emacs). See here:

recording

I'm running lsp-ui without any customization or setq parameter, just installed and activated it.

Is there any configuration I can try to fix this? Perhaps somewhere there is

thanks

sebastiencs commented 4 years ago

@apiraino In terminals, lsp-ui can't use child frames, which is used in GUI. In terminals the implementation is based on overlay.

the sideline is broken

I think you're referring to lsp-ui-doc from you gif, but the gif is too fast I can't really see what/where is it broken.

In my terminal it renders like this:

image

Do you have a different result with your config ? What configuration would make your experience better ? Setting a maximum width and height ?

apiraino commented 4 years ago

ah thanks a lot @sebastiencs for the hints and corrections! Now I'm starting to understand how it is supposed to work.

So, here is a more meaningful description of what happens. The doc overlay is too wide and each line of the documentation is cut in two lines (notice the \ char at the end of each line).

I also suspect the documentation rendering is broken: what do I need to install to properly render the docs without using webkit?

The funny thing is that no matter my shell width, the overlay shows this behaviour. If I enlarge the shell, the overlay alignment gets fixed, but if I move back and forth triggering the doc overlay, it always appears broken until I resize the shell window. See this behaviour in this GIF (~5mb):

recording

I've tried fiddling with some settings (quasi-randomly changing stuff), trying to force a different behaviour but I didn't see anything different

 '(lsp-ui-doc-alignment (quote window))
 '(lsp-ui-doc-border "red")
 '(lsp-ui-doc-header t)
 '(lsp-ui-doc-max-height 10)
 '(lsp-ui-doc-max-width 50)
 '(lsp-ui-doc-position (quote top))
 '(lsp-ui-doc-use-childframe nil)
sebastiencs commented 4 years ago

@apiraino You most likely have a configured variable that lsp-ui doesn't take into account. Can you try to disable your customization/packages and found what cause that issue

apiraino commented 3 years ago

@sebastiencs I've finally had time to dig this issue to the bottom and understand the reason behind.

This line in my custom.el breaks the UI

'(display-line-numbers t)

if I comment this line everything goes in place and the documentation UI looks fine.

Armed with this new knowledge now I see there is a number of issues correlated.

Currently I have Emacs 27.1 and lsp-ui 20201209.332 from melpa but the issue still persists. I have also tried the suggestion in #380 and add the hook in my lsp-ui initialization (which I don't understand what it does), but it didnt work (or I wrote it wrong):

(use-package lsp-ui
  :init
   ...
  (add-hook 'lsp-ui-doc-frame-mode-hook #'(lambda()(display-line-numbers-mode -1)))
  :commands lsp-ui-mode)

Still a problem on my end to investigate or could still be an issue with the display line number? I run emacs -nw so my config could be slightly more problematic...

thanks

apiraino commented 3 years ago

closing because I failed to isolate/fix the issue and now cant repro anymore