hrsh7th / nvim-cmp

A completion plugin for neovim coded in Lua.
MIT License
7.9k stars 394 forks source link

Question: How to use comparators to sort properties and values first in CSS? #1732

Open kmoschcau opened 11 months ago

kmoschcau commented 11 months ago

Hi, currently I don't fully understand what each comparator does or how it could help me achieve what I want.

Currently I have this setup in my cmp config:

      sources = cmp.config.sources({
        { name = "nvim_lsp" },
        { name = "nvim_lsp_signature_help" },
        { name = "luasnip" },
      }, {
        buffer_source,
      }),
      sorting = {
        comparators = {
          cmp.config.compare.offset,
          cmp.config.compare.exact,
          cmp.config.compare.score,
          require("cmp-under-comparator").under,
          cmp.config.compare.kind,
          cmp.config.compare.sort_text,
          cmp.config.compare.length,
          cmp.config.compare.order,
        },
      },

Basically when completing properties, I would like to have properties first. When completing values for properties I would like to have values first. Right now they are both somewhere in the middle, sandwiched between functions and snippets. How could I achieve having them first?