diff --git a/generator/Cargo.lock b/generator/Cargo.lock index ac21f1b..680fa02 100644 --- a/generator/Cargo.lock +++ b/generator/Cargo.lock @@ -407,6 +407,7 @@ dependencies = [ "syntect", "thiserror", "tiny-skia", + "two-face", ] [[package]] @@ -1276,6 +1277,17 @@ version = "0.20.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17f77d76d837a7830fe1d4f12b7b4ba4192c1888001c7164257e4bc6d21d96b4" +[[package]] +name = "two-face" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37bed2135b2459c7eefba72c906d374697eb15949c205f2f124e3636a46b5eeb" +dependencies = [ + "once_cell", + "serde", + "syntect", +] + [[package]] name = "unicode-bidi" version = "0.3.15" diff --git a/generator/Cargo.toml b/generator/Cargo.toml index e4a8bb1..becf5eb 100644 --- a/generator/Cargo.toml +++ b/generator/Cargo.toml @@ -12,6 +12,7 @@ serde = "1.0.197" arboard = {features = ["wayland-data-control"], version = "3.3.2"} thiserror = "1.0.58" regex = "1.10.3" +two-face = "0.3.0" [lib] crate-type = ["cdylib"] diff --git a/generator/src/components/interface/render_error.rs b/generator/src/components/interface/render_error.rs index 22b19a1..28b4420 100644 --- a/generator/src/components/interface/render_error.rs +++ b/generator/src/components/interface/render_error.rs @@ -8,7 +8,7 @@ pub enum RenderError { #[error("Highlight code failed!")] HighlightThemeLoadFailed, - #[error("Find Highlight theme for {0} failed")] + #[error("No such highlight syntax for {0}")] HighlightCodeFailed(String), #[error("Unable to parse unknown background theme {0}")] diff --git a/generator/src/highlight.rs b/generator/src/highlight.rs index 8040b39..935cd89 100644 --- a/generator/src/highlight.rs +++ b/generator/src/highlight.rs @@ -2,7 +2,6 @@ use cosmic_text::{Attrs, Family, Style, Weight}; use syntect::{ easy::HighlightLines, highlighting::{FontStyle, ThemeSet}, - parsing::SyntaxSet, util::LinesWithEndings, }; @@ -37,7 +36,7 @@ impl Highlight { theme_folder: &str, theme: &str, ) -> Result, RenderError> { - let syntax_set = SyntaxSet::load_defaults_newlines(); + let syntax_set = two_face::syntax::extra_newlines(); let theme_set = ThemeSet::load_from_folder(theme_folder) .map_err(|_| RenderError::HighlightThemeLoadFailed)?; let syntax = match &self.extension {