autocommands for pandoc

This commit is contained in:
Fabrice Mouhartem 2023-12-24 21:48:21 +01:00
parent d377f3432a
commit fad7bc2ae5
2 changed files with 32 additions and 0 deletions

View File

@ -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

31
lua/autocommands.lua Normal file
View File

@ -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", "<Leader>i", "mz[s1z=`z", {noremap = true, silent = true})
vim.keymap.set("n", "à", "]s", {noremap = true, silent = true})
else
vim.keymap.del("n", "<Leader>i")
vim.keymap.del("n", "à")
end
end
})