1use crate::kind::TexSyntaxKind;
2use oak_core::Language;
3
4pub struct TexLanguage {
6 pub version: TexVersion,
8 pub math_mode: bool,
10 pub packages: bool,
12 pub custom_commands: bool,
14 pub strict: bool,
16}
17
18#[derive(Debug, Clone, Copy, PartialEq, Eq)]
20pub enum TexVersion {
21 Tex,
23 LaTeX,
25 LaTeX2e,
27 XeTeX,
29 LuaTeX,
31 PdfTeX,
33}
34
35impl TexLanguage {
36 pub fn standard() -> Self {
38 Self { version: TexVersion::LaTeX2e, math_mode: true, packages: true, custom_commands: true, strict: false }
39 }
40
41 pub fn tex() -> Self {
43 Self { version: TexVersion::Tex, math_mode: true, packages: false, custom_commands: false, strict: true }
44 }
45
46 pub fn xetex() -> Self {
48 Self { version: TexVersion::XeTeX, math_mode: true, packages: true, custom_commands: true, strict: false }
49 }
50
51 pub fn luatex() -> Self {
53 Self { version: TexVersion::LuaTeX, math_mode: true, packages: true, custom_commands: true, strict: false }
54 }
55
56 pub fn pdftex() -> Self {
58 Self { version: TexVersion::PdfTeX, math_mode: true, packages: true, custom_commands: true, strict: false }
59 }
60
61 pub fn strict() -> Self {
63 Self { version: TexVersion::LaTeX2e, math_mode: true, packages: true, custom_commands: false, strict: true }
64 }
65
66 pub fn with_extensions() -> Self {
68 Self { version: TexVersion::LaTeX2e, math_mode: true, packages: true, custom_commands: true, strict: false }
69 }
70}
71
72impl Language for TexLanguage {
73 type SyntaxKind = TexSyntaxKind;
74 type TypedRoot = ();
75}
76
77impl Default for TexLanguage {
78 fn default() -> Self {
79 Self::standard()
80 }
81}