nvim-config-kickstart/lua/autocommands.lua

42 lines
1.4 KiB
Lua

local markdown = vim.api.nvim_create_augroup("markdown", { clear = true })
-- Recognize .md as pandoc
vim.api.nvim_create_autocmd({"BufEnter", "BufWinEnter"}, {
pattern = {"*.md", },
group = markdown,
callback = function()
vim.o.filetype = 'pandoc'
require('luasnip').filetype_extend("pandoc", {"markdown"})
vim.o.spell = true
vim.o.spelllang = 'en'
vim.o.formatoptions = "qj"
-- email commands: my/msy to paste the html inside the clipboard
vim.keymap.set('', '<LocalLeader>msy', ':w !pandoc -f markdown+emoji -t html5 -s | wl-copy<CR><CR>', { noremap = true, silent = true })
vim.keymap.set('', '<LocalLeader>my', ':w !pandoc -f markdown+emoji --wrap=none -t html5 | wl-copy<CR><CR>', { noremap = true, silent = true })
end
})
-- French markdown files
vim.api.nvim_create_autocmd({"BufEnter", "BufWinEnter"}, {
pattern = {"*-fr.md", },
group = markdown,
callback = function()
vim.o.spelllang = 'fr'
end
})
-- Spell shortcuts
vim.api.nvim_create_autocmd({"OptionSet"}, {
pattern = { "spell" },
group = markdown,
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
})