on master help sign in
Load assets from the binary
commit59fabd8ca5a0bde7a3c65a6e54403411244ddbaf authorsharkdp <davidpeter@web.de> dateMon 30 Apr 2018, 15:31 (9 years ago) parentced6801
1 file changed+13−2
src/main.rs+13−2
src/main.rs+13−2
@@ -34,7 +34,7 @@ use console::Term;
3434use directories::ProjectDirs;
3535use git2::{DiffOptions, IntoCString, Repository};
3636
37−use syntect::dumps::{dump_to_file, from_reader};
37+use syntect::dumps::{dump_to_file, from_binary, from_reader};
3838use syntect::easy::HighlightFile;
3939use syntect::highlighting::{Theme, ThemeSet};
4040use syntect::parsing::SyntaxSet;
@@ -315,6 +315,17 @@ impl HighlightingAssets {
315315 theme_set,
316316 })
317317 }
318+
319+ fn from_binary() -> Self {
320+ let mut syntax_set: SyntaxSet = from_binary(include_bytes!("../assets/syntax_set"));
321+ syntax_set.link_syntaxes();
322+ let theme_set: ThemeSet = from_binary(include_bytes!("../assets/theme_set"));
323+
324+ HighlightingAssets {
325+ syntax_set,
326+ theme_set,
327+ }
328+ }
318329}
319330
320331fn run() -> Result<()> {
@@ -357,7 +368,7 @@ fn run() -> Result<()> {
357368 true_color: is_truecolor_terminal(),
358369 };
359370
360− let assets = HighlightingAssets::from_cache()?;
371+ let assets = HighlightingAssets::from_binary();
361372
362373 let theme = assets.theme_set.themes.get("Default").ok_or_else(|| {
363374 io::Error::new(