trishume / syntect

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

Implement extends #536

Open jalil-salame opened 5 months ago

jalil-salame commented 5 months ago

This adds support for the extends keyword which lets the tests pass on Build 4075 as requested in #323. The implementation is very hacky right now:

I am opening this PR on top of #535 to get the fixes to the tests.

I don't know if this is a correct implementation of the extends keyword, specifically, I don't know when contexts are evaluated; the contexts are properly merged, but the variables can be overwritten and thus the context needs to be re-evaluated, I don't know if I need to do something about it, or id the context evaluation is done after the SyntaxSet is built.

I am not happy with the implementation either, but I don't know how to improve it further. I will happily improve it if you have any ideas.

Ideally, SyntaxSetBuilder::build would return an error that indicates the syntax was unable to extend another syntax.