From fad7bc2ae55cffdcc2c20f34576a76d44f100db8 Mon Sep 17 00:00:00 2001 From: Fabrice Mouhartem Date: Sun, 24 Dec 2023 21:48:21 +0100 Subject: [PATCH] autocommands for pandoc --- init.lua | 1 + lua/autocommands.lua | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 lua/autocommands.lua 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 +})