Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat] add more language highlighting using two-face #56

Merged
merged 1 commit into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions generator/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions generator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
2 changes: 1 addition & 1 deletion generator/src/components/interface/render_error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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}")]
Expand Down
3 changes: 1 addition & 2 deletions generator/src/highlight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use cosmic_text::{Attrs, Family, Style, Weight};
use syntect::{
easy::HighlightLines,
highlighting::{FontStyle, ThemeSet},
parsing::SyntaxSet,
util::LinesWithEndings,
};

Expand Down Expand Up @@ -37,7 +36,7 @@ impl Highlight {
theme_folder: &str,
theme: &str,
) -> Result<Vec<(&str, Attrs)>, 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 {
Expand Down
Loading