summaryrefslogtreecommitdiffstats
path: root/.config/nvim/lua/user/autocommds.lua
blob: e2452bf33998c4faeba2b31bae3c6972234944a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
local reloadgroup = vim.api.nvim_create_augroup("ReloadGroup", { clear = true })
require'user.remaps'

vim.api.nvim_create_autocmd (
	"BufWritePost",
	{
	group = reloadgroup,
	pattern = "*.tex",
	callback = function()
		vim.system( {'bash', 
		'-c', 
		"echo making > file && latexmk -shell-escape -xelatex " .. vim.fn.expand('%:t') .. " && pkill -HUP mupdf"},
		{detach = true})
	end}
)

vim.api.nvim_create_autocmd (
	{"BufRead", "BufNewFile"}, {
	pattern = {"*.tex"},
	callback = function()
		if (global_inde == nil) then
			global_inde = vim.opt.indentexpr:get()
		end
		vim.bo.autoindent = false
		vim.bo.smartindent = false
		vim.bo.cindent = false
		vim.bo.indentexpr = nil
	end,
})

-- vim.api.nvim_create_autocmd (
-- 	"InsertEnter", {
-- 		once = true,
-- 		group = reloadgroup,
-- 		pattern = "*.tex",
-- 		callback = function()
-- 			vim.system(
-- 				{'latexmk', '-xelatex', '-pvc', vim.fn.expand('%:t')}, 
-- 				{ detach = true })
-- 		end
-- 	}
-- )