summaryrefslogtreecommitdiff
path: root/.config/nvim/lua/writing_config.lua
blob: 6380868b36803068cc25973193379cd253f0c026 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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,
})