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

View File

@ -1,10 +1,5 @@
local markdown = vim.api.nvim_create_augroup("markdown", { clear = true }) local markdown = vim.api.nvim_create_augroup("markdown", { clear = true })
local spelling = vim.api.nvim_create_augroup("spelling", { clear = true })
local keyunmap = function(mode, binding)
if vim.fn.maparg(binding, mode) ~= "" then
vim.keymap.del(mode, binding)
end
end
-- Recognize .md as pandoc -- Recognize .md as pandoc
vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, { vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, {
@ -36,16 +31,8 @@ vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, {
-- Spell shortcuts -- Spell shortcuts
vim.api.nvim_create_autocmd({ "OptionSet" }, { vim.api.nvim_create_autocmd({ "OptionSet" }, {
pattern = { "spell" }, pattern = { "spell" },
group = markdown, group = spelling,
callback = function() callback = require('spelling').spell_keymap
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
}) })
-- LaTeX configuration -- LaTeX configuration