@@ -10,37 +10,37 @@ pub use languages::get_language;
1010
1111#[ derive( Debug , Clone , Copy , PartialEq , Eq ) ]
1212pub enum TokenType {
13- Keyword ,
14- Type ,
13+ Comment ,
14+ Constant ,
1515 Function ,
16- Variable ,
17- String ,
16+ Keyword ,
17+ Label ,
1818 Number ,
19- Comment ,
2019 Operator ,
21- Punctuation ,
22- Constant ,
2320 Parameter ,
2421 Property ,
25- Label ,
22+ Punctuation ,
23+ String ,
24+ Type ,
25+ Variable ,
2626}
2727
2828impl TokenType {
2929 pub fn color ( & self , theme : & Theme ) -> Color {
3030 match self {
31- TokenType :: Keyword => theme. syntax_keyword ,
32- TokenType :: Type => theme. syntax_type ,
31+ TokenType :: Comment => theme. syntax_comment ,
32+ TokenType :: Constant => theme. syntax_constant ,
3333 TokenType :: Function => theme. syntax_function ,
34- TokenType :: Variable => theme. syntax_variable ,
35- TokenType :: String => theme. syntax_string ,
34+ TokenType :: Keyword => theme. syntax_keyword ,
35+ TokenType :: Label => theme. syntax_label ,
3636 TokenType :: Number => theme. syntax_number ,
37- TokenType :: Comment => theme. syntax_comment ,
3837 TokenType :: Operator => theme. syntax_operator ,
39- TokenType :: Punctuation => theme. syntax_punctuation ,
40- TokenType :: Constant => theme. syntax_constant ,
4138 TokenType :: Parameter => theme. syntax_parameter ,
4239 TokenType :: Property => theme. syntax_property ,
43- TokenType :: Label => theme. syntax_label ,
40+ TokenType :: Punctuation => theme. syntax_punctuation ,
41+ TokenType :: String => theme. syntax_string ,
42+ TokenType :: Type => theme. syntax_type ,
43+ TokenType :: Variable => theme. syntax_variable ,
4444 }
4545 }
4646}
@@ -151,44 +151,41 @@ impl Highlighter {
151151 let base_name = capture_name. split ( '.' ) . next ( ) . unwrap_or ( capture_name) ;
152152
153153 let token_type = match base_name {
154- "keyword" => TokenType :: Keyword ,
155- "type" => TokenType :: Type ,
154+ "annotation" | "attribute" | "decorator" => TokenType :: Keyword ,
155+ "boolean" => TokenType :: Constant ,
156+ "character" => TokenType :: String ,
157+ "class" | "constructor" | "enum" | "interface" | "struct" | "trait" => {
158+ TokenType :: Type
159+ }
160+ "comment" => TokenType :: Comment ,
161+ "conditional" | "exception" | "include" | "repeat" | "storageclass" => {
162+ TokenType :: Keyword
163+ }
164+ "constant" => TokenType :: Constant ,
165+ "delimiter" => TokenType :: Punctuation ,
166+ "escape" => TokenType :: Operator ,
167+ "field" => TokenType :: Property ,
168+ "float" => TokenType :: Number ,
156169 "function" => TokenType :: Function ,
157- "variable" => TokenType :: Variable ,
158- "string" => TokenType :: String ,
170+ "identifier" => TokenType :: Variable ,
171+ "keyword" => TokenType :: Keyword ,
172+ "label" => TokenType :: Label ,
173+ "macro" | "method" => TokenType :: Function ,
174+ "module" | "namespace" => TokenType :: Type ,
159175 "number" => TokenType :: Number ,
160- "comment" => TokenType :: Comment ,
161176 "operator" => TokenType :: Operator ,
162- "punctuation" => TokenType :: Punctuation ,
163- "constant" => TokenType :: Constant ,
164177 "parameter" => TokenType :: Parameter ,
165178 "property" => TokenType :: Property ,
166- "label" => TokenType :: Label ,
167- "character" => TokenType :: String ,
168- "boolean" => TokenType :: Constant ,
169- // Additional common capture names
170- "namespace" | "module" => TokenType :: Type ,
171- "constructor" => TokenType :: Type ,
172- "method" => TokenType :: Function ,
173- "macro" => TokenType :: Function ,
174- "annotation" | "attribute" | "decorator" => TokenType :: Keyword ,
175- "tag" => TokenType :: Type ,
176- "escape" => TokenType :: Operator ,
177- "delimiter" => TokenType :: Punctuation ,
178- "special" => TokenType :: Operator ,
179- "field" => TokenType :: Property ,
180- "enum" | "struct" | "class" | "interface" | "trait" => TokenType :: Type ,
179+ "punctuation" => TokenType :: Punctuation ,
181180 "regexp" => TokenType :: String ,
182- // Additional from all language queries
183- "conditional" | "repeat" | "exception" | "include" | "storageclass" => {
184- TokenType :: Keyword
185- }
186- "identifier" => TokenType :: Variable ,
187- "float" => TokenType :: Number ,
188- // Markdown and documentation
181+ "special" => TokenType :: Operator ,
182+ "string" => TokenType :: String ,
183+ "tag" => TokenType :: Type ,
189184 "text" => TokenType :: String ,
185+ "type" => TokenType :: Type ,
186+ "variable" => TokenType :: Variable ,
190187 // Skip internal/special markers
191- "embedded " | "spell " | "__name__ " | "_name " | "_op " | "_type " | "none " => {
188+ "__name__ " | "_name " | "_op " | "_type " | "embedded " | "none " | "spell " => {
192189 continue
193190 }
194191 _ => continue ,
0 commit comments