diff options
author | Laurențiu Nicola <[email protected]> | 2019-05-21 12:04:54 +0100 |
---|---|---|
committer | Laurențiu Nicola <[email protected]> | 2019-05-21 12:19:08 +0100 |
commit | 9ade271a67a9fae0d89f8138970679c9730e9fce (patch) | |
tree | 7a3cc5a13d3d71d0d247f5d0b86ecdabfc9f8f35 /crates | |
parent | eabfe3902f363ee03bef8421580c6fe8e3730899 (diff) |
Use ThemeColor and add support for light themes
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_ide_api/src/syntax_highlighting.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/crates/ra_ide_api/src/syntax_highlighting.rs b/crates/ra_ide_api/src/syntax_highlighting.rs index a03b13839..ab69a4374 100644 --- a/crates/ra_ide_api/src/syntax_highlighting.rs +++ b/crates/ra_ide_api/src/syntax_highlighting.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | use rustc_hash::FxHashSet; | 1 | use rustc_hash::FxHashSet; |
2 | 2 | ||
3 | use ra_syntax::{ast, AstNode, TextRange, Direction, SyntaxKind::*, SyntaxElement, T}; | 3 | use ra_syntax::{ast, AstNode, TextRange, Direction, SyntaxKind, SyntaxKind::*, SyntaxElement, T}; |
4 | use ra_db::SourceDatabase; | 4 | use ra_db::SourceDatabase; |
5 | 5 | ||
6 | use crate::{FileId, db::RootDatabase}; | 6 | use crate::{FileId, db::RootDatabase}; |
@@ -11,6 +11,14 @@ pub struct HighlightedRange { | |||
11 | pub tag: &'static str, | 11 | pub tag: &'static str, |
12 | } | 12 | } |
13 | 13 | ||
14 | fn is_control_keyword(kind: SyntaxKind) -> bool { | ||
15 | match kind { | ||
16 | FOR_KW | LOOP_KW | WHILE_KW | CONTINUE_KW | BREAK_KW | IF_KW | ELSE_KW | MATCH_KW | ||
17 | | RETURN_KW => true, | ||
18 | _ => false, | ||
19 | } | ||
20 | } | ||
21 | |||
14 | pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRange> { | 22 | pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRange> { |
15 | let source_file = db.parse(file_id); | 23 | let source_file = db.parse(file_id); |
16 | 24 | ||
@@ -29,6 +37,8 @@ pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRa | |||
29 | NAME => "function", | 37 | NAME => "function", |
30 | INT_NUMBER | FLOAT_NUMBER | CHAR | BYTE => "literal", | 38 | INT_NUMBER | FLOAT_NUMBER | CHAR | BYTE => "literal", |
31 | LIFETIME => "parameter", | 39 | LIFETIME => "parameter", |
40 | UNSAFE_KW => "unsafe", | ||
41 | k if is_control_keyword(k) => "control", | ||
32 | k if k.is_keyword() => "keyword", | 42 | k if k.is_keyword() => "keyword", |
33 | _ => { | 43 | _ => { |
34 | if let Some(macro_call) = node.as_node().and_then(ast::MacroCall::cast) { | 44 | if let Some(macro_call) = node.as_node().and_then(ast::MacroCall::cast) { |