Open ibraheemdev opened 3 years ago
Is this only on Dracula or on any themes? The rust syntax shipped is pretty old.
gruvbox-dark
seems to work fine:
Looks like a bug with the Dracula theme then :/
If this happens to be the outdated syntax tool, perhaps we should add Whitesource or Dependabot to help keep things up-to-date. In the meantime, I'll take a crack at trying to find the root cause, if it happens to be more than just an outdated dep.
There seem to be more issues here too. The variables and identifiers in this code block styled with the charcoal
theme are supposed to be white instead of orange:
Orange is the accent color of this particular Zola site, and previously, the currently active Highlight theme would override the default orange color of this code block text, but not anymore. Not sure if this is a related bug or something deserving of filing a new ticket?
I can confirm that gruvbox-dark
doesn't have the orange text problem for me as well, as @ibraheemdev suggested above. Perhaps there are some bugs with a few of the themes?
Perhaps there are some bugs with a few of the themes?
It's likely. The syntax definitions for Rust for example are also pretty old now as syntect doesn't support the latest features.
Indeed, it looks like a limitation of the parser.
I've tried to adapt a theme, but it's easy to see by using highlight_theme = "css"
in the configuration that the parser is confused about many elements.
I think that if it could at least recognize the keywords (like self
, const
, ...), it may help a little. In the following code:
forward_ref_binop! { impl const Shl, shl for $t, $f }
storage.type.impl.rust
entity.name.impl.rust
, and so 'const' and 'for' cannot be distinguished as language elements.In the function definition below, both 'self' and 'f' are variable.parameter.rust
, so 'self' cannot be distinguished as language element:
fn fmt(&self, f: &mut Formatter<'_>)
The Sublime syntax file is very old, its last modification was done in 2019.
I've tried with another file I found in the rust-lang
repository:
https://github.com/rust-lang/rust-enhanced/blob/master/RustEnhanced.sublime-syntax
(Note: you must rename Rust Enhanced
to Rust
at the top)
Despite that, I find it hard to get any satisfactory result. I don't know if that's a limitation of the parsing system used by Sublime or if it's due to the syntax file itself. For example, the word other
below is in a different group in each case:
z-meta z-block z-rust
:
fn shl(self, other: U) -> T {
self << other
}
z-meta z-group z-rust
(also used for macros...):
fn add_mod(self, other: Self, m: Self) -> Self::Output {
(self + other) % m
}
So either I leave many groups in the same neutral colour, or it ends up in a mess of inconcistent colours.
Has anyone tried other recent syntax files?
This issue doesn't seem to be active anymore. For anyone looking for a fix, I'll just include my modified version of Rust.sublime-syntax
, that I patched to get slightly better results for the Rust language.
self
to variable.language.rust to distinguish it from other parameterslet
, const
, and static
which were storage.type.rust (that includes a lot of other things like identifiers), and moved them to keyword.other.rust.This file replaces sublime\syntaxes\Packages\Rust\Rust.sublime-syntax, which is in a Git submodule. I won't commit it in its original repository since it likely breaks some tests and is incompatible with older versions. The fact it's a submodule of Zola also makes it more complicated to update here - I'm using a custom version that I compiled to generate websites.
The packed file must be rebuilt after each modification of the syntax file, before compiling Zola:
cd components\config
cargo run --example generate_sublime synpack ../../sublime/syntaxes ../../sublime/syntaxes/newlines.packdump
To get optimal results, it's best to adapt the theme file but it should already give better results with existing themes.
The syntax highlighting Dracula theme currently underlines a lot of code that should not be underlined. This is an example
rust
code block: