uga-rosa / cmp-dictionary

A dictionary completion source for nvim-cmp
MIT License
236 stars 16 forks source link

Set dictionary based on vim `spelllang`? #29

Closed farbodsz closed 2 years ago

farbodsz commented 2 years ago

Sometimes I write prose in English, or in other languages within vim, and adjust vim's spelllang option to get spelling corrections.

Is it possible to configure cmp-dictionary so that the dictionary (and list of words for completion) changes, depending on what spelllang option is set?

uga-rosa commented 2 years ago

I would like to know what exactly you would like to do. It is not possible to dynamically change the completion candidates as it is now, but probably not that big a change should be necessary. I don't know about the performance impact, though.

farbodsz commented 2 years ago

Yes exactly - I'm imagining something like this:

  1. User defines dictionary sources for various languages (English, French, German, etc) in their configuration
  2. User changes spelllang during their editing session
  3. Active dictionary source is updated dynamically

If it would have a large performance impact, I'm happy just to specify those sources together, so that completion for all languages shows up, regardless of what I've set as spelllang.

uga-rosa commented 2 years ago

I see, you don't want to put the result of spellsuggest() as a candidate, you want to register a dictionary for each spelllang like the current implementation of filetype and filepath?

uga-rosa commented 2 years ago

Added. Please register language and dictionary in dic.spelllang during setup. The plugin cannot detect changes in spelllang, so be sure to run :CmpDictionaryUpdate after spelllang is changed.