oak_typst/language/
mod.rs1use crate::{ast::TypstRoot, kind::TypstSyntaxKind};
2use oak_core::Language;
3
4pub struct TypstLanguage {
6 pub math_mode: bool,
8 pub scripting: bool,
10 pub strict: bool,
12 pub target: TypstVersion,
14 pub experimental: bool,
16}
17
18#[derive(Debug, Clone, Copy, PartialEq, Eq)]
20pub enum TypstVersion {
21 V0_1,
22 V0_2,
23 V0_3,
24 V0_4,
25 V0_5,
26 V0_6,
27 V0_7,
28 V0_8,
29 V0_9,
30 V0_10,
31 V0_11,
32 Latest,
33}
34
35impl TypstLanguage {
36 pub fn standard() -> Self {
38 Self { math_mode: false, scripting: false, strict: false, target: TypstVersion::V0_11, experimental: false }
39 }
40
41 pub fn with_math() -> Self {
43 Self { math_mode: true, scripting: false, strict: false, target: TypstVersion::V0_11, experimental: false }
44 }
45
46 pub fn with_scripting() -> Self {
48 Self { math_mode: false, scripting: true, strict: false, target: TypstVersion::V0_11, experimental: false }
49 }
50
51 pub fn strict() -> Self {
53 Self { math_mode: false, scripting: false, strict: true, target: TypstVersion::V0_11, experimental: false }
54 }
55
56 pub fn experimental() -> Self {
58 Self { math_mode: true, scripting: true, strict: true, target: TypstVersion::Latest, experimental: true }
59 }
60}
61
62impl Language for TypstLanguage {
63 type SyntaxKind = TypstSyntaxKind;
64 type TypedRoot = TypstRoot;
65}