casouri / eldoc-box

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

Support as front-end for corfu or company-mode candidates? #99

Closed aguynamedben closed 7 months ago

aguynamedben commented 7 months ago

This package is awesome. It's the best "pretty printing" of docs I've seen in Emacs. Great work!

I'm wondering if you've ever considered making this a "front end" for corfu or company-mode.

Below is a comparison:

eldoc-box

!!! awesome!

image

stock eldoc buffer

Pretty good, has syntax highlighting, displays horizontal rule, but has goofy &nsbp;'s from Markdown (I see why you added a prettifier layer!)

image

corfu-popupinfo-mode

No syntax highlighting, no horizontal rule, but at least monospace

image

company-quickhelp

Seems like it's just whitespace stripped and non-monospace

image

I would guess that Corfu and Company Mode completion systems are on the rise due to the popularity of language servers, and the eglot and lsp Emacs packages. It seems like you have the best "clean up the docs" system that would benefit many people if the logic could be ported or shared with corfu or company-mode.

casouri commented 7 months ago

eldoc-box just has a few heuristic prettifier functions that cleans up the markdown returned from language servers, and fontifies the markdown with markdown-mode (you probably already know this). It should be pretty easy for someone to copy these functions and write some boilerplate code to integrate with company and corfu. For me it doesn't make much sense for company or corfu to import eldoc-box just for the prettification.

(defvar eldoc-box-buffer-hook '(eldoc-box--prettify-markdown-separator
                                eldoc-box--replace-en-space
                                eldoc-box--remove-linked-images
                                eldoc-box--remove-noise-chars
                                eldoc-box--fontify-html
                                eldoc-box--condense-large-newline-gaps)
  "Hook run after buffer for doc is setup.
Run inside the new buffer. By default, it contains some Markdown
prettifiers, which see.")
aguynamedben commented 7 months ago

@casouri Thanks for the response. I'm going to close this. eldoc-box was doing a lot of legwork to clean up nastiness coming from PyRight language server. PyRight gives back "plaintext" instead of Markdown, and it's plaintext is Python doc strings (not actually plain text). So your extra step of processing was cleaning it twice.

Interestingly, the Eglot package leans on markdown-mode as well, which I use. I think Eglot was cleaning the nasty output from PyRight once, and then you were cleaning it again.

I switched my Python language server to pylsp (https://github.com/python-lsp/python-lsp-server) which gives back proper Markdown from it's language server, and now (a) Corfu showing it nicely, eldoc-box showing it nicely, and eldoc buffer showing it nicely.

Thanks for your response, language servers and these documentation UXes are so interesting! I love eldoc-box, thank you for sharing your work and helping people like me understand things. 🙏

corfu-popupinfo improved with Markdown from pylsp

image

eldox-box still kicking butt!

image
casouri commented 7 months ago

I'm glad you found out what works best for you 😁