Rust lexer confuses "str" in different circumstances

In Rust str is a type but also it is a scope, as in use std::str::from_utf8;. For now Kate highlights str in both cases as if it was a type. Is there a way to fix it or edit the lexer yourself?

I believe so. The definition for Kate’s syntax highlighting is in Frameworks / Syntax Highlighting Engine · GitLab, the README links to all docs related to how to change a syntax highlighting definition.

See Working with Syntax Highlighting

You can take the default syntax file from the official repo and then modify it.

I use Kate preinstalled with KDE Plasma, and tried placing a modified stock Rust lexer into ~/.local/share/org.kde.syntax-highlighting/syntax/ folder, but Kate doesn’t use it.
If I name the language Rust it just skips it altogether, if I name it something else, it doesn’t apply it by default, even though I changed the priority.

If you keep the name but increase the version, does it work in that case?

Yes, thanks, that did help.

To fix the main issue stated in this post, you just have to move <RegExpr String="&scope1;|&scope2;" attribute="Scope"/> rule within the “Normal” context above <keyword String="keywords" attribute="Keyword" context="#stay"/> rule.

At this point I can’t see any issue with that change.

If you could provide a merge request with an extended test case that would be cool.

“Extended test case” in this context would be a rust code file containing all possible code needed to confirm the correctness of changes in lexer file, or an automated test in C++/Qt?

It would mean extending the rust file

Not sure if I did everything correctly, but I did it.