uga-rosa / cmp-dictionary

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

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

Closed naquad closed 1 year ago

naquad commented 1 year ago

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.

uga-rosa commented 1 year ago

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.

uga-rosa commented 1 year ago

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

naquad commented 1 year ago

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?

uga-rosa commented 1 year ago

Please see them.

https://github.com/uga-rosa/cmp-dictionary/blob/main/doc/cmp-dictionary.txt#L23-L28 https://github.com/uga-rosa/cmp-dictionary/blob/main/doc/cmp-dictionary.txt#L186-L193

naquad commented 1 year ago

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.

uga-rosa commented 1 year ago

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.

uga-rosa commented 1 year ago

Added automatic update function in OptionSet dictionary in 26522d209f5661c94f3a8bad8145160983d2252b.

naquad commented 1 year ago

Works great! Thank you :)