-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Current master does not properly highlight Rust source file #906
Comments
This is not a problem with |
https://github.com/rust-lang/rust-enhanced might be better to use (although I don't know if it does any better here) |
Probably it would. How can I try it with the Cargo-installed Also, whatever's highlighting the code on this web page, appears to do a better job. Perhaps it could be used... |
@sharkdp can you switch to https://github.com/rust-lang/rust-enhanced ? Based on the opinion of the 'netizens, it is likely to give better results. If you do switch (and I hope you do) - to get your updates, I should just reinstall |
There is no need to reinstall/recompile |
Following your instructions above and installing the syntaxes - I can confirm that both work fine:
So, either of the two proposed fixes would work (tested). |
Thank you for reporting this upstream (sublimehq/Packages#2323). Given that you are trying to highlight Rust source code with a language feature (const generics) that is not stable and hasn't even finished the design phase (rust-lang/rust#44580), I think that this doesn't really constitute a bug. In this case, I think we can just wait for sublimehq/Packages#2305 to be merged and close this? |
I disagree - the problem seems unrelated to the unstable feature. The fact that you can remove several lines of code (reduce the sample) and still observe the problem seems to confirm it. And it is remedied by the current https://github.com/rust-lang/rust-enhanced
Since you gave me a good workaround (copying the relevant |
How would the smaller example look like? The problem is apparently caused by the string within angle brackets. Without const generics, strings inside angle brackets wouldn't be allowed, right? |
You may be right. Anyway, this thing is supposed to syntax-highlight the source, not to play Regardless, the only thing I care about here is that the sources are properly and comprehensively highlighted. The workaround you suggested works perfectly for me, with a minimal inconvenience. Therefore, IMHO it's OK to patch (or switch from Sublime to RustEnhanced) whenever you think the right time is, if at all. Since my machines all now incorporate the workaround - timeline doesn't matter (for me). |
I deliberately decided against this for the reasons given above. If there is a Rust source code file that compiles on stable Rust, but is highlighted incorrectly by If someone tells me that it is extremely likely that this unstable syntax will make it into stable Rust, I'm also OK with patching the current Rust syntax. I'd rather not have to maintain two Rust syntaxes, if possible. |
Respectfully disagree.
Of course! Nobody's suggesting that. What I recommend is that you ditch the current |
I'm not here to argue, but I think that both tools (syntax validators and syntax highlighters) have a lot in common. You cannot expect a completely invalid syntax to be highlighted properly (whatever that would mean). Some syntaxes in
We're not going to add syntaxes for every possible flavor of every possible programming language out there. That is not feasible (from a maintenance and performance point of view). "Rust nightly" is not (yet) the official version of the language. Its syntax is prone to frequent changes. There is no way we could keep up with that.
Adding new syntaxes adds a maintenance cost and a performance cost (#951). The current Rust syntax has served us well for years. Using a new syntax could lead to all kinds of surprises (e.g. #677 #914 #924 #750).
Note that the Rust syntax is part of sublimehq/Packages, which we either include completely or not at all. But that's not the main point. Maintenance cost (see above) is. Also, we have invested a lot of time in the customization features of |
So? Highlighters are expected to, well, highlight the code even with errors in it.
Let's not go down this rabbit hole. "Completely" invalid and such...
I'm not familiar enough with Your point about "either include completely or not at all" is well-taken. That explains why my proposal may not be feasible.
Yes, you're right. Thanks! |
What version of
bat
are you using?Describe the bug you encountered:
I'm trying to display/highlight the following Rust source file
const-generics.rs
:What is happening - it stops syntax-highlighting after the first
impl<>
is processed:Describe what you expected to happen?
The entire source file highlighted appropriately. Same way, as, e.g., the above source is highlighted by this web page.
How did you install
bat
?$ cargo install bat
The text was updated successfully, but these errors were encountered: