uga-rosa/cmp-dictionary

Accept function for dic and/or file type or provide other means to set buffer-specific dictionaries

naquad opened this issue · 8 comments

I have the following configuration:

require('cmp_dictionary').setup {
  dic = {
    ['*'] = '/usr/share/dict/words',
    ledger = '<secret location>/accounting/accounts.txt'
  }
}

While it mostly works there are a number of issues with this configuration.

  1. This is a static configuration that can't be customized in the runtime. Think set dictionary+=asd.txt so one can set dictionaries specific to the particular buffer.
  2. The configuration is "global", i.e. you can't customize the configuration per buffer.
  3. All the configuration made using 'dictionary and 'thesaurus is ignored :(

I've been using a lot of dictionaries and have quite a few configurations for file types, frameworks, and so forth. It would be great to see the support of 'dictionary and/or 'thesaurus in cmp-dictionary. If that's too much work then at least accept a function instead of the string for specifying the dictionary would be very appreciated.

To allow more user flexibility, I plan to eliminate the dic in setup and refer to the value of the dictionary option. I have been busy lately and the work has been slow, but I will do it soon, so please be patient for a while.

I have merged v2. Can you do what you wanted to do?

From what I see in the help and the Wiki, there are no changes related to this issue. No function can be set for the dictionary source, and the 'dictionary setting is not handled.

Am I missing something?

Ah, thank you for the clarification, now I got it. Although, after some testing, it seems that I still have to call :CmpDictionaryUpdate even when the switcher is used, despite what the docs say. Is that correct?

Demo: asciicast

P. S. Previous message demo link is broken, please ignore it.

It's not a bug (only FileType, BufEnter, and OptionSet spelllang have been registered), but it sure would be nice to have automatic updates in the OptionSet dictionary.

Added automatic update function in OptionSet dictionary in 26522d2.

Works great! Thank you :)