Skip to content

Commit ac4baca

Browse files
committed
Passable nano syntax highlighting
rust.nanorc provides syntax highlighting for Rust. An attempt has been made to make the syntax highlighting look good on both dark and light terminals. Issue #21286.
1 parent 89c4e37 commit ac4baca

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

src/etc/nano/rust.nanorc

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Nano configuration for Rust
2+
# Copyright 2015 The Rust Project Developers.
3+
#
4+
# NOTE: Rules are applied in order: later rules re-colorize matching text.
5+
syntax "rust" "\.rs"
6+
7+
# function definition
8+
color magenta "fn [a-z0-9_]+"
9+
10+
# Reserved words
11+
color yellow "\<(abstract|alignof|as|be|box|break|const|continue|crate|do|else|enum|extern|false|final|fn|for|if|impl|in|let|loop|macro|match|mod|move|mut|offsetof|override|priv|pub|pure|ref|return|sizeof|static|self|struct|super|true|trait|type|typeof|unsafe|unsized|use|virtual|where|while|yield)\>"
12+
13+
# macros
14+
color red "[a-z_]+!"
15+
16+
# Constants
17+
color magenta "[A-Z][A-Z_]+"
18+
19+
# Traits/Enums/Structs/Types/etc.
20+
color magenta "[A-Z][a-z]+"
21+
22+
# Strings
23+
color green "\".*\""
24+
color green start="\".*\\$" end=".*\""
25+
# NOTE: This isn't accurate but matching "#{0,} for the end of the string is too liberal
26+
color green start="r#+\"" end="\"#+"
27+
28+
# Comments
29+
color blue "//.*"
30+
31+
# Attributes
32+
color magenta start="#!\[" end="\]"
33+
34+
# Some common markers
35+
color brightcyan "(XXX|TODO|FIXME|\?\?\?)"

0 commit comments

Comments
 (0)