company-mode / company-quickhelp

Documentation popup for Company
GNU General Public License v3.0
374 stars 33 forks source link

Syntax highlighting #128

Closed aguynamedben closed 6 months ago

aguynamedben commented 6 months ago

I'm comparing different doc preview modes and am curious if company-quickhelp can provide better formatting and syntax highlighting similar to eldoc-box.

company-quickhelp

No syntax highlighting, no horizontal rule

image

stock eldoc buffer

Nice syntax highlighting, horizontal rule, but some goofy  's left (from Markdown?)

image

eldoc-box

Nice syntax highlighting, horizontal rule, but doesn't integrate with candidates for company, corfu, etc. Note the eldoc-box readme says they do some "pretty" preprocessing, maybe some code can be shared from that?

image

corfu-popupinfo-mode

About the same as company-quickhelp, but monospace font.

Are there any plans to improve the formatting for company-quickhelp?

aguynamedben commented 6 months ago

I'm going to close this. I think most of this nastiness was coming from PyRight language server, which seems to give back "nasty Python docstrings via plaintext" as its documentation at point.

I installed pylsp (https://github.com/python-lsp/python-lsp-server) and it's giving proper Markdown and it looks much better. Interestingly, Eglot has a feature where if you have markdown-mode installed, Eglot will use markdown-mode to clean up Markdown from the language server. But PyRight was giving back "plaintext" and it was all Python docstrings, that's why it looks so plain in company-quickhelp.

dgutov commented 6 months ago

Indeed, it sounds like eldoc and documentation buffer use different sources of information, which had different degrees of formatting applied by the first LSP server that you used.

In general, it's hard for me to say whether PyRight is misbehaving, or if this is a variant of the norm. It would be a better question for the developers of lsp-mode or eglot (whichever you are using), since those as adaptors in both cases, transforming the data.