spell
source for nvim-cmp
based on vim's spellsuggest
.
require("cmp").setup({
sources = {
{
name = "spell",
option = {
keep_all_entries = false,
enable_in_context = function()
return true
end,
preselect_correct_word = true,
},
},
},
})
Setting spell
(and spelllang
) is mandatory to use spellsuggest
.
vim.opt.spell = true
vim.opt.spelllang = { "en_us" }
If true, all vim.fn.spellsuggest
results are displayed in nvim-cmp
menu. Otherwise, they are being filtered to only include fuzzy matches.
Type: boolean
Default: false
'nvim-cmp' menu is populated only when the function returns true.
For example, one can enable this source only when in a @spell
treesitter capture. See :help treesitter-highlight-spell
.
enable_in_context = function(params)
return require('cmp.config.context').in_treesitter_capture('spell')
end,
Type: function
Return: boolean
Default:
enable_in_context = function(params)
return true
end,
Note: this option will be removed when hrsh7th/nvim-cmp#632 is implemented.
If true and the spelling of a word is correct, the word is displayed as the first entry and preselected.
Type: boolean
Default: true