minad / marginalia

:scroll: marginalia.el - Marginalia in the minibuffer
GNU General Public License v3.0
780 stars 27 forks source link

Annotations in complete-symbol completions buffer #133

Closed danrobi11 closed 2 years ago

danrobi11 commented 2 years ago

Hi. When I run C-M i there's no annotations in the complete-symbol completions buffer. Does marginalia support the Emacs built-in complete-symbol?

danrobi11 commented 2 years ago

My bad. I was trying to run C-M i on marginalia- with no parents. It works with (marginalia-. Closing.

minad commented 2 years ago

There is still some minor issue here: complete-symbol uses info-complete-symbol internally. Unfortunately there is no way to detect this completion table from the side of Marginalia, such that we can augment it with a symbol completion category and the corresponding Marginalia symbol annotator. The prompt classifier can also be not used in the case of in buffer completion, since there is no prompt.

As I see it, annotations for completion-at-point are out of scope of Marginalia. This don't affect me personally since I don't want the rich Marginalia annotations in the Corfu completion popup, I even prevent them exclude them from being used there. Having such rich annotations may be more interesting for users of default completion, Mct or consult-completion-in-region.

cc @oantolin What do you think as a user of consult-completion-in-region? Maybe we can improve the classifiers slightly? I would try to avoid introducing complicated, unpredictable heuristics. The current category classifier system of Marginalia works well enough in the minibuffer.

oantolin commented 2 years ago

I'm a little confused. I already get Marginalia annotations even for complete-symbol, for variables as well as for functions. Here's a screenshot of completing variables:

image

minad commented 2 years ago

@oantolin What kind of magic is this? I only see the annotations for function names after the opening parenthesis, but not for variables. Tried emacs -Q (Emacs 28) with marginalia-mode only.

oantolin commented 2 years ago

I don't remember doing anything! 😆 I'll figure out what's going on and report.

oantolin commented 2 years ago

From emacs -q loading marginalia-mode and using consult-completion-in-region you do get variable annotations. So it's something consult-completion-in-region arranges.

minad commented 2 years ago

See https://github.com/minad/consult/blob/95d1851567637325425c0956adbf711c801dd45c/consult.el#L2406-L2414

oantolin commented 2 years ago

I don't think that's it, since I don't have company installed.

minad commented 2 years ago

Company docsig is provided by the elisp capf.

oantolin commented 2 years ago

I was about to say I do have :company-docsig! So the built-in elisp capf adds that property?! I had no idea.

oantolin commented 2 years ago

Wow, it's true! The built-in elisp-mode package has some company stuff in it. I had no idea at all!

oantolin commented 2 years ago

How did that happen?

minad commented 2 years ago

Wow, it's true! The built-in elisp-mode package has some company stuff in it. I had no idea at all! How did that happen?

The Company maintainer Dmitry Gutov added it. :) Personally I am not fond of the package-specific naming, but the functionality is good to have nevertheless. It would have been a bit better to introduce an official docsig-function as part of the completion metadata, similar to the annotation-function and similar to what I did when I proposed the group-function. Anyway this is just about naming. Corfu also has full support for all Company extensions.

oantolin commented 2 years ago

Well, mystery solved, then.