Better syntax highlighting for Rust in Vim
- Vim Script 96.5%
- Python 2.6%
- Dockerfile 0.9%
taylor.fish fork of rust.vim
This is a fork of rust.vim with an updated syntax highlighting file (syntax/rust.vim).
For the original README, see README.orig.md.
Installation
Copy syntax/rust.vim to ~/.vim/syntax/:
git clone https://codeberg.org/taylordotfish/rust.vim
mkdir -p ~/.vim/syntax
cp rust.vim/syntax/rust.vim ~/.vim/syntax/
Changes
- Added ability to customize which edition is used for highlighting.
Set
g:rust_editionbefore the syntax file is loaded; e.g.,let g:rust_edition = 2021orlet g:rust_edition = "latest". - Added support for
safe fn. - Added support for
&raw constand&raw mut. - Added support for
pub(in ...). - Added support for the
genkeyword. (Fixes #521.) - Added support for items added to the prelude in the 2021 and 2024 editions,
like
TryFromandFuture. - Keywords in positions where an item name is expected are now highlighted
(e.g.,
fn do() {}ormod priv;). (Fixes #406.) - Added support for non-ASCII characters in identifiers (
Café::new()). - Added support for
?as a macro repetition operator ($()?). (Fixes #498.) - Fixed highlighting of successive borrow operators (
&&x). - Fixed highlighting of lifetime bounds (
'a: 'b). - Fixed false positive highlighting of child path components as built-in types;
e.g.,
strinstd::str::FromStris a module rather than a type. - Fixed false positive highlighting of enum variants as prelude items; e.g.,
Boxinenum Shape { Box, Sphere }orlet s = Shape::Box. This also applies to associated types, as inlet x: <T as Trait>::String. - Added support for raw identifiers in paths and function calls (
r#foo()). asis now highlighted as a keyword rather than an operator. (Fixes #493.)- Updated list of derive macros.
- Improved highlighting of
async,await,try, anddyn. - Improved highlighting of
impl ... for ...using proper parsing. - Improved detection of turbofish function calls (
f::<T>()). - Improved parsing of attributes (fixes cases like
#[[]]). - Fixed parsing of
/* */*(previously parsed as a comment containing an unclosed nested comment). - Improved detection of which Markdown code blocks should be highlighted as Rust code in doc comments.
- Fixed parsing of multiline attributes and macro repetition expressions
(
$(x)*) inside code blocks in doc comments. - Fixed parsing of non-Rust code blocks in block doc comments (
/** */). - Fixed parsing of doc comments containing an unclosed code block.
- Leading
#characters in doc comment code blocks (to hide lines in rustdoc’s output) are now highlighted. - Added option not to highlight code in doc comments:
let g:rust_highlight_doc_code = 0before the syntax file is loaded. (Fixes #407.) - Reduced stale highlighting when syntactic constructs span multiple
lines by setting
syn sync linebreaksto 1. - Added a distinct syntax group for prelude structs instead of including
them in
rustTrait. - Added highlighting for
?in?Sized. - Reduced false positives in highlighting of assert and panic macros
(
assertiveness!(),paniculate!()). - Removed obsolete syntax.
License
The changes in this repository are licensed under the same license as the original: your choice of either the MIT license or version 2 of the Apache License. For more information, see README.orig.md.