Giter Site home page Giter Site logo

Comments (8)

oantolin avatar oantolin commented on August 20, 2024

One simple way to do it would be to set completion-styles to whatever you want to use for corfu and company, and add to minibuffer-mode-hook a function that set the completion-styles locally in the minibuffer to something that includes orderless. Like this:

(setq completion-styles '(basic partial-completion)) ; styles for corfu & company

(defun use-orderless ()
  (setq-local completion-styles '(orderless))) ; styles for minibuffer commands such as consult commands

(add-hook 'minibuffer-mode-hook #'use-orderless)

But maybe, in case this is an XY problem, let me ask: why do you want to disable orderless for corfu and company?

from orderless.

ydzhou avatar ydzhou commented on August 20, 2024

Hi @oantolin , yeah I prefer company/corfu use substring for completion. When I type something, normally I can remember the prefix of what I am trying to type, so orderless is an overkill for me.

from orderless.

minad avatar minad commented on August 20, 2024

@oantolin

One simple way to do it would be to set completion-styles to whatever you want to use for corfu and company, and add to minibuffer-mode-hook a function that set the completion-styles locally in the minibuffer to something that includes orderless.

That's not such a good fix actually, when taking more packages like Consult into account. I haven't found the ideal fix for Corfu yet to be honest. The problem with activating orderless only within the minibuffer is that it doesn't play nicely with consult-line which uses the completion-styles to jump to the position of the match (even after closing the minibuffer). One could then work around this problem by setting completion-category-overrides for consult-location but that's also not great. For Company the solution is to modify the completion styles with an advice around company-capf. Such an advice does not work for Corfu since Corfu uses completion-all-completions and completion-try-completion at many more places.

from orderless.

oantolin avatar oantolin commented on August 20, 2024

Fair enough, @ydzhou.

I obviously hadn't checked all the consequences, @minad. Thanks for pointing those issues out. As for a good way to control completion-styles for Corfu, is there any way to detect if Corfu is currently open, some varíable or something? If so, one could write a new completion style that simply delegates to one completion style or another depending on whether Corfu is asking or not.

from orderless.

oantolin avatar oantolin commented on August 20, 2024

Also, consult-line already stores a marker in a text property, right? Isn't that marker obtained while the minibuffer is open? Why does it need to use completion again. Or am I just wrong about the location being stored in a text property, @minad ?

from orderless.

minad avatar minad commented on August 20, 2024

In order to highlight the matches.

from orderless.

oantolin avatar oantolin commented on August 20, 2024

In order to highlight the matches.

Oh, right!

from orderless.

failable avatar failable commented on August 20, 2024

This works, but messy.

  (defvar osfva-default-completion-styles
    (let ((sv (get 'completion-styles 'standard-value)))
      (and (consp sv)
           (condition-case nil
               (eval (car sv) t)
             (error completion-styles)))))

  (defvar osfva-enable-orderless-in-company nil)

  (defun osfva-toggle-enable-orderless-in-company ()
    (interactive)
    (setq osfva-enable-orderless-in-company
          (not osfva-enable-orderless-in-company)))

  (defun osfva-company-disable-orderless (orig-fun &rest args)
    "Diable orderless completion style when company is doing the completion."
    (let ((completion-styles (if osfva-enable-orderless-in-company
                                 completion-styles
                               osfva-default-completion-styles)))
      (apply orig-fun args)))
  (advice-add #'company--perform :around #'osfva-company-disable-orderless)

https://osfva.com/20210721000000-%E5%9C%A8company_mode%E8%A1%A5%E5%85%A8%E8%BF%87%E7%A8%8B%E4%B8%AD%E7%A6%81%E7%94%A8orderless/

from orderless.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.