Merge pull request #1697 from zed-industries/css-highlighting-fixes

Highlighting fixes
This commit is contained in:
Max Brunsfeld 2022-10-07 12:56:31 -07:00 committed by GitHub
commit 00188511cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 28 additions and 35 deletions

View file

@ -86,7 +86,7 @@
(identifier) @variable
((identifier) @constant
(#match? @constant "^[A-Z][A-Z\\d_]*$"))
(#match? @constant "^_*[A-Z][A-Z\\d_]*$"))
(call_expression
function: (identifier) @function)

View file

@ -37,11 +37,11 @@
(type_identifier) @type
((identifier) @constant
(#match? @constant "^[A-Z][A-Z\\d_]*$"))
(#match? @constant "^_*[A-Z][A-Z\\d_]*$"))
(field_identifier) @property
(statement_identifier) @label
(this) @variable.builtin
(this) @variable.special
[
"break"

View file

@ -41,10 +41,13 @@
(function_name) @function
((property_name) @variable
(#match? @variable "^--"))
((plain_value) @variable
(#match? @variable "^--"))
(
[
(property_name)
(plain_value)
] @variable.special
(#match? @variable.special "^--")
)
[
"@media"
@ -70,7 +73,6 @@
(unit) @type
[
"#"
","
":"
] @punctuation.delimiter

View file

@ -51,12 +51,12 @@
(shorthand_property_identifier)
(shorthand_property_identifier_pattern)
] @constant
(#match? @constant "^[A-Z_][A-Z\\d_]+$"))
(#match? @constant "^_*[A-Z_][A-Z\\d_]*$"))
; Literals
(this) @variable.builtin
(super) @variable.builtin
(this) @variable.special
(super) @variable.special
[
(true)

View file

@ -21,7 +21,7 @@
(#match? @type "^[A-Z]"))
((identifier) @constant
(#match? @constant "^[A-Z][A-Z_]*$"))
(#match? @constant "^_*[A-Z][A-Z\\d_]*$"))
; Builtin functions

View file

@ -1,6 +1,6 @@
(type_identifier) @type
(primitive_type) @type.builtin
(self) @variable.builtin
(self) @variable.special
(field_identifier) @property
(call_expression
@ -27,22 +27,13 @@
; Identifier conventions
; Assume uppercase names are enum constructors
((identifier) @variant
(#match? @variant "^[A-Z]"))
; Assume that uppercase names in paths are types
((scoped_identifier
path: (identifier) @type)
(#match? @type "^[A-Z]"))
((scoped_identifier
path: (scoped_identifier
name: (identifier) @type))
; Assume uppercase names are types/enum-constructors
((identifier) @type
(#match? @type "^[A-Z]"))
; Assume all-caps names are constants
((identifier) @constant
(#match? @constant "^[A-Z][A-Z\\d_]+$"))
(#match? @constant "^_*[A-Z][A-Z\\d_]*$"))
[
"("

View file

@ -51,12 +51,12 @@
(shorthand_property_identifier)
(shorthand_property_identifier_pattern)
] @constant
(#match? @constant "^[A-Z_][A-Z\\d_]+$"))
(#match? @constant "^_*[A-Z_][A-Z\\d_]*$"))
; Literals
(this) @variable.builtin
(super) @variable.builtin
(this) @variable.special
(super) @variable.special
[
(true)

View file

@ -185,6 +185,10 @@ export function createTheme(
color: sample(ramps.neutral, 7),
weight: fontWeights.normal,
},
"variable.special": {
color: sample(ramps.blue, 0.80),
weight: fontWeights.normal,
},
comment: {
color: sample(ramps.neutral, 5),
weight: fontWeights.normal,
@ -210,15 +214,11 @@ export function createTheme(
weight: fontWeights.normal,
},
constructor: {
color: sample(ramps.blue, 0.5),
weight: fontWeights.normal,
},
variant: {
color: sample(ramps.blue, 0.5),
color: sample(ramps.cyan, 0.5),
weight: fontWeights.normal,
},
property: {
color: sample(ramps.blue, 0.5),
color: sample(ramps.blue, 0.6),
weight: fontWeights.normal,
},
enum: {

View file

@ -43,7 +43,7 @@ export interface Syntax {
keyword: SyntaxHighlightStyle;
function: SyntaxHighlightStyle;
type: SyntaxHighlightStyle;
variant: SyntaxHighlightStyle;
constructor: SyntaxHighlightStyle;
property: SyntaxHighlightStyle;
enum: SyntaxHighlightStyle;
operator: SyntaxHighlightStyle;