2023-12-24 21:42:24 +00:00
|
|
|
local markdown = vim.api.nvim_create_augroup("markdown", { clear = true })
|
|
|
|
|
2023-12-25 09:11:44 +00:00
|
|
|
local keyunmap = function(mode, binding)
|
|
|
|
print(vim.inspect(vim.fn.maparg(binding, mode)))
|
|
|
|
if vim.fn.maparg(binding, mode) ~= "" then
|
|
|
|
vim.keymap.del(mode, binding)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-12-24 20:48:21 +00:00
|
|
|
-- Recognize .md as pandoc
|
|
|
|
vim.api.nvim_create_autocmd({"BufEnter", "BufWinEnter"}, {
|
|
|
|
pattern = {"*.md", },
|
2023-12-24 21:42:24 +00:00
|
|
|
group = markdown,
|
2023-12-24 20:48:21 +00:00
|
|
|
callback = function()
|
|
|
|
vim.o.filetype = 'pandoc'
|
2023-12-24 22:36:46 +00:00
|
|
|
require('luasnip').filetype_extend("pandoc", {"markdown"})
|
2023-12-24 20:48:21 +00:00
|
|
|
vim.o.spell = true
|
|
|
|
vim.o.spelllang = 'en'
|
2023-12-24 21:40:34 +00:00
|
|
|
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 })
|
2023-12-24 20:48:21 +00:00
|
|
|
end
|
|
|
|
})
|
|
|
|
|
|
|
|
-- French markdown files
|
|
|
|
vim.api.nvim_create_autocmd({"BufEnter", "BufWinEnter"}, {
|
|
|
|
pattern = {"*-fr.md", },
|
2023-12-24 21:42:24 +00:00
|
|
|
group = markdown,
|
2023-12-24 20:48:21 +00:00
|
|
|
callback = function()
|
|
|
|
vim.o.spelllang = 'fr'
|
|
|
|
end
|
|
|
|
})
|
|
|
|
|
|
|
|
-- Spell shortcuts
|
|
|
|
vim.api.nvim_create_autocmd({"OptionSet"}, {
|
|
|
|
pattern = { "spell" },
|
2023-12-24 21:42:24 +00:00
|
|
|
group = markdown,
|
2023-12-24 20:48:21 +00:00
|
|
|
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
|
2023-12-25 09:11:44 +00:00
|
|
|
keyunmap("n", "<Leader>i")
|
|
|
|
keyunmap("n", "à")
|
2023-12-24 20:48:21 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
})
|