syl20bnr / spacemacs

A community-driven Emacs distribution - The best editor is neither Emacs nor Vim, it's Emacs *and* Vim!
http://spacemacs.org
GNU General Public License v3.0
23.57k stars 4.9k forks source link

Don't use orderless with company-capf as a default #16302

Open niontrix opened 4 months ago

niontrix commented 4 months ago

Hi guys! I recently switched from using helm to the compleseus-layer which uses orderless for completion styles. So far it works great. But a few days ago I noticed that Company still seems to have an unresolved issue that causes the auto-completion to become unbearably slow when using ordereless as a completion style. Currently the compleseus-layer configures orderless to not be used as a completion style when lsp-completion-mode is active, because as far as I know lsp provides its own completion styles, so its not needed. The problem I have is that when I try to use auto-completion in an emacs-lisp buffer the auto-completion gets unuseably slow, which I could trace back to the use of orderless, using the profiler. Like in https://github.com/oantolin/orderless/issues/48#issuecomment-856750410 I think it maybe best not to use orderless as a completion style with company-capf by default, because it seems to be a general issue with company when using orderless, so I expect it to cause the same problems in other modes as well.

https://github.com/syl20bnr/spacemacs/blob/4a227fc94651136a8de54bcafa7d22abe1fa0295/layers/%2Bcompletion/compleseus/packages.el#L300-L310

Proposed:

 (defun compleseus/init-orderless () 
   (use-package orderless 
     :init 
     ;; company-capf is messed up with orderless 
     ;; https://github.com/oantolin/orderless/issues/48#issuecomment-856750410 
     (define-advice company-capf (:around (orig-fun &rest args) set-completion-styles) 
       (let ((completion-styles '(basic partial-completion orderless))) 
         (apply orig-fun args)))