mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 20:42:04 +00:00
Use ThemeColor and add support for light themes
This commit is contained in:
parent
eabfe3902f
commit
9ade271a67
3 changed files with 152 additions and 14 deletions
|
@ -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<HighlightedRange> {
|
||||
let source_file = db.parse(file_id);
|
||||
|
||||
|
@ -29,6 +37,8 @@ pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRa
|
|||
NAME => "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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue