js highlighting

This commit is contained in:
WanderingPenwing 2024-02-28 18:04:44 +01:00
parent b84cde8e2b
commit f95d44ec69
4 changed files with 217 additions and 189 deletions

View file

@ -399,6 +399,7 @@ fn to_syntax(language: &str) -> Syntax {
match language {
"py" => Syntax::python(),
"rs" => Syntax::rust(),
"js" => Syntax::javascript(),
_ => Syntax::shell(),
}
}

View file

@ -0,0 +1,24 @@
use super::Syntax;
use std::collections::BTreeSet;
impl Syntax {
pub fn javascript() -> Syntax {
Syntax {
language: "Javascript",
case_sensitive: true,
comment: "//",
comment_multiline: ["/*", "*/"],
keywords: BTreeSet::from([
"&&", "||", "!", "let", "var", "abstract", "arguments", "await", "break", "case", "catch", "class", "const", "continue",
"debugger", "default", "delete", "do", "else", "enum", "eval", "export", "extends", "final", "finally", "for", "function",
"goto", "if", "implements", "import", "in", "instanceof", "interface", "let", "native", "new", "package", "private", "protected",
"public", "return", "static", "super", "switch", "synchronized", "this","throw", "throws", "transient", "try", "typeof",
"var", "volatile", "while", "with", "yield",
]),
types: BTreeSet::from([
"Boolean", "Number", "BigInt", "Undefined", "Null", "String", "Symbol", "byte", "char", "float", "int", "long", "short", "void",
]),
special: BTreeSet::from(["false", "null", "true"]),
}
}
}

View file

@ -1,5 +1,6 @@
#![allow(dead_code)]
pub mod asm;
pub mod javascript;
pub mod lua;
pub mod python;
pub mod rust;

View file

@ -27,6 +27,8 @@ impl ShortcutsWindow {
ui.separator();
ui.label("Ctrl+F : open search window");
ui.separator();
ui.label("Ctrl+T : reload tree");
ui.separator();
ui.label("Ctrl+Z : undo");
ui.label("Ctrl+Y : redo");
ui.label("Tab on selection : add indent of selection");