Skip to main content

oak_org_mode/language/
mod.rs

1use oak_core::{Language, LanguageCategory};
2use std::{
3    string::{String, ToString},
4    vec,
5    vec::Vec,
6};
7
8#[derive(Debug, Clone)]
9pub struct OrgModeLanguage {
10    pub todo_keywords: Vec<String>,
11    pub done_keywords: Vec<String>,
12    pub strict_mode: bool,
13}
14
15impl OrgModeLanguage {
16    pub fn new() -> Self {
17        Self { todo_keywords: vec!["TODO".to_string(), "NEXT".to_string(), "WAITING".to_string()], done_keywords: vec!["DONE".to_string(), "CANCELLED".to_string()], strict_mode: false }
18    }
19
20    pub fn with_todo_keywords(mut self, keywords: Vec<String>) -> Self {
21        self.todo_keywords = keywords;
22        self
23    }
24
25    pub fn with_done_keywords(mut self, keywords: Vec<String>) -> Self {
26        self.done_keywords = keywords;
27        self
28    }
29
30    pub fn with_strict_mode(mut self, strict: bool) -> Self {
31        self.strict_mode = strict;
32        self
33    }
34}
35
36impl Default for OrgModeLanguage {
37    fn default() -> Self {
38        Self {
39            todo_keywords: vec!["TODO".to_string(), "NEXT".to_string(), "WAITING".to_string()],
40            done_keywords: vec!["DONE".to_string(), "CANCELLED".to_string()],
41            strict_mode: false,
42        }
43    }
44}
45
46impl Language for OrgModeLanguage {
47    const NAME: &'static str = "org-mode";
48    const CATEGORY: LanguageCategory = LanguageCategory::Markup;
49
50    type TokenType = crate::kind::OrgModeSyntaxKind;
51    type ElementType = crate::kind::OrgModeSyntaxKind;
52    type TypedRoot = ();
53}