Add augroup to autocommand

This commit is contained in:
Fabrice Mouhartem 2023-12-24 22:42:24 +01:00
parent 6254bfe4d0
commit 6d26e62cee

View File

@ -1,6 +1,9 @@
local markdown = vim.api.nvim_create_augroup("markdown", { clear = true })
-- Recognize .md as pandoc -- Recognize .md as pandoc
vim.api.nvim_create_autocmd({"BufEnter", "BufWinEnter"}, { vim.api.nvim_create_autocmd({"BufEnter", "BufWinEnter"}, {
pattern = {"*.md", }, pattern = {"*.md", },
group = markdown,
callback = function() callback = function()
vim.o.filetype = 'pandoc' vim.o.filetype = 'pandoc'
vim.o.spell = true vim.o.spell = true
@ -15,6 +18,7 @@ vim.api.nvim_create_autocmd({"BufEnter", "BufWinEnter"}, {
-- French markdown files -- French markdown files
vim.api.nvim_create_autocmd({"BufEnter", "BufWinEnter"}, { vim.api.nvim_create_autocmd({"BufEnter", "BufWinEnter"}, {
pattern = {"*-fr.md", }, pattern = {"*-fr.md", },
group = markdown,
callback = function() callback = function()
vim.o.spelllang = 'fr' vim.o.spelllang = 'fr'
end end
@ -23,6 +27,7 @@ vim.api.nvim_create_autocmd({"BufEnter", "BufWinEnter"}, {
-- Spell shortcuts -- Spell shortcuts
vim.api.nvim_create_autocmd({"OptionSet"}, { vim.api.nvim_create_autocmd({"OptionSet"}, {
pattern = { "spell" }, pattern = { "spell" },
group = markdown,
callback = function() callback = function()
if vim.o.spell == true then if vim.o.spell == true then
vim.keymap.set("n", "<Leader>i", "mz[s1z=`z", {noremap = true, silent = true}) vim.keymap.set("n", "<Leader>i", "mz[s1z=`z", {noremap = true, silent = true})