nvim-cmp source for fuzzy-matched dictionary completions, powered by fuzzy.nvim.
Unlike cmp-dictionary which uses prefix/trie matching, this plugin uses fuzzy matching via fzf, fzy, or zf backends.
Depends on fuzzy.nvim (which depends on fzf, fzy, or zf).
Using lazy.nvim with fzy:
{ 'romgrk/fzy-lua-native', build = 'make' }
{ 'KoalaVim/fuzzy.nvim', dependencies = { 'romgrk/fzy-lua-native' } }
{ 'KoalaVim/cmp-fuzzy-dictionary', dependencies = { 'KoalaVim/fuzzy.nvim' } }require('cmp').setup({
sources = cmp.config.sources({
{ name = 'fuzzy_dictionary', keyword_length = 3 },
}),
})
require('cmp_fuzzy_dictionary').update({
paths = { '/usr/share/dict/words' },
})Note: the source name is fuzzy_dictionary in cmp's config.
Configuration is passed via require('cmp_fuzzy_dictionary').update():
Dictionary file paths. Each file should contain one word per line.
Default: {}
Maximum number of fuzzy matches to return.
Default: 15
Passed to the fuzzy matching backend. For fzf: case_mode (0 = smart, 1 = ignore, 2 = respect). For fzy: is_case_sensitive boolean.
Default: 0
To sort results by fuzzy match score:
local compare = require('cmp.config.compare')
cmp.setup({
sorting = {
comparators = {
require('cmp_fuzzy_dictionary.compare'),
compare.offset,
compare.exact,
compare.score,
-- ...
},
},
})MIT