Use spelling module for autocommand about spelling

This commit is contained in:
Fabrice Mouhartem 2023-12-25 16:02:03 +01:00
parent 761d30bb69
commit cbde7406b3
1 changed files with 3 additions and 16 deletions

View File

@ -1,10 +1,5 @@
local markdown = vim.api.nvim_create_augroup("markdown", { clear = true })
local keyunmap = function(mode, binding)
if vim.fn.maparg(binding, mode) ~= "" then
vim.keymap.del(mode, binding)
end
end
local spelling = vim.api.nvim_create_augroup("spelling", { clear = true })
-- Recognize .md as pandoc
vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, {
@ -36,16 +31,8 @@ vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, {
-- Spell shortcuts
vim.api.nvim_create_autocmd({ "OptionSet" }, {
pattern = { "spell" },
group = markdown,
callback = function()
if vim.o.spell == true then
vim.keymap.set("n", "<Leader>i", "mz[s1z=`z", { noremap = true, silent = true, desc = "f[I]x typo under cursor" })
vim.keymap.set("n", "à", "]s", { noremap = true, silent = true, desc = "Go to the next typo" })
else
keyunmap("n", "<Leader>i")
keyunmap("n", "à")
end
end
group = spelling,
callback = require('spelling').spell_keymap
})
-- LaTeX configuration