nvim-config-kickstart/lua/autocommands.lua

60 lines
1.9 KiB
Lua
Raw Normal View History

2023-12-24 21:42:24 +00:00
local markdown = vim.api.nvim_create_augroup("markdown", { clear = true })
local spelling = vim.api.nvim_create_augroup("spelling", { clear = true })
2023-12-24 20:48:21 +00:00
-- Recognize .md as pandoc
2023-12-25 13:29:10 +00:00
vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, {
pattern = { "*.md", },
2023-12-24 21:42:24 +00:00
group = markdown,
2023-12-25 13:29:10 +00:00
callback = function()
2023-12-24 20:48:21 +00:00
vim.o.filetype = 'pandoc'
2023-12-25 13:29:10 +00:00
require('luasnip').filetype_extend("pandoc", { "markdown" })
2023-12-24 20:48:21 +00:00
vim.o.spell = true
2023-12-25 15:09:06 +00:00
require('spelling').spell_keymap()
2023-12-24 20:48:21 +00:00
vim.o.spelllang = 'en'
vim.o.formatoptions = "qj"
-- email commands: my/msy to paste the html inside the clipboard
2023-12-25 13:29:10 +00:00
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
2023-12-25 13:29:10 +00:00
vim.api.nvim_create_autocmd({ "BufEnter", "BufWinEnter" }, {
pattern = { "*-fr.md", },
2023-12-24 21:42:24 +00:00
group = markdown,
2023-12-25 13:29:10 +00:00
callback = function()
2023-12-24 20:48:21 +00:00
vim.o.spelllang = 'fr'
end
})
-- Spell shortcuts
2023-12-25 13:29:10 +00:00
vim.api.nvim_create_autocmd({ "OptionSet" }, {
2023-12-24 20:48:21 +00:00
pattern = { "spell" },
group = spelling,
callback = require('spelling').spell_keymap
2023-12-24 20:48:21 +00:00
})
-- LaTeX configuration
local texgroup = vim.api.nvim_create_augroup("latex", { clear = true })
vim.api.nvim_create_autocmd("FileType", {
2023-12-25 15:09:06 +00:00
pattern = { "latex", "tex" },
group = texgroup,
callback = function()
-- vimtex configuration
vim.g.vimtex_view_method = 'zathura'
2023-12-25 13:29:10 +00:00
vim.g.maplocalleader = ' '
-- Legacy shortcut from my vim-latexsuite days
2023-12-25 13:29:10 +00:00
vim.api.nvim_set_keymap("n", "<Leader>ls", ":VimtexView<CR>",
{ noremap = true, silent = true, desc = 'View [L]atex Document' })
vim.o.foldmethod = 'expr'
2023-12-25 13:29:10 +00:00
vim.o.foldexpr = 'vimtex#fold#level(v:lnum)'
vim.o.foldtext = 'vimtex#fold#text()'
vim.o.spell = true
2023-12-25 15:09:06 +00:00
require('spelling').spell_keymap()
end,
})