fix hblang highlighting to match current lang

This commit is contained in:
able 2024-05-12 08:28:51 -05:00
parent d836f2f145
commit fe4ab556f8
2 changed files with 116 additions and 101 deletions

View file

@ -19,7 +19,7 @@ impl Config<'static> {
let mut engine = Engine::new(); let mut engine = Engine::new();
let mut scope = Scope::new(); let mut scope = Scope::new();
let ast = engine let ast = engine
.compile_file(PathBuf::from_str("assets/config.rhai").unwrap()) .compile_file(PathBuf::from_str("/home/able/Projects/adit/assets/config.rhai").unwrap())
.unwrap(); .unwrap();
let result = engine.call_fn::<Dynamic>(&mut scope, &ast, "status_bar", ()); let result = engine.call_fn::<Dynamic>(&mut scope, &ast, "status_bar", ());

View file

@ -32,7 +32,11 @@ impl FileType {
&self.hl_opts &self.hl_opts
} }
pub fn from(file_name: &str) -> Self { pub fn from(file_name: &str) -> Self {
if file_name.ends_with(".rs") { let ext = file_name.split('.').last();
if ext.is_some() {
let ext = ext.unwrap();
match ext {
"rs" => {
return Self { return Self {
name: String::from("Rust"), name: String::from("Rust"),
hl_opts: HighlightingOptions { hl_opts: HighlightingOptions {
@ -111,9 +115,9 @@ impl FileType {
"f64".to_string(), "f64".to_string(),
], ],
}, },
};
} }
if file_name.ends_with(".hb") { }
"hb" => {
return Self { return Self {
name: String::from("HBLang"), name: String::from("HBLang"),
hl_opts: HighlightingOptions { hl_opts: HighlightingOptions {
@ -128,12 +132,23 @@ impl FileType {
"return".to_string(), "return".to_string(),
"loop".to_string(), "loop".to_string(),
"break".to_string(), "break".to_string(),
"struct".to_string(),
],
secondary_keywords: vec![
":=".to_string(),
"void".to_string(),
"never".to_string(),
"int".to_string(),
"bool".to_string(),
], ],
secondary_keywords: vec![":=".to_string(), "int".to_string()],
}, },
}; };
} }
_ => return Self::default(),
}
}
Self::default() Self::default()
} }
} }