reddit / emacs

Prioritize certain completions in ivy;

The9thHuman · 2022-08-06 10:56
Hello, Ive been using ivy for a while now, and its been blooming smooth sailing. One thing i havent figured out though is how to prioritize specific completions; my search-fu is failing me here. What i want is to be able to provide a list of interactive functions (I only need this for executing extended commands) that, should they be in the list of completions, should be placed first in the completion list. For example, currently if i type in `sly connect`, the function `sly-connect` isnt first, that honor goes to `sly-list-connections`. As there ⠀isnt any way to narrow down completion to *just* `sly-connect` without replacing the space with a hyphen, i have to add it to the list of functions i have to type literally. So, is there any way to prioritize certain completions? Or, do you have other recommendations for how to solve this issue without needing to remember specific functions? Thanks!
MonsieurPi · 2022-08-06 14:06
Take a look at prescient and savehist, might help Edit with links https://github.com/radian-software/prescient.el https://www.emacswiki.org/emacs/SaveHist
MonsieurPi · 2022-08-06 14:09
And if you don't want littering, take a look at no-littering https://github.com/emacscollective/no-littering
deaddyfreddy · 2022-08-09 12:20
try installing https://github.com/DarwinAwardWinner/amx (no need to activate/bind it, since ivy automatically detects its presence and uses for command prioritization)
n9lla · 2022-08-10 11:23
Is `ivy-sort-matches-functions-alist` what you're looking for? Also somewhat related, to further narrow down you could add a dollar sign and `connect$` should only match commands that end with "connect". If not, there is `ivy-re-builders-alist`. I have not bothered for M-x but for swiper I use something I pieced together from `ivy--regex-ignore-order` and the Orderless package ([https://github.com/oantolin/orderless](https://github.com/oantolin/orderless)).