Spelling commands and mappings for Neovim.
- Automatically turn on spelling for certain file types
- Add mapping and command for toggling spelling on/off
- Add mappings for fixing spelling relative to the cursor in both normal and insert mode
Requires Neovim 0.7+
Ensure a dictionary is set in your init.lua
file:
vim.o.dictionary = '/usr/share/dict/cracklib-small'
The easiest way to get the above file within your filesystem is to download the Cracktime-Runtime package.
With Packer.nvim:
require('packer').startup(function(use)
use 'superDross/spellbound.nvim'
end)
:SpellingToggle
-- toggle spelling on/off
mapping.toggle_map
-- mapping for toggling spelling on/off (default:Ctrl-S
)mapping.fix_right
-- fix the nearest spelling mistake to the right of the cursor with the first suggestion (default:Ctrl-l
)mapping.fix_left
-- fix the nearest spelling mistake to the left of the cursor with the first suggestion (default:Ctrl-h
)language
-- language to check spelling againstautospell_filetypes
-- filetypes that should have spelling activated when openedautospell_gitfiles
-- activate spelling for git commit and rebase buffersnumber_suggestions
-- number of suggestions to display withz=
return_to_position
-- return to the original cursor position after executingfix_right
/fix_left
mappinghighlight.bg_colour
-- background colour of the highlight (default:lightgreen
)highlight.fg_colour
-- foreground colour of the highlight (default:black
)highlight.timer
-- number of microseconds in which the highlight will flash for (default: 500)
-- default settings
vim.g.spellbound_settings = {
mappings = {
toggle_map = '<C-s>',
fix_right = '<C-l>',
fix_left = '<C-h>',
},
language = 'en_gb',
autospell_filetypes = { '*.txt', '*.md', '*.rst' },
autospell_gitfiles = true,
number_suggestions = 10,
return_to_position = false,
}
To change the language to Spanish and toggle map key, but keep the fix maps defaults, then add the following to your init.lua
:
vim.g.spellbound_settings = {
mappings = {
toggle_map = '<Leader>s'
},
language = 'es',
}