Compare commits

...

2 commits

Author SHA1 Message Date
able fe4ab556f8 fix hblang highlighting to match current lang 2024-05-12 08:28:51 -05:00
able d836f2f145 support hblang 2024-05-11 18:05:38 -05:00
3 changed files with 118 additions and 82 deletions

View file

@ -1,3 +1,3 @@
[toolchain]
channel = "nightly"
channel = "nightly-2023-09-17"
components = ["rust-src", "llvm-tools"]

View file

@ -19,7 +19,7 @@ impl Config<'static> {
let mut engine = Engine::new();
let mut scope = Scope::new();
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();
let result = engine.call_fn::<Dynamic>(&mut scope, &ast, "status_bar", ());

View file

@ -32,7 +32,11 @@ impl FileType {
&self.hl_opts
}
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 {
name: String::from("Rust"),
hl_opts: HighlightingOptions {
@ -111,8 +115,40 @@ impl FileType {
"f64".to_string(),
],
},
}
}
"hb" => {
return Self {
name: String::from("HBLang"),
hl_opts: HighlightingOptions {
numbers: true,
strings: true,
characters: true,
comments: true,
multiline_comments: true,
primary_keywords: vec![
"if".to_string(),
"else".to_string(),
"return".to_string(),
"loop".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(),
],
},
};
}
_ => return Self::default(),
}
}
Self::default()
}
}