-
-
Notifications
You must be signed in to change notification settings - Fork 111
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
Add previews to consult-completion-in-region #218
Conversation
One case in which completion in region does receive a function as |
Mmh, I think we decided that in the file case we would use |
It's worth losing the previews in the file case, since |
I tested this and it seems to work well. I am a bit worried about the collection trick you are using, since the metadata of the collection is lost. Furthermore is it possible to add support for Overall I am not very happy with capf and I am using this intricate company setup as a replacement, which I would like to get rid of (https://github.com/minad/corfu, #175 (comment)). I think a good setup would look somehow like this:
|
Regarding the collection hack and the preview I think the cleaner solution would be to still use |
Using I'll also try your cycling idea by calling |
I just noticed that |
Yes, I didn't implement this correctly since I did not use the function for file completion as of now. But I am aware of this since your Embark function looks differently. |
This way we get previews for both file and non-file completion.
I fixed |
You would have to access the fields Did you also try to get this cycle threshold to work? |
Not yet, since it does already work with default completion (except that the minibuffer does open anyway). 😛 |
Wait, I take it back, |
Oh, tab cycling does work, but not if you press tab right away, you need to press something else first. If you start with tab it scrolls the window. I have no idea why! |
OK, cycling is done! I think that's everything. |
Cool! Seems to work almost. I gave it a quick test. There seems to be a small problem with file completions, for example in eshell - where cycling sometimes does not work. Maybe the all-completions length check is not applicable to files and needs something more sophisticated? Did you also observe some issue there? |
Cycling does seem to work for me for file completion in eshell. What exactly happens when you try it? |
It could be some local misconfiguration. I will try a bit longer and then I can produce a test case. It seems to work mostly, but in some scenarios it fails. |
Hmm, It somehow behaves weird for file completion when I compare it with default completion (I have completion-at-point configured such that it uses the default completion, no selectrum). It completes full file paths instead of path elements as in completion--in-region. But maybe the current version also misbehaves like this? |
Oh, completing entire paths in one go instead of completing them one component at a time was done on purpose! This was suggested by @clemera, and is what Selectrum's completion in region function does. I like that behavior too. When you want to complete a long path, it feels much faster to navigate in the minibuffer to it than to press |
This is why I use |
Ah okay, I just stumbled over this because my muscles are too stupidly trained for TAB TAB TAB shell completion. Maybe I have to make this configurable 😆 I will merge this at some point but I have to fiddle a bit more with it. Overall it looks good. |
Note that I didn't really use this function before, and I am now considering it as replacement for company. Therefore I am coming up again with these old discussions. Sorry for that. |
I merged your PR with some very minor restructuring and I added |
Looks good! Thanks for rewriting the Also, you added the |
I thought it might make sense to use the default value to not surprise users. This is how default completion behaves (letting you complete symbols with point within the symbol for example). But I have set it to nil myself (to use |
I wasn't talking about the default value of the variable, @clemera. What I meant is that in Selectrum, Also, if |
I don't know what you mean, the styles should be used for the initial filtering regardless of how many candidates you have.
That is right, it is a feature not a bug ;) |
I'm not sure I think they will digress further in the future because I have some plans to offer overlay completion for it. |
Oh, sorry, I missed the argument Since I hadn't seen the
Oh, really? |
One thing I don't like about calling |
The table is only passed so metadata can be queried from it as the candidates are a list of strings at that point.
I didn't consider it common that you want to use the same styles for the initial filtering you use regularly. That was the point of adding the option after all, but maybe I'm wrong it might make sense to do what consult does and additional allow a filter function which can be |
Ah okay that is nice indeed. Though it seems the completion-in-region-styles are used in consult for the whole completion session? I only added it for the initial filtering as for the completion itself I would think one would want to use the regular styles. |
You probably assumed we are doing the same in Selectrum? I understand your surprise that using |
When @minad proposed the variable my initial reaction was that it wasn't necessary because I also thought one would want one's regular styles, but he says for completion in region he prefers more weight to prefix matches and to hit tab to add text, which sounds pretty reasonable (I do stick with only orderless, everywhere). |
You know, I am really loving this function now that I've been using it for a few days! The preview makes it so I most often don't even need to pop up the completions at all (I'm currently on a no-visible-completions-until-needed kick). Pretty often I don't even glance at the minibuffer. |
This adds previews to
consult-completion-in-region
. The preview code was removed fromconsult--yank-read
, put into a littleconsult--region-state
function and then used both inconsult--yank-read
andconsult-completion-in-region
.(I ran into a small snag:
consult--read
cannot be passed a completion table function, because it expects functions to be async collections. I think I have a good workaround for that.)