From 9ade271a67a9fae0d89f8138970679c9730e9fce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lauren=C8=9Biu=20Nicola?= Date: Tue, 21 May 2019 14:04:54 +0300 Subject: Use ThemeColor and add support for light themes --- crates/ra_ide_api/src/syntax_highlighting.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'crates/ra_ide_api') 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 @@ use rustc_hash::FxHashSet; -use ra_syntax::{ast, AstNode, TextRange, Direction, SyntaxKind::*, SyntaxElement, T}; +use ra_syntax::{ast, AstNode, TextRange, Direction, SyntaxKind, SyntaxKind::*, SyntaxElement, T}; use ra_db::SourceDatabase; use crate::{FileId, db::RootDatabase}; @@ -11,6 +11,14 @@ pub struct HighlightedRange { pub tag: &'static str, } +fn is_control_keyword(kind: SyntaxKind) -> bool { + match kind { + FOR_KW | LOOP_KW | WHILE_KW | CONTINUE_KW | BREAK_KW | IF_KW | ELSE_KW | MATCH_KW + | RETURN_KW => true, + _ => false, + } +} + pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec { let source_file = db.parse(file_id); @@ -29,6 +37,8 @@ pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec "function", INT_NUMBER | FLOAT_NUMBER | CHAR | BYTE => "literal", LIFETIME => "parameter", + UNSAFE_KW => "unsafe", + k if is_control_keyword(k) => "control", k if k.is_keyword() => "keyword", _ => { if let Some(macro_call) = node.as_node().and_then(ast::MacroCall::cast) { -- cgit v1.2.3