summaryrefslogtreecommitdiff
path: root/.config/nvim/lua/writing_config.lua
diff options
context:
space:
mode:
Diffstat (limited to '.config/nvim/lua/writing_config.lua')
-rw-r--r--.config/nvim/lua/writing_config.lua18
1 files changed, 18 insertions, 0 deletions
diff --git a/.config/nvim/lua/writing_config.lua b/.config/nvim/lua/writing_config.lua
new file mode 100644
index 0000000..6380868
--- /dev/null
+++ b/.config/nvim/lua/writing_config.lua
@@ -0,0 +1,18 @@
+vim.api.nvim_create_autocmd("BufWritePost", {
+ pattern = "*.tex",
+ callback = function()
+ -- compile tex file to pdf with pdflatex on save
+ if vim.fn.executable('pdflatex') == 1 then
+ vim.cmd("execute '!pdflatex ' . expand('%:p')")
+ else
+ print("pdflatex is not installed")
+ end
+
+ -- compile tex file to html with pandoc on save
+ if vim.fn.executable('pandoc') == 1 then
+ vim.cmd("execute '!pandoc -o ' . substitute(expand('%:p'), '.tex', '.html ', '') . expand('%:p')")
+ else
+ print("pandoc is not installed")
+ end
+ end,
+})