diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-05-21 14:58:42 +0100 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-05-21 14:58:42 +0100 |
commit | 51e82fe6d2edd7ca66944540bdbbc8cb39e4b5d2 (patch) | |
tree | 4ba523d010901e2c68d2901217074494d01c22d1 /crates | |
parent | c6a5d871d7a670473a78e03852bb158f3b6d5be3 (diff) | |
parent | b08362f6d2973336764c52ebc7cc5e9f34f0d80a (diff) |
Merge #1299
1299: Use ThemeColor and add support for light themes r=matklad a=lnicola
Part of #1294.
- switch to `ThemeColor`
- add light and high contrast theme definitions
- highlight control flow keywords and `unsafe`
Co-authored-by: Laurențiu Nicola <[email protected]>
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_ide_api/src/syntax_highlighting.rs | 19 |
1 files changed, 18 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..2158291dc 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,21 @@ 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 | T![for] | ||
17 | | T![loop] | ||
18 | | T![while] | ||
19 | | T![continue] | ||
20 | | T![break] | ||
21 | | T![if] | ||
22 | | T![else] | ||
23 | | T![match] | ||
24 | | T![return] => true, | ||
25 | _ => false, | ||
26 | } | ||
27 | } | ||
28 | |||
14 | pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRange> { | 29 | pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRange> { |
15 | let source_file = db.parse(file_id); | 30 | let source_file = db.parse(file_id); |
16 | 31 | ||
@@ -29,6 +44,8 @@ pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRa | |||
29 | NAME => "function", | 44 | NAME => "function", |
30 | INT_NUMBER | FLOAT_NUMBER | CHAR | BYTE => "literal", | 45 | INT_NUMBER | FLOAT_NUMBER | CHAR | BYTE => "literal", |
31 | LIFETIME => "parameter", | 46 | LIFETIME => "parameter", |
47 | T![unsafe] => "keyword.unsafe", | ||
48 | k if is_control_keyword(k) => "keyword.control", | ||
32 | k if k.is_keyword() => "keyword", | 49 | k if k.is_keyword() => "keyword", |
33 | _ => { | 50 | _ => { |
34 | if let Some(macro_call) = node.as_node().and_then(ast::MacroCall::cast) { | 51 | if let Some(macro_call) = node.as_node().and_then(ast::MacroCall::cast) { |