diff --git a/init.lua b/init.lua index 4d93257..39b9b20 100644 --- a/init.lua +++ b/init.lua @@ -65,6 +65,7 @@ require('neorg-configure') -- Customizations require('bepo') require('restore-position') +require('autocommands') -- The line beneath this is called `modeline`. See `:help modeline` -- vim: ts=2 sts=2 sw=2 et diff --git a/lua/autocommands.lua b/lua/autocommands.lua new file mode 100644 index 0000000..8378b50 --- /dev/null +++ b/lua/autocommands.lua @@ -0,0 +1,31 @@ +-- Recognize .md as pandoc +vim.api.nvim_create_autocmd({"BufEnter", "BufWinEnter"}, { + pattern = {"*.md", }, + callback = function() + vim.o.filetype = 'pandoc' + vim.o.spell = true + vim.o.spelllang = 'en' + end +}) + +-- French markdown files +vim.api.nvim_create_autocmd({"BufEnter", "BufWinEnter"}, { + pattern = {"*-fr.md", }, + callback = function() + vim.o.spelllang = 'fr' + end +}) + +-- Spell shortcuts +vim.api.nvim_create_autocmd({"OptionSet"}, { + pattern = { "spell" }, + callback = function() + if vim.o.spell == true then + vim.keymap.set("n", "i", "mz[s1z=`z", {noremap = true, silent = true}) + vim.keymap.set("n", "à", "]s", {noremap = true, silent = true}) + else + vim.keymap.del("n", "i") + vim.keymap.del("n", "à") + end + end +})