summaryrefslogtreecommitdiff
path: root/support/texlab/crates/parser/src/config.rs
blob: 95b3e4eb56e2eb0e9604b1a674f7086ce21ece8c (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
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
use rustc_hash::FxHashSet;

#[derive(Debug)]
pub struct SyntaxConfig {
    pub follow_package_links: bool,
    pub math_environments: FxHashSet<String>,
    pub enum_environments: FxHashSet<String>,
    pub verbatim_environments: FxHashSet<String>,
    pub citation_commands: FxHashSet<String>,
    pub label_definition_commands: FxHashSet<String>,
    pub label_definition_prefixes: Vec<(String, String)>,
    pub label_reference_commands: FxHashSet<String>,
    pub label_reference_prefixes: Vec<(String, String)>,
}

impl Default for SyntaxConfig {
    fn default() -> Self {
        let math_environments = DEFAULT_MATH_ENVIRONMENTS
            .iter()
            .map(ToString::to_string)
            .collect();

        let enum_environments = DEFAULT_ENUM_ENVIRONMENTS
            .iter()
            .map(ToString::to_string)
            .collect();

        let verbatim_environments = DEFAULT_VERBATIM_ENVIRONMENTS
            .iter()
            .map(ToString::to_string)
            .collect();

        let citation_commands = DEFAULT_CITATION_COMMANDS
            .iter()
            .map(ToString::to_string)
            .collect();

        let label_definition_commands = DEFAULT_LABEL_DEFINITION_COMMANDS
            .iter()
            .map(ToString::to_string)
            .collect();

        let label_definition_prefixes = DEFAULT_LABEL_DEFINITION_PREFIXES
            .iter()
            .map(|(x, y)| (ToString::to_string(x), ToString::to_string(y)))
            .collect();

        let label_reference_commands = DEFAULT_LABEL_REFERENCE_COMMANDS
            .iter()
            .map(ToString::to_string)
            .collect();

        let label_reference_prefixes = DEFAULT_LABEL_REFERENCE_PREFIXES
            .iter()
            .map(|(x, y)| (ToString::to_string(x), ToString::to_string(y)))
            .collect();

        Self {
            follow_package_links: false,
            math_environments,
            enum_environments,
            verbatim_environments,
            citation_commands,
            label_definition_commands,
            label_definition_prefixes,
            label_reference_commands,
            label_reference_prefixes,
        }
    }
}

static DEFAULT_MATH_ENVIRONMENTS: &[&str] = &[
    "align",
    "align*",
    "alignat",
    "alignat*",
    "aligned",
    "aligned*",
    "alignedat",
    "alignedat*",
    "array",
    "array*",
    "bmatrix",
    "Bmatrix",
    "bmatrix*",
    "Bmatrix*",
    "cases",
    "cases*",
    "CD",
    "CD*",
    "eqnarray",
    "eqnarray*",
    "equation",
    "equation*",
    "flalign",
    "flalign*",
    "gather",
    "gather*",
    "gathered",
    "gathered*",
    "IEEEeqnarray",
    "IEEEeqnarray*",
    "matrix",
    "matrix*",
    "multline",
    "multline*",
    "pmatrix",
    "pmatrix*",
    "smallmatrix",
    "smallmatrix*",
    "split",
    "split*",
    "subarray",
    "subarray*",
    "subequations",
    "subequations*",
    "vmatrix",
    "Vmatrix",
    "vmatrix*",
    "Vmatrix*",
];

static DEFAULT_ENUM_ENVIRONMENTS: &[&str] = &["enumerate", "itemize", "description"];

static DEFAULT_VERBATIM_ENVIRONMENTS: &[&str] =
    &["pycode", "minted", "asy", "lstlisting", "verbatim"];

static DEFAULT_CITATION_COMMANDS: &[&str] = &[
    "cite",
    "cite*",
    "Cite",
    "nocite",
    "citet",
    "citet*",
    "citep",
    "citep*",
    "citeauthor",
    "citeauthor*",
    "Citeauthor",
    "Citeauthor*",
    "citetitle",
    "citetitle*",
    "citeyear",
    "citeyear*",
    "citedate",
    "citedate*",
    "citeurl",
    "fullcite",
    "citeyearpar",
    "citealt",
    "citealp",
    "citetext",
    "parencite",
    "parencite*",
    "Parencite",
    "footcite",
    "footfullcite",
    "footcitetext",
    "textcite",
    "Textcite",
    "smartcite",
    "supercite",
    "autocite",
    "autocite*",
    "Autocite",
    "Autocite*",
    "volcite",
    "Volcite",
    "pvolcite",
    "Pvolcite",
    "fvolcite",
    "ftvolcite",
    "svolcite",
    "Svolcite",
    "tvolcite",
    "Tvolcite",
    "avolcite",
    "Avolcite",
    "notecite",
    "pnotecite",
    "Pnotecite",
    "fnotecite",
    "citeA",
    "citeA*",
];

static DEFAULT_LABEL_DEFINITION_COMMANDS: &[&str] = &["label", "zlabel"];

static DEFAULT_LABEL_DEFINITION_PREFIXES: &[(&str, &str)] = &[];

static DEFAULT_LABEL_REFERENCE_COMMANDS: &[&str] = &[
    "ref",
    "vref",
    "Vref",
    "autoref",
    "pageref",
    "cref",
    "cref*",
    "Cref",
    "Cref*",
    "zcref",
    "zcref*",
    "zcpageref",
    "zcpageref*",
    "namecref",
    "nameCref",
    "lcnamecref",
    "namecrefs",
    "nameCrefs",
    "lcnamecrefs",
    "labelcref",
    "labelcpageref",
    "eqref",
];

static DEFAULT_LABEL_REFERENCE_PREFIXES: &[(&str, &str)] = &[];