diff --git a/lua/autocommands.lua b/lua/autocommands.lua index 6cd20e2..25acc87 100644 --- a/lua/autocommands.lua +++ b/lua/autocommands.lua @@ -9,6 +9,7 @@ vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, { vim.o.filetype = 'pandoc' require('luasnip').filetype_extend("pandoc", { "markdown" }) vim.o.spell = true + require('spelling').spell_keymap() vim.o.spelllang = 'en' vim.o.formatoptions = "qj" -- email commands: my/msy to paste the html inside the clipboard @@ -39,7 +40,7 @@ vim.api.nvim_create_autocmd({ "OptionSet" }, { local texgroup = vim.api.nvim_create_augroup("latex", { clear = true }) vim.api.nvim_create_autocmd("FileType", { - pattern = { "latex" }, + pattern = { "latex", "tex" }, group = texgroup, callback = function() -- vimtex configuration @@ -53,5 +54,6 @@ vim.api.nvim_create_autocmd("FileType", { vim.o.foldexpr = 'vimtex#fold#level(v:lnum)' vim.o.foldtext = 'vimtex#fold#text()' vim.o.spell = true + require('spelling').spell_keymap() end, }) diff --git a/lua/spelling.lua b/lua/spelling.lua index 838d540..89ba07d 100644 --- a/lua/spelling.lua +++ b/lua/spelling.lua @@ -7,15 +7,13 @@ end local M = {} M.spell_keymap = function() - if vim.o.spell == true then - vim.keymap.set("n", "i", "mzl[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 + if vim.o.spell == true then + vim.keymap.set("n", "i", "mzl[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 -M.spell_keymap() - return M