Dictionary completion source for nvim-cmp
Example setting
require("cmp").setup({
-- other settings
sources = {
-- other sources
{
name = "dictionary",
keyword_length = 2,
},
}
})
require("cmp_dictionary").setup({
dic = {
["*"] = "/usr/share/dict/words",
["markdown"] = { "path/to/mddict", "path/to/mddict2" },
["javascript,typescript"] = { "path/to/jsdict" },
},
-- The following are default values, so you don't need to write them if you don't want to change them
exact = 2,
async = false,
capacity = 5,
debug = false,
})
The key is the file type, and the value is an array of dictionary paths.
You can also use comma-separated file types for the key.
If one dictionary, you can use a string instead of an array.
The key *
is used as a global setting.
It decides how many characters at the beginning are used as the exact match. If -1, only candidates with an exact prefix match will be returns.
If true, perform the initialization in a separate thread. If you are using a very large dictionary and the body operation is blocked, try this.
You need module mpack, so you need to install lua51-mpack or build neovim of 0.6 or higher.
Determines the maximum number of dictionaries to be cached. This will prevent duplicate reads when you switch dictionaries with the settings described above.
If true, debug messages are output.
You can download dic from aspell.net or installing by package manager, xbps extract to
$ ls /usr/share/dict/
american-english british-english words
The dictionary is recognized as a list delimited by %s
. %s
is a space, \t
, \n
, \r
, or \f
.
For example, if you use the following file as a dictionary, the source to be added is {"hello", "world", "!"}
.
hello
world !