Giter Site home page Giter Site logo

Support source priorities about nvim-cmp HOT 8 CLOSED

hrsh7th avatar hrsh7th commented on September 26, 2024
Support source priorities

from nvim-cmp.

Comments (8)

hrsh7th avatar hrsh7th commented on September 26, 2024

I think we should add https://github.com/hrsh7th/nvim-cmp/blob/main/lua/cmp/menu.lua#L92 as option.

from nvim-cmp.

tzachar avatar tzachar commented on September 26, 2024

It depends on how you calculate the score. If it is a number between 0 and 1, the easiest solution is to keep the code as is and just mention that the order of sources determines their priorities.
However, the question is do you sort completion items globally or internally by source and keep the source order? If you would like to support both options, it requires changing the current logic.

from nvim-cmp.

hrsh7th avatar hrsh7th commented on September 26, 2024

The nvim-cmp will sort items as globally. But it has a priority bonus so we can control source priority by it.

And sorting logic fully customizable.

require'cmp'.setup {
  sorting = {
    comparators = {
      function(e1, e2)
        ...
      end
    }
  }
}

The default config is https://github.com/hrsh7th/nvim-cmp/blob/main/lua/cmp/config/default.lua#L49

from nvim-cmp.

tzachar avatar tzachar commented on September 26, 2024

And the score is between 0 and 1?

from nvim-cmp.

hrsh7th avatar hrsh7th commented on September 26, 2024

No. The score is upper 1 value (0 means no match instead).

from nvim-cmp.

tzachar avatar tzachar commented on September 26, 2024

So the solution is to just mention the default priority scheme in the README.

from nvim-cmp.

hrsh7th avatar hrsh7th commented on September 26, 2024

I've added first configuration document (it's WIP).
Could you feedback it? https://github.com/hrsh7th/nvim-cmp#configuration-1

from nvim-cmp.

tzachar avatar tzachar commented on September 26, 2024

Cool. See #12

from nvim-cmp.

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.