capsule/content/gemlog/spell_checking_in_neovim.gmi

29 lines
No EOL
1.3 KiB
Text

Meta(
title: "Spell checking in NeoVim",
summary: None,
published: Some(Time(
year: 2023,
month: 5,
day: 21,
hour: 15,
minute: 2,
second: 52,
)),
tags: [
"neovim",
"workflow",
"lua",
],
)
---
I had an email reply to one of my posts this morning which pointed out a spelling error. Well, there was more to the reply, but for the sake of this post that's the important bit. Anyway, what's funny is that I was just last night looking at the possibility of adding spellcheck to my NeoVim configuration.
It turns out that NeoVim has a spell checker built in as of version 0.8. That's fantastic. You can turn it on with the command `:set spell`, or if you are using a language other than en_US `:set spelllang=<LANG>` where <LANG> would be your language code. But I really like having things like this mapped to an easy to remember keybind whenever possible, so I wanted to be able to toggle it on and off using `<leader>sc`. Well, that was pretty easy as well with the following snippet in init.lua.
```
-- Toggle spellcheck
local function toggle_spell_check()
vim.opt.spell = not(vim.opt.spell:get())
end
vim.keymap.set('n', '<leader>sc', toggle_spell_check, {noremap=true})
```
I love having lua available in NeoVim.