bat: bat panics on simple Vue file
When calling bat on this Vue file
<style lang="stylus">
</style>
it panics with:
thread 'main' panicked at
'Can only call resolve on linked references:
ByScope { scope: <source.stylus>, sub_context: None }',
…/syntect-4.1.0/src/parsing/syntax_definition.rs:188:18
found with the Python script in #913.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 1
- Comments: 19 (8 by maintainers)
Commits related to this issue
- Add Stylus syntax closes #915 — committed to sharkdp/bat by sharkdp 4 years ago
- Add Stylus syntax (#917) closes #915 — committed to sharkdp/bat by sharkdp 4 years ago
- Bump to syntect 5.0.0 to e.g. start lazy-loading themes Closes #915 Closes #951 Closes #1846 Closes #1854 — committed to Enselic/bat by Enselic 2 years ago
- Bump to syntect 5.0.0 to e.g. start lazy-loading syntaxes (#2181) * Bump to syntect 5.0.0 to e.g. start lazy-loading themes Closes #915 Closes #951 Closes #1846 Closes #1854 * Typo fix forma... — committed to sharkdp/bat by Enselic 2 years ago
I finally got around polishing the prototype code, and opened a PR with production ready code for syntect that fixes this whole class of bugs: https://github.com/trishume/syntect/pull/427
(Before this is fixed in bat, syntect needs to release 5.0.0 and bat needs to start depending on that release of course, so it might still take a while before this is fixed for bat end-users)
Thank you for reporting this. That’s unfortunate.
It should be possible to somehow verify that syntaxes do not include broken references when building the binary assets. This might need to be fixed upstream (in
syntect).I meet same error with single Vue component file with
pugtemplate syntax.I started work on #1616, and realised the output from syntect wasn’t helpful enough, so I created https://github.com/trishume/syntect/pull/338
Linking to this “version” of syntect, now when building assets in
bat, we get:Here is a working prototype that should fix this and all other panics in the same family, namely panics caused by attempts to embed syntaxes that are missing: https://github.com/Enselic/bat/pull/52
The proposed solution makes
syntectfall back toPlain Textsyntax for embedded syntaxes that are missing, which seems to work well. This also seems to be what Sublime Text is doing in cases like these.The prototype includes a commit that adjust the Vue syntax regression test to also include a snippet of Pug:
Current bat crashes in Vue files with the above, but the prototype handles it well (continues to highlight subsequent Vue code as before).
Further progress on this currently blocked mostly by https://github.com/trishume/syntect/pull/382 which the
syntectcode is based on to reduce future conflicts. But as soon as that is merged I plan on resuming work on this.If you have any concerns with regards to falling back to
Plain Textsyntax in cases like these, I would love to hear them!I’ve created a PR which will add a new API to syntect for this, but I’m sure it could be improved: https://github.com/trishume/syntect/pull/332
See also https://github.com/sharkdp/bat/issues/1492
Turns out it was necessary to also change
styletotemplate. Here is how to reproduce with a one-liner:Understood, thank you. Removed the milestone (which - anyway - was only a suggestion).
@sharkdp Nope, Vue still has unresolved syntaxes (
)
I am still convinced that my proposed approach to solve it “once and for all” (https://github.com/sharkdp/bat/issues/915#issuecomment-950274207) is the right one, but I actually think we should wait with fixing this until after 0.19.0. It is a bit tricky to get the code right in syntect, and trishume seems busy these days, so there is a risk that that work would delay a release several months more in the worst case.
syntect released on Aug 2: https://github.com/trishume/syntect/releases/tag/v4.6.0
A tiny bit of additional code (to print the warnings to the console at asset building time) - I have already made the necessary changes locally, just waiting for a
syntectrelease before I make a PR. Or is it okay to depend on thesyntectgit repository directly?