From cbde7406b3b0d34056f7e4fa982fba4e0333c1d1 Mon Sep 17 00:00:00 2001 From: Fabrice Mouhartem Date: Mon, 25 Dec 2023 16:02:03 +0100 Subject: [PATCH] Use spelling module for autocommand about spelling --- lua/autocommands.lua | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/lua/autocommands.lua b/lua/autocommands.lua index 8f914e4..6cd20e2 100644 --- a/lua/autocommands.lua +++ b/lua/autocommands.lua @@ -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", "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", "i") - keyunmap("n", "à") - end - end + group = spelling, + callback = require('spelling').spell_keymap }) -- LaTeX configuration