f3fora / cmp-spell

spell source for nvim-cmp based on vim's spellsuggest.
191 stars 3 forks source link

cmp-spell cannot sort by order at first entry #12

Closed Jaehaks closed 4 months ago

Jaehaks commented 5 months ago

I wanted the completion window to be printed in the same order as the vim.fn.spellsuggest() function. like this.

  1. overshoot
  2. Overshot
  3. overshoe
  4. over shot
  5. overshoots

To see this, I changed the sorting order in config of nvim-cmp like

sorting = {
  priority_weight = 2.0,
  comparators = {
    compare.order,
  }
},

but the completion window said the input word first like

1. overshot

  1. overshoot
  2. Overshot
  3. overshoe
  4. over shot
  5. overshoots

Why does the first one displayed? my source setting is

-- /////// source of lua
cmp.setup.filetype({'lua'}, {
  sources = {
    {
      name = 'spell', 
      group_index = 1,
      option = {
        keep_all_entries = true, -- it can show more possible list
        enable_in_context = function () -- is_available() does not work, this option make spell completion work only 
          return context.in_treesitter_capture('comment') or context.in_syntax_group('Comment')
        end
      }
    },
  }
})
Jaehaks commented 4 months ago

@f3fora It is weird that the order is same with suggestion of spellsuggest() when preselect_correct_word = false. Anyway, It works for me! Thank you for your commit!