Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

cmp-fuzzy-dictionary

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.

Installation

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' } }

Setup

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

Configuration is passed via require('cmp_fuzzy_dictionary').update():

paths (type: table of strings)

Dictionary file paths. Each file should contain one word per line.

Default: {}

max_items (type: int)

Maximum number of fuzzy matches to return.

Default: 15

fuzzy_extra_arg

Passed to the fuzzy matching backend. For fzf: case_mode (0 = smart, 1 = ignore, 2 = respect). For fzy: is_case_sensitive boolean.

Default: 0

Sorting

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,
      -- ...
    },
  },
})

License

MIT

About

nvim-cmp source for fuzzy-matched dictionary completions, powered by fuzzy.nvim

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages