-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[#42] Utilize annotation and docsig function in completion-in-region #62
[#42] Utilize annotation and docsig function in completion-in-region #62
Conversation
Just a random thought: Sometimes I found myself really want to also filter those annotations (e.g., type "function" to filter out all functions). But seems it's impossible from the fact that the prefix is originally for read-file-name function, and such filtering could be awkward if not use prescient. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks cool!
I have thought about this for other purposes as well. I think selectrum could offer a neat unique approach to handle candidates from "multiple sources". By prefixing the query with for example "f " you could restrict candidates to only functions. Available search prefixes could be displayed in a |
About About About "meta": There is such thing called "completion metadata", I don't understand it, but it's an (undocumented) arg of |
I am not a fan of this approach, but I've heard helm can let you filter from results offered by multiple backends simultaneously, and this is loved by helm users. I once saw similar features in VSCode: In its "command pallete" (kind of like But I have no idea how could Selectrum handle "multiple sources". It's obvious that you can build your own command that put together buffers, recent files, imenu indexes and other things together, and distinguish them by a text property, then write a |
There could be a general text property which defines such prefixes. For example |
I don't like that approach. It feels very special-cased to me. On the other hand, you could apply your own text property to each candidate, and then pass a dynamic collection function to |
Yes that is an easy way to do it. I do something similar with a custom switch buffer command I currently use with selectrum. I like that approach: search the whole collection unless I specify a special filter pattern. I think it is a great feature and I remember there was an issue to add it to What is you plan in regard to more useful default commands? I think it would be great to have a |
I think such commands should be kept in personal configurations until we accrue such a volume of them that it makes sense to design a permanent solution. By implicitly encouraging people to design their commands so that they work better with plain |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok!
I agree with that in general but it would help to have a central place where users can lookup and share those commands. A wiki for selectrum would be a nice place for sharing such commands I think. |
Good idea! The Selectrum wiki is officially open for business, then :) |
Nice! |
I was just customizing the face of this, and I think inheriting from the built-in face P.S. I love this, thank you all for your work! |
Glad you love it ;)
I'm not sure about this. I saw you use lsp-mode with Selectrum, so I searched for some lsp-mode pictures (I don't use it). Some of them use very colorful/bold face for annotations, which actually looks great for me. I think it's better to offer two faces, one for the annotation (on the left side), another for the docsig (on the right side), so the user could customize them as he/she want. Does this seem reasonable for you? |
Isn't Actually, I was trying to figure out why the common part in my completions looked so ugly. Turns out that it's by default using I'm going to open a PR deleting Also, I agree with you, I would prefer these to be colorful, and my theme (Solarized) only customizes one of these faces, so I'm going to update it as well. |
I agree with this. However, there's no essential difficulties in customizing: you use
What if the user want to use one face for annotation, and another for docsig? That's why I suggested offering two faces. |
Hm, I see what you mean, people may wish to do that (including myself). Let me amend that PR; I still think we ought to default to inheritance than just making up new colors, but we could certainly provide two faces for users' to change as they see fit. |
This implements ideas mentioned in #42 (comment).
How does it look like
This is
selectrum-completion-in-region
on a backend created by me. I use the:annotation-function
for the kind (variable, function, ...), which is displayed as the prefix; and I use the:company-docsig
for the signature, which is displayed using right-margin text.How does it work
The
completion-at-point
function let bindscompletion-extra-properties
to the extra props offered by backends, so we could just get the things we need from it.What can still be improved
I use a italic face for those annotations, but I think it's better to also use some gray color to distinguish them from the candidate. Are you ok with me adding such face?
Maybe we should also handle
:exit-function
(see the docstring ofcompletion-extra-properties
). I haven't study what is it for. company-capf also handles:predicate
(see the docstring ofcompletion-at-point-functions
.