diff --git a/crates/ra_ide/src/snapshots/highlighting.html b/crates/ra_ide/src/snapshots/highlighting.html
index 4166a8f90d47..40605d9efdfb 100644
--- a/crates/ra_ide/src/snapshots/highlighting.html
+++ b/crates/ra_ide/src/snapshots/highlighting.html
@@ -10,8 +10,10 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
.builtin { color: #DD6718; }
.text { color: #DCDCCC; }
.type { color: #7CB8BB; }
+.type\.param { color: #20999D; }
.attribute { color: #94BFF3; }
.literal { color: #BFEBBF; }
+.literal\.numeric { color: #6A8759; }
.macro { color: #94BFF3; }
.variable { color: #DCDCCC; }
.variable\.mut { color: #DCDCCC; text-decoration: underline; }
@@ -22,36 +24,36 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
#[derive(Clone, Debug)]
struct Foo {
- pub x: i32,
- pub y: i32,
+ pub x: i32,
+ pub y: i32,
}
-fn foo<T>() -> T {
+fn foo<T>() -> T {
unimplemented!();
- foo::<i32>();
+ foo::<i32>();
}
fn main() {
- println!("Hello, {}!", 92);
+ println!("Hello, {}!", 92);
let mut vec = Vec::new();
if true {
- vec.push(Foo { x: 0, y: 1 });
+ vec.push(Foo { x: 0, y: 1 });
}
- unsafe { vec.set_len(0); }
+ unsafe { vec.set_len(0); }
- let mut x = 42;
+ let mut x = 42;
let y = &mut x;
let z = &y;
y;
}
-enum E<X> {
- V(X)
+enum E<X> {
+ V(X)
}
-impl<X> E<X> {
- fn new<T>() -> E<T> {}
+impl<X> E<X> {
+ fn new<T>() -> E<T> {}
}
\ No newline at end of file
diff --git a/crates/ra_ide/src/snapshots/rainbow_highlighting.html b/crates/ra_ide/src/snapshots/rainbow_highlighting.html
index 9dfbc8047529..ecf26c708472 100644
--- a/crates/ra_ide/src/snapshots/rainbow_highlighting.html
+++ b/crates/ra_ide/src/snapshots/rainbow_highlighting.html
@@ -10,8 +10,10 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
.builtin { color: #DD6718; }
.text { color: #DCDCCC; }
.type { color: #7CB8BB; }
+.type\.param { color: #20999D; }
.attribute { color: #94BFF3; }
.literal { color: #BFEBBF; }
+.literal\.numeric { color: #6A8759; }
.macro { color: #94BFF3; }
.variable { color: #DCDCCC; }
.variable\.mut { color: #DCDCCC; text-decoration: underline; }
diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs
index 7ecb1a027243..235e09ffca52 100644
--- a/crates/ra_ide/src/syntax_highlighting.rs
+++ b/crates/ra_ide/src/syntax_highlighting.rs
@@ -108,14 +108,17 @@ pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec highlight_name(db, name_kind),
None => name.syntax().parent().map_or("function", |x| match x.kind() {
- TYPE_PARAM | STRUCT_DEF | ENUM_DEF | TRAIT_DEF | TYPE_ALIAS_DEF => "type",
+ STRUCT_DEF | ENUM_DEF | TRAIT_DEF | TYPE_ALIAS_DEF => "type",
+ TYPE_PARAM => "type.param",
RECORD_FIELD_DEF => "field",
_ => "function",
}),
}
}
- INT_NUMBER | FLOAT_NUMBER | CHAR | BYTE => "literal",
- LIFETIME => "parameter",
+ INT_NUMBER | FLOAT_NUMBER => "literal.numeric",
+ BYTE => "literal.byte",
+ CHAR => "literal.char",
+ LIFETIME => "type.lifetime",
T![unsafe] => "keyword.unsafe",
k if is_control_keyword(k) => "keyword.control",
k if k.is_keyword() => "keyword",
@@ -224,8 +227,9 @@ fn highlight_name(db: &RootDatabase, name_kind: NameKind) -> &'static str {
Def(hir::ModuleDef::Static(_)) => "constant",
Def(hir::ModuleDef::Trait(_)) => "type",
Def(hir::ModuleDef::TypeAlias(_)) => "type",
- Def(hir::ModuleDef::BuiltinType(_)) => "type",
- SelfType(_) | TypeParam(_) => "type",
+ Def(hir::ModuleDef::BuiltinType(_)) => "type.builtin",
+ SelfType(_) => "type.self",
+ TypeParam(_) => "type.param",
Local(local) => {
if local.is_mut(db) {
"variable.mut"
@@ -255,8 +259,10 @@ pre { color: #DCDCCC; background: #3F3F3F; font-size: 22px; padd
.builtin { color: #DD6718; }
.text { color: #DCDCCC; }
.type { color: #7CB8BB; }
+.type\\.param { color: #20999D; }
.attribute { color: #94BFF3; }
.literal { color: #BFEBBF; }
+.literal\\.numeric { color: #6A8759; }
.macro { color: #94BFF3; }
.variable { color: #DCDCCC; }
.variable\\.mut { color: #DCDCCC; text-decoration: underline; }
diff --git a/editors/code/package.json b/editors/code/package.json
index e3bb07be797d..43db61a8bc0f 100644
--- a/editors/code/package.json
+++ b/editors/code/package.json
@@ -437,6 +437,33 @@
"highContrast": "#B5CEA8"
}
},
+ {
+ "id": "ralsp.literal.numeric",
+ "description": "Color for numeric literals",
+ "defaults": {
+ "dark": "#BECEA8",
+ "light": "#09885A",
+ "highContrast": "#B5CEA8"
+ }
+ },
+ {
+ "id": "ralsp.literal.char",
+ "description": "Color for character literals",
+ "defaults": {
+ "dark": "#BECEA8",
+ "light": "#09885A",
+ "highContrast": "#B5CEA8"
+ }
+ },
+ {
+ "id": "ralsp.literal.byte",
+ "description": "Color for byte literals",
+ "defaults": {
+ "dark": "#BECEA8",
+ "light": "#09885A",
+ "highContrast": "#B5CEA8"
+ }
+ },
{
"id": "ralsp.macro",
"description": "Color for macros",
@@ -457,7 +484,43 @@
},
{
"id": "ralsp.type",
- "description": "Color for types",
+ "description": "Color for other types (traits, aliases..)",
+ "defaults": {
+ "dark": "#4EC9B0",
+ "light": "#267F99",
+ "highContrast": "#4EC9B0"
+ }
+ },
+ {
+ "id": "ralsp.type.builtin",
+ "description": "Color for built-in types (&str, bool, u16, u32)",
+ "defaults": {
+ "dark": "#4EC9B0",
+ "light": "#267F99",
+ "highContrast": "#4EC9B0"
+ }
+ },
+ {
+ "id": "ralsp.type.lifetime",
+ "description": "Color for `Self` param type",
+ "defaults": {
+ "dark": "#4EC9B0",
+ "light": "#267F99",
+ "highContrast": "#4EC9B0"
+ }
+ },
+ {
+ "id": "ralsp.type.self",
+ "description": "Color for `Self` param type",
+ "defaults": {
+ "dark": "#4EC9B0",
+ "light": "#267F99",
+ "highContrast": "#4EC9B0"
+ }
+ },
+ {
+ "id": "ralsp.type.param",
+ "description": "Color for type parameters",
"defaults": {
"dark": "#4EC9B0",
"light": "#267F99",
diff --git a/editors/code/src/highlighting.ts b/editors/code/src/highlighting.ts
index 6d50a2f2ded0..d7c0ae1316a6 100644
--- a/editors/code/src/highlighting.ts
+++ b/editors/code/src/highlighting.ts
@@ -53,10 +53,17 @@ export class Highlighter {
decoration('parameter'),
decoration('constant'),
decoration('type'),
+ decoration('type.self'),
+ decoration('type.generic'),
+ decoration('type.param'),
+ decoration('type.lifetime'),
decoration('builtin'),
decoration('text'),
decoration('attribute'),
decoration('literal'),
+ decoration('literal.numeric'),
+ decoration('literal.char'),
+ decoration('literal.byte'),
decoration('macro'),
decoration('variable'),
decoration('variable.mut', 'underline'),