Company
Company comes with a ‘company-capf’ backend that uses the completion-at-point functions, which in turn use completion styles. This means that the ‘company-capf’ backend will automatically use ‘orderless’, no configuration necessary!
But there are a couple of points of discomfort:
Pressing SPC takes you out of completion, so with the default separator you are limited to one component, which is no fun. To fix this add a separator that is allowed to occur in identifiers, for example, for Emacs Lisp code you could use an ampersand:
emacs-lisp(setq orderless-component-separator "[ &]")The matching portions of candidates aren’t highlighted. That’s because ‘
company-capf’ is hard-coded to look for the ‘completions-common-part’ face, and it only use one face, ‘company-echo-common’ to highlight candidates.So, while you can’t get different faces for different components, you can at least get the matches highlighted in the sole available face with this configuration:
emacs-lisp(defun just-one-face (fn &rest args) (let ((orderless-match-faces [completions-common-part])) (apply fn args))) (advice-add 'company-capf--candidates :around #'just-one-face)(Aren’t dynamically scoped variables and the advice system nifty?)
If you would like to use different ‘completion-styles’ with ‘company-capf’ instead, you can add this to your configuration:
;; We follow a suggestion by company maintainer u/hvis:
;; https://www.reddit.com/r/emacs/comments/nichkl/comment/gz1jr3s/
(defun company-completion-styles (capf-fn &rest args)
(let ((completion-styles '(basic partial-completion)))
(apply capf-fn args))
(advice-add 'company-capf :around #'company-completion-styles)