From cac651905c513766eb0c26818866ec2282654570 Mon Sep 17 00:00:00 2001 From: Nathan Fisher Date: Sun, 21 May 2023 11:03:13 -0400 Subject: [PATCH] Spellchecking in neovim --- content/gemlog/spell_checking_in_neovim.gmi | 29 +++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 content/gemlog/spell_checking_in_neovim.gmi diff --git a/content/gemlog/spell_checking_in_neovim.gmi b/content/gemlog/spell_checking_in_neovim.gmi new file mode 100644 index 0000000..dad8a5d --- /dev/null +++ b/content/gemlog/spell_checking_in_neovim.gmi @@ -0,0 +1,29 @@ +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=` where 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 `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', 'sc', toggle_spell_check, {noremap=true}) +``` +I love having lua available in NeoVim. \ No newline at end of file