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
|
use serde::{Deserialize, Serialize};
use std::path::PathBuf;
#[derive(Debug, PartialEq, Eq, Clone, Copy, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum BibtexFormatter {
Texlab,
Latexindent,
}
impl Default for BibtexFormatter {
fn default() -> Self {
Self::Texlab
}
}
#[derive(Debug, PartialEq, Eq, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct BibtexFormattingOptions {
pub line_length: Option<i32>,
pub formatter: Option<BibtexFormatter>,
}
#[derive(Debug, PartialEq, Eq, Clone, Default, Serialize, Deserialize)]
pub struct LatexForwardSearchOptions {
pub executable: Option<String>,
pub args: Option<Vec<String>>,
}
#[derive(Debug, PartialEq, Eq, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct LatexLintOptions {
pub on_change: Option<bool>,
pub on_save: Option<bool>,
}
impl LatexLintOptions {
pub fn on_change(&self) -> bool {
self.on_change.unwrap_or(false)
}
pub fn on_save(&self) -> bool {
self.on_save.unwrap_or(false)
}
}
#[derive(Debug, PartialEq, Eq, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct LatexBuildOptions {
pub executable: Option<String>,
pub args: Option<Vec<String>>,
pub on_save: Option<bool>,
pub output_directory: Option<PathBuf>,
pub forward_search_after: Option<bool>,
}
impl LatexBuildOptions {
pub fn executable(&self) -> String {
self.executable
.as_ref()
.map(Clone::clone)
.unwrap_or_else(|| "latexmk".to_owned())
}
pub fn args(&self) -> Vec<String> {
self.args.as_ref().map(Clone::clone).unwrap_or_else(|| {
vec![
"-pdf".to_owned(),
"-interaction=nonstopmode".to_owned(),
"-synctex=1".to_owned(),
]
})
}
pub fn on_save(&self) -> bool {
self.on_save.unwrap_or(false)
}
pub fn forward_search_after(&self) -> bool {
self.forward_search_after.unwrap_or(false)
}
}
#[derive(Debug, PartialEq, Eq, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct LatexOptions {
pub forward_search: Option<LatexForwardSearchOptions>,
pub lint: Option<LatexLintOptions>,
pub build: Option<LatexBuildOptions>,
pub root_directory: Option<PathBuf>,
}
#[derive(Debug, PartialEq, Eq, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct BibtexOptions {
pub formatting: Option<BibtexFormattingOptions>,
}
#[derive(Debug, PartialEq, Eq, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Options {
pub latex: Option<LatexOptions>,
pub bibtex: Option<BibtexOptions>,
}
|