trishume / syntect

Rust library for syntax highlighting using Sublime Text syntax definitions.
https://docs.rs/syntect
MIT License
1.85k stars 130 forks source link

How to use the .tmTmeme file in the project with Theme #525

Closed thinkingreed closed 3 months ago

thinkingreed commented 3 months ago

I would like to read the .tmTmeme file of assets in the project and use it in the theme, but I do not know how to do it, so I would appreciate if you could teach me how. ■Executed code let theme_set: ThemeSet = from_binary(include_bytes!("assets/test.tmTheme")); *from_binary is the from_binary function of dumps.rs. ■Errors that occur Io(Custom { kind: InvalidInput, error: "corrupt deflate stream" })

keith-hall commented 3 months ago

I think the reason why you are seeing this error is because you are trying to deserialize a single .tmTheme file into a theme set. If you look at https://docs.rs/crate/syntect/latest/source/src/dumps.rs, you'll see it deserializes .packdump files. Probably the correct approach is to - as part of a separate code path - use ThemeSet add_from_folder, then dump_to_file, and then from_binary(include_bytes!( that resulting file.

thinkingreed commented 3 months ago

Thank you for your response. It would have been better to output the .tmTheme file to a dmp file and read that file. solved. I was only thinking about how to read directly from the .tmTheme file. Thank you from the bottom of my heart.