diff options
Diffstat (limited to 'crates/ra_ide/src/syntax_highlighting')
-rw-r--r-- | crates/ra_ide/src/syntax_highlighting/html.rs | 20 | ||||
-rw-r--r-- | crates/ra_ide/src/syntax_highlighting/tags.rs | 94 | ||||
-rw-r--r-- | crates/ra_ide/src/syntax_highlighting/tests.rs | 2 |
3 files changed, 63 insertions, 53 deletions
diff --git a/crates/ra_ide/src/syntax_highlighting/html.rs b/crates/ra_ide/src/syntax_highlighting/html.rs index 210d9a57b..54678c278 100644 --- a/crates/ra_ide/src/syntax_highlighting/html.rs +++ b/crates/ra_ide/src/syntax_highlighting/html.rs | |||
@@ -80,25 +80,27 @@ const STYLE: &str = " | |||
80 | body { margin: 0; } | 80 | body { margin: 0; } |
81 | pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padding: 0.4em; } | 81 | pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padding: 0.4em; } |
82 | 82 | ||
83 | |||
83 | .comment { color: #7F9F7F; } | 84 | .comment { color: #7F9F7F; } |
84 | .string { color: #CC9393; } | 85 | .struct, .enum { color: #7CB8BB; } |
86 | .enum_variant { color: #BDE0F3; } | ||
87 | .string_literal { color: #CC9393; } | ||
85 | .field { color: #94BFF3; } | 88 | .field { color: #94BFF3; } |
86 | .function { color: #93E0E3; } | 89 | .function { color: #93E0E3; } |
87 | .parameter { color: #94BFF3; } | 90 | .parameter { color: #94BFF3; } |
88 | .text { color: #DCDCCC; } | 91 | .text { color: #DCDCCC; } |
89 | .type { color: #7CB8BB; } | 92 | .type { color: #7CB8BB; } |
90 | .type.builtin { color: #8CD0D3; } | 93 | .builtin_type { color: #8CD0D3; } |
91 | .type.param { color: #20999D; } | 94 | .type_param { color: #DFAF8F; } |
92 | .attribute { color: #94BFF3; } | 95 | .attribute { color: #94BFF3; } |
93 | .literal { color: #BFEBBF; } | 96 | .numeric_literal { color: #BFEBBF; } |
94 | .literal.numeric { color: #6A8759; } | ||
95 | .macro { color: #94BFF3; } | 97 | .macro { color: #94BFF3; } |
96 | .module { color: #AFD8AF; } | 98 | .module { color: #AFD8AF; } |
97 | .variable { color: #DCDCCC; } | 99 | .variable { color: #DCDCCC; } |
98 | .variable.mut { color: #DCDCCC; text-decoration: underline; } | 100 | .mutable { text-decoration: underline; } |
99 | 101 | ||
100 | .keyword { color: #F0DFAF; } | 102 | .keyword { color: #F0DFAF; font-weight: bold; } |
101 | .keyword.unsafe { color: #DFAF8F; } | 103 | .keyword.unsafe { color: #BC8383; font-weight: bold; } |
102 | .keyword.control { color: #F0DFAF; font-weight: bold; } | 104 | .control { font-style: italic; } |
103 | </style> | 105 | </style> |
104 | "; | 106 | "; |
diff --git a/crates/ra_ide/src/syntax_highlighting/tags.rs b/crates/ra_ide/src/syntax_highlighting/tags.rs index 383c74c98..9da80823c 100644 --- a/crates/ra_ide/src/syntax_highlighting/tags.rs +++ b/crates/ra_ide/src/syntax_highlighting/tags.rs | |||
@@ -14,59 +14,71 @@ pub struct HighlightModifiers(u32); | |||
14 | 14 | ||
15 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] | 15 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] |
16 | pub enum HighlightTag { | 16 | pub enum HighlightTag { |
17 | Attribute, | ||
18 | BuiltinType, | ||
19 | ByteLiteral, | ||
20 | CharLiteral, | ||
21 | Comment, | ||
22 | Constant, | ||
23 | Enum, | ||
24 | EnumVariant, | ||
17 | Field, | 25 | Field, |
18 | Function, | 26 | Function, |
19 | Module, | 27 | Keyword, |
20 | Constant, | 28 | Lifetime, |
21 | Macro, | 29 | Macro, |
22 | Variable, | 30 | Module, |
23 | 31 | NumericLiteral, | |
24 | Type, | 32 | SelfType, |
25 | TypeSelf, | 33 | Static, |
34 | StringLiteral, | ||
35 | Struct, | ||
36 | Trait, | ||
37 | TypeAlias, | ||
26 | TypeParam, | 38 | TypeParam, |
27 | TypeLifetime, | 39 | Union, |
28 | 40 | Local, | |
29 | LiteralByte, | ||
30 | LiteralNumeric, | ||
31 | LiteralChar, | ||
32 | |||
33 | Comment, | ||
34 | LiteralString, | ||
35 | Attribute, | ||
36 | |||
37 | Keyword, | ||
38 | } | 41 | } |
39 | 42 | ||
40 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] | 43 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] |
41 | #[repr(u8)] | 44 | #[repr(u8)] |
42 | pub enum HighlightModifier { | 45 | pub enum HighlightModifier { |
43 | Mutable = 0, | ||
44 | Unsafe, | ||
45 | /// Used with keywords like `if` and `break`. | 46 | /// Used with keywords like `if` and `break`. |
46 | Control, | 47 | Control = 0, |
47 | Builtin, | 48 | /// `foo` in `fn foo(x: i32)` is a definition, `foo` in `foo(90 + 2)` is |
49 | /// not. | ||
50 | Definition, | ||
51 | Mutable, | ||
52 | Unsafe, | ||
48 | } | 53 | } |
49 | 54 | ||
50 | impl HighlightTag { | 55 | impl HighlightTag { |
51 | fn as_str(self) -> &'static str { | 56 | fn as_str(self) -> &'static str { |
52 | match self { | 57 | match self { |
58 | HighlightTag::Attribute => "attribute", | ||
59 | HighlightTag::BuiltinType => "builtin_type", | ||
60 | HighlightTag::ByteLiteral => "byte_literal", | ||
61 | HighlightTag::CharLiteral => "char_literal", | ||
62 | HighlightTag::Comment => "comment", | ||
63 | HighlightTag::Constant => "constant", | ||
64 | HighlightTag::Enum => "enum", | ||
65 | HighlightTag::EnumVariant => "enum_variant", | ||
53 | HighlightTag::Field => "field", | 66 | HighlightTag::Field => "field", |
54 | HighlightTag::Function => "function", | 67 | HighlightTag::Function => "function", |
55 | HighlightTag::Module => "module", | ||
56 | HighlightTag::Constant => "constant", | ||
57 | HighlightTag::Macro => "macro", | ||
58 | HighlightTag::Variable => "variable", | ||
59 | HighlightTag::Type => "type", | ||
60 | HighlightTag::TypeSelf => "type.self", | ||
61 | HighlightTag::TypeParam => "type.param", | ||
62 | HighlightTag::TypeLifetime => "type.lifetime", | ||
63 | HighlightTag::LiteralByte => "literal.byte", | ||
64 | HighlightTag::LiteralNumeric => "literal.numeric", | ||
65 | HighlightTag::LiteralChar => "literal.char", | ||
66 | HighlightTag::Comment => "comment", | ||
67 | HighlightTag::LiteralString => "string", | ||
68 | HighlightTag::Attribute => "attribute", | ||
69 | HighlightTag::Keyword => "keyword", | 68 | HighlightTag::Keyword => "keyword", |
69 | HighlightTag::Lifetime => "lifetime", | ||
70 | HighlightTag::Macro => "macro", | ||
71 | HighlightTag::Module => "module", | ||
72 | HighlightTag::NumericLiteral => "numeric_literal", | ||
73 | HighlightTag::SelfType => "self_type", | ||
74 | HighlightTag::Static => "static", | ||
75 | HighlightTag::StringLiteral => "string_literal", | ||
76 | HighlightTag::Struct => "struct", | ||
77 | HighlightTag::Trait => "trait", | ||
78 | HighlightTag::TypeAlias => "type_alias", | ||
79 | HighlightTag::TypeParam => "type_param", | ||
80 | HighlightTag::Union => "union", | ||
81 | HighlightTag::Local => "variable", | ||
70 | } | 82 | } |
71 | } | 83 | } |
72 | } | 84 | } |
@@ -78,19 +90,15 @@ impl fmt::Display for HighlightTag { | |||
78 | } | 90 | } |
79 | 91 | ||
80 | impl HighlightModifier { | 92 | impl HighlightModifier { |
81 | const ALL: &'static [HighlightModifier] = &[ | 93 | const ALL: &'static [HighlightModifier] = |
82 | HighlightModifier::Mutable, | 94 | &[HighlightModifier::Mutable, HighlightModifier::Unsafe, HighlightModifier::Control]; |
83 | HighlightModifier::Unsafe, | ||
84 | HighlightModifier::Control, | ||
85 | HighlightModifier::Builtin, | ||
86 | ]; | ||
87 | 95 | ||
88 | fn as_str(self) -> &'static str { | 96 | fn as_str(self) -> &'static str { |
89 | match self { | 97 | match self { |
98 | HighlightModifier::Control => "control", | ||
99 | HighlightModifier::Definition => "declaration", | ||
90 | HighlightModifier::Mutable => "mutable", | 100 | HighlightModifier::Mutable => "mutable", |
91 | HighlightModifier::Unsafe => "unsafe", | 101 | HighlightModifier::Unsafe => "unsafe", |
92 | HighlightModifier::Control => "control", | ||
93 | HighlightModifier::Builtin => "builtin", | ||
94 | } | 102 | } |
95 | } | 103 | } |
96 | 104 | ||
diff --git a/crates/ra_ide/src/syntax_highlighting/tests.rs b/crates/ra_ide/src/syntax_highlighting/tests.rs index ff23d4ac5..2d90a072f 100644 --- a/crates/ra_ide/src/syntax_highlighting/tests.rs +++ b/crates/ra_ide/src/syntax_highlighting/tests.rs | |||
@@ -26,7 +26,7 @@ macro_rules! def_fn { | |||
26 | ($($tt:tt)*) => {$($tt)*} | 26 | ($($tt:tt)*) => {$($tt)*} |
27 | } | 27 | } |
28 | 28 | ||
29 | def_fn!{ | 29 | def_fn! { |
30 | fn bar() -> u32 { | 30 | fn bar() -> u32 { |
31 | 100 | 31 | 100 |
32 | } | 32 | } |