-
-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathtex.lua
More file actions
105 lines (98 loc) · 2.54 KB
/
tex.lua
File metadata and controls
105 lines (98 loc) · 2.54 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
--- LaTeX actions
local M = {}
--- Frontend - options displayed on telescope
M.options = {
{ text = "Build PDF", value = "option1" },
{ text = "Clean auxiliary files", value = "option2" },
{ text = "Clean all generated files", value = "option3" },
}
--- Backend - overseer tasks performed on option selected
function M.action(selected_option)
local overseer = require("overseer")
local utils = require("compiler.utils")
local entry_point = vim.fn.expand("%:p")
local entry_dir = vim.fn.fnamemodify(entry_point, ":h")
local file_name = vim.fn.fnamemodify(entry_point, ":t")
local file_root = vim.fn.fnamemodify(entry_point, ":r")
local final_message = "--task finished--"
local rm_cmd = (vim.loop.os_uname().sysname == "Windows_NT") and "del /Q" or "rm -f"
local cd_cmd = (vim.loop.os_uname().sysname == "Windows_NT") and "cd /d" or "cd"
if selected_option == "option1" then
-- 使用 latexmk 编译 PDF
local task = overseer.new_task({
name = "- LaTeX build",
strategy = {
"orchestrator",
tasks = {
{
name = '- Build PDF → "' .. file_name .. '"',
cmd = cd_cmd
.. ' "'
.. entry_dir
.. '"'
.. ' && latexmk -pdf -interaction=nonstopmode -file-line-error "'
.. file_name
.. '"'
.. ' && echo "'
.. entry_point
.. '"'
.. ' && echo "'
.. final_message
.. '"',
components = { "default_extended" },
},
},
},
})
task:start()
elseif selected_option == "option2" then
local task = overseer.new_task({
name = "- LaTeX clean aux",
strategy = {
"orchestrator",
tasks = {
{
name = '- Clean aux files → "' .. file_name .. '"',
cmd = cd_cmd
.. ' "'
.. entry_dir
.. '"'
.. ' && latexmk -c "'
.. file_name
.. '"'
.. ' && echo "'
.. final_message
.. '"',
components = { "default_extended" },
},
},
},
})
task:start()
elseif selected_option == "option3" then
local task = overseer.new_task({
name = "- LaTeX clean all",
strategy = {
"orchestrator",
tasks = {
{
name = '- Clean all files → "' .. file_name .. '"',
cmd = cd_cmd
.. ' "'
.. entry_dir
.. '"'
.. ' && latexmk -C "'
.. file_name
.. '"'
.. ' && echo "'
.. final_message
.. '"',
components = { "default_extended" },
},
},
},
})
task:start()
end
end
return M