Giter Site home page Giter Site logo

Comments (9)

iostapyshyn avatar iostapyshyn commented on July 19, 2024 5

Just in case somebody has the same problem and is okay with not using orderless for company, here's what I use:

(define-advice company-capf
    (:around (orig-fun &rest args) set-completion-styles)
  (let ((completion-styles '(basic partial-completion)))
    (apply orig-fun args)))

from orderless.

oantolin avatar oantolin commented on July 19, 2024 1

You can probably also test in an orderless dispatcher whether company is active or not, but I don't know how to do that off the top of my head since I don't use company.

from orderless.

minad avatar minad commented on July 19, 2024

This is a very similar issue to #49.

from orderless.

kenranunderscore avatar kenranunderscore commented on July 19, 2024

@minad Phew, I don't really understand your issue all that well yet. Yours looks like a bug somewhere to me, while I don't see any obviously wrong completions in my case. I felt like mine is more a matter of knowing how to configure orderless.

Am I wrong here? I'm happy to learn more about this as I want to get into writing elisp myself. For instance the toy code you posted in #49 is a very cool example of how one would even debug this stuff 👍

from orderless.

minad avatar minad commented on July 19, 2024

@kenranunderscore Yes, #49 is a more intricate underlying issue about how some capf backends work. But I am not yet sure about how to resolve this.

  • For once there is the problem that company usually stops completion as soon as you enter a space (https://github.com/oantolin/orderless/#company and #35). The problem is that the completion style does not have full control.
  • Then there is the issue that the results returned by capf may not match the input string (assume for example that the capf backend performs some kind of expansion of the prefix, but the expanded string does not match the original prefix). Then the completion style may filter out the candidates.
  • Company always asks the capf backend for new candidates for every character you enter. This means the input string you enter must somehow be accepted by both the capf backend and the completion style. This is particularly problematic with lsp servers, which look directly at the buffer and return the candidates depending on the context around the point. This means one has to stop asking the server for candidates as soon as one wants to do completion style filtering. (This is a bit like the consult-grep command, where you have grep-filtering and completion-style filtering, if you are familiar with that command)
  • One more issue: The completion style passes a prefix filtering string to the backend when calling all-completions. The capf backend can then interpret this string in any way it wants (for example prefix filtering, this is expected). But orderless is not doing this, it always passes "" to the backend since there is no such thing as a prefix due the orderless nature. This means you run into two problems - first, the backend cannot do prefiltering (for example on the server, which would be efficient). Second orderless then uses the prefix word for its own filtering, but this may not match the expanded candidate returned by the backend.

The question you are asking is valid. I hope I don't cause too much confusion here, my points are all a bit incoherent. You basically want the backend to see "prefix" and the completion style orderless to match "^prefix".

from orderless.

minad avatar minad commented on July 19, 2024

@kenranunderscore You can use the following style dispatcher in order to add the caret for prefix matches to the first pattern.

(defun caret-orderless-dispatch (pattern index _total)
  (when (= index 0)
    `(orderless-regexp . ,(concat "^" pattern))))
(setq orderless-style-dispatchers '(caret-orderless-dispatch))

from orderless.

minad avatar minad commented on July 19, 2024

@oantolin Yes, I am using something like this for Corfu where I check for completion-in-region-mode. Maybe in Company you can use the variable company-my-keymap to detect if Company is active. Sorry for the blurb above, this happened when I was thinking about how Corfu should work and how it should work with special backends like lsp/eglot.

from orderless.

kenranunderscore avatar kenranunderscore commented on July 19, 2024

Thank you for the answers!
@minad Your explanations piqued my interest in corfu and I'll be giving it a try instead of company (which accidentally also made me realize that the features of selectrum I use are basically vertico, so I switched there, too). First steps feel great and I think I might just like not having auto-completion pop up on its own, but rather when I wish it to.

But I'll stop derailing this ticket: I won't try anything here for the time being. Feel free to close if you like.

from orderless.

kenranunderscore avatar kenranunderscore commented on July 19, 2024

I'm also using @iostapyshyn's customization above and that suffices for me. Of course reopen if you'd like to keep this around as a marker/reminder or something.

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.