From 59fabd8ca5a0bde7a3c65a6e54403411244ddbaf Mon Sep 17 00:00:00 2001 From: sharkdp Date: Mon, 30 Apr 2018 15:31:27 +0200 Subject: [PATCH] Load assets from the binary --- src/main.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 268c27a9..4797c557 100644 --- a/src/main.rs +++ b/src/main.rs @@ -34,7 +34,7 @@ use console::Term; use directories::ProjectDirs; use git2::{DiffOptions, IntoCString, Repository}; -use syntect::dumps::{dump_to_file, from_reader}; +use syntect::dumps::{dump_to_file, from_binary, from_reader}; use syntect::easy::HighlightFile; use syntect::highlighting::{Theme, ThemeSet}; use syntect::parsing::SyntaxSet; @@ -315,6 +315,17 @@ impl HighlightingAssets { theme_set, }) } + + fn from_binary() -> Self { + let mut syntax_set: SyntaxSet = from_binary(include_bytes!("../assets/syntax_set")); + syntax_set.link_syntaxes(); + let theme_set: ThemeSet = from_binary(include_bytes!("../assets/theme_set")); + + HighlightingAssets { + syntax_set, + theme_set, + } + } } fn run() -> Result<()> { @@ -357,7 +368,7 @@ fn run() -> Result<()> { true_color: is_truecolor_terminal(), }; - let assets = HighlightingAssets::from_cache()?; + let assets = HighlightingAssets::from_binary(); let theme = assets.theme_set.themes.get("Default").ok_or_else(|| { io::Error::new(