Skip to content

Commit eeaa65c

Browse files
committed
Final default css.cson
1 parent 9e58c28 commit eeaa65c

File tree

1 file changed

+202
-52
lines changed

1 file changed

+202
-52
lines changed

src/vscode-css/grammars/css.cson

Lines changed: 202 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,17 @@
1616
(?=\\s|:|$)
1717
'''
1818
'patterns': [
19+
{
20+
'include': '#commas'
21+
}
1922
{
2023
'include': '#comment-block'
2124
}
2225
{
2326
'include': '#escapes'
2427
}
2528
{
26-
'include': '#combinators'
29+
'include': '#combinator-invalid'
2730
}
2831
{
2932
'include': '#selector'
@@ -34,9 +37,6 @@
3437
{
3538
'include': '#rule-list'
3639
}
37-
{
38-
'include': '#nesting-selector'
39-
}
4040
]
4141
'repository':
4242
'arithmetic-operators':
@@ -483,6 +483,9 @@
483483
'name': 'punctuation.section.supports.end.bracket.curly.css'
484484
'name': 'meta.at-rule.supports.body.css'
485485
'patterns': [
486+
{
487+
'include': '#rule-list-innards'
488+
}
486489
{
487490
'include': '$self'
488491
}
@@ -701,14 +704,16 @@
701704
'combinators':
702705
'patterns': [
703706
{
704-
'match': '/deep/|>>>'
705-
'name': 'invalid.deprecated.combinator.css'
707+
'include': '#combinator-invalid'
706708
}
707709
{
708710
'match': '>>|>|\\+|~'
709711
'name': 'keyword.operator.combinator.css'
710712
}
711713
]
714+
'combinator-invalid':
715+
'match': '/deep/|>>>'
716+
'name': 'invalid.deprecated.combinator.css'
712717
'commas':
713718
'match': ','
714719
'name': 'punctuation.separator.list.comma.css'
@@ -1068,27 +1073,23 @@
10681073
}
10691074
]
10701075
'function-nesting':
1076+
'begin': '\\('
1077+
'beginCaptures':
1078+
'0':
1079+
'name': 'punctuation.definition.function.begin.bracket.round.css'
1080+
'end': '\\)'
1081+
'endCaptures':
1082+
'0':
1083+
'name': 'punctuation.definition.function.end.bracket.round.css'
10711084
'patterns': [
10721085
{
1073-
'begin': '\\('
1074-
'beginCaptures':
1075-
'0':
1076-
'name': 'punctuation.definition.begin.bracket.round.scss'
1077-
'end': '\\)'
1078-
'endCaptures':
1079-
'0':
1080-
'name': 'punctuation.definition.end.bracket.round.scss'
1081-
'patterns': [
1082-
{
1083-
'include': '#arithmetic-operators'
1084-
}
1085-
{
1086-
'include': '#property-values'
1087-
},
1088-
{
1089-
'include': '#function-nesting'
1090-
}
1091-
]
1086+
'include': '#arithmetic-operators'
1087+
}
1088+
{
1089+
'include': '#property-values'
1090+
},
1091+
{
1092+
'include': '#function-nesting'
10921093
}
10931094
]
10941095
'functional-pseudo-classes':
@@ -1394,7 +1395,7 @@
13941395
'include': '#comment-block'
13951396
}
13961397
{
1397-
"include": "#functions"
1398+
'include': '#functions'
13981399
}
13991400
]
14001401
}
@@ -1424,9 +1425,6 @@
14241425
)
14251426
(?=$|[{,\\s;]|/\\*)
14261427
'''
1427-
'nesting-selector':
1428-
'match': '&'
1429-
'name': 'entity.name.tag.nesting.selector.css'
14301428
'numeric-values':
14311429
'patterns': [
14321430
{
@@ -1629,11 +1627,11 @@
16291627
)
16301628
(?![\\w-])
16311629
'''
1632-
'name': 'support.type.property-name.css'
1630+
'name': 'meta.property-name.css support.type.property-name.css'
16331631
}
16341632
{
16351633
'match': '(?<![\\w-])(?i:-(?:ah|apple|atsc|epub|hp|khtml|moz|ms|o|rim|ro|tc|wap|webkit|xv)|(?:mso|prince))-[a-zA-Z-]+'
1636-
'name': 'support.type.vendored.property-name.css'
1634+
'name': 'meta.property-name.css support.type.vendored.property-name.css'
16371635
}
16381636
]
16391637
'property-values':
@@ -1760,24 +1758,34 @@
17601758
'name': 'variable.css'
17611759
}
17621760
{
1763-
'begin': '(?<![-a-zA-Z])(?=[-a-zA-Z])'
1764-
'end': '$|(?![-a-zA-Z])'
1765-
'name': 'meta.property-name.css'
1766-
'patterns': [
1767-
{
1768-
'include': '#property-names'
1769-
}
1770-
]
1761+
'include': '#shared-names'
17711762
}
17721763
{
1773-
'include': '#selector-innards'
1764+
'include': '#property-names'
1765+
}
1766+
{
1767+
'include': '#selector'
17741768
}
17751769
{
17761770
'begin': '(:)\\s*'
17771771
'beginCaptures':
17781772
'1':
17791773
'name': 'punctuation.separator.key-value.css'
1780-
'end': '\\s*(;)|\\s*(?=}|\\))'
1774+
'end': '''(?x)
1775+
\\s* # Optional whitespaces, followed by:
1776+
(?:
1777+
(;) # A semicolon
1778+
| (?=
1779+
\\} # OR a closing curly brace
1780+
| \\) # OR a closing parenthesis
1781+
| (?: # OR an opening curly brace not enclosed by quotes
1782+
[^\\'\\"]?
1783+
\\{
1784+
[^\\'\\"]?
1785+
)
1786+
)
1787+
)
1788+
'''
17811789
'endCaptures':
17821790
'1':
17831791
'name': 'punctuation.terminator.rule.css'
@@ -1795,22 +1803,80 @@
17951803
'match': ';'
17961804
'name': 'punctuation.terminator.rule.css'
17971805
}
1806+
{
1807+
'begin': '(?<![-a-zA-Z])(?=[-a-zA-Z])'
1808+
'end': '$|(?![-a-zA-Z])'
1809+
'name': 'meta.property-name.css'
1810+
}
17981811
]
17991812
'selector':
1800-
'begin': '''(?x)
1813+
'begin': '''(?xi)
1814+
# Match must be preceded by one of the following:
1815+
(?<=
1816+
^ # Start of line
1817+
| (^|[^\\:])\\s # Whitespace, after the start of a line or any character except a colon (which denotes a property)
1818+
| ; # Semicolon (condensed property list syntax)
1819+
| [{}] # Opening or closing brace (condensed property list syntax)
1820+
| \\*/ # Comment end
1821+
| \\\\(?:[0-9a-fA-F]{1,6}|.) # Escape sequence
1822+
)
1823+
1824+
# Match may contain any of the following:
18011825
(?=
1802-
(?:\\|)? # Possible anonymous namespace prefix
18031826
(?:
1804-
[-\\[:.*\\#a-zA-Z_] # Valid selector character
1805-
|
1806-
[^\\x00-\\x7F] # Which can include non-ASCII symbols
1807-
|
1808-
\\\\ # Or an escape sequence
1809-
(?:[0-9a-fA-F]{1,6}|.)
1827+
# Match must start with one of the following:
1828+
& # Nesting selector
1829+
| \\* # Universal selector
1830+
| [>~+] # Selector combinator
1831+
| \\| # Selector namespace separator
1832+
| \\[ # Attribute selector opening bracket
1833+
| [a-zA-Z] # Letter
1834+
| [^\\x00-\\x7F] # Non-ASCII symbols
1835+
| \\\\(?:[0-9a-fA-F]{1,6}|.) # Escape sequence
1836+
1837+
# Or one of the following symbols, followed by a word character, hyphen, or escape sequence:
1838+
| (?:
1839+
\\. # Class selector
1840+
| \\# # ID selector
1841+
)
1842+
(?:
1843+
[\\w-] # Word character or hyphen
1844+
| \\\\(?: # Escape sequence
1845+
[0-9a-fA-F]{1,6}
1846+
| .
1847+
)
1848+
)
1849+
1850+
# Or one of the following symbols, followed a letter or hyphen:
1851+
| (?:
1852+
\\: # Pseudo-class
1853+
| \\:\\: # Pseudo-element
1854+
)
1855+
[a-zA-Z-] # Letter or hyphen
18101856
)
18111857
)
1812-
'''
1813-
'end': '(?=\\s*[/@{)])'
1858+
1859+
# Match must NOT contain any of the following:
1860+
(?!
1861+
[\\w-]*[\\:]+\\s # One or more colons immediately followed by a whitespace (denotes a property or invalid sequence)
1862+
| [^{]*; # Any characters and a semicolon before an opening bracket (denotes the end of a property)
1863+
| [^{]*} # A closing bracket before an opening bracket (denotes a property)
1864+
| [^\\:]+(\\:\\:):+ # More than two colons (invalid sequence)
1865+
)
1866+
'''
1867+
'end': '''(?x)
1868+
# Match must end with:
1869+
(?=
1870+
\\s* # Optional whitespace and one of the following:
1871+
(?:
1872+
\\/ # Comment
1873+
| @ # At-rule
1874+
| { # Opening property list brace
1875+
| \\) # Closing function brace (for passing test on `some-edgy-new-function(`)
1876+
| $ # End of line
1877+
)
1878+
)
1879+
'''
18141880
'name': 'meta.selector.css'
18151881
'patterns': [
18161882
{
@@ -1843,7 +1909,7 @@
18431909
[-\\w*]+
18441910
\\|
18451911
(?!
1846-
[-\\[:.*\\#a-zA-Z_] # Make sure there's a selector to match
1912+
[-\\[:.*&\\#a-zA-Z_] # Make sure there's a selector to match
18471913
| [^\\x00-\\x7F]
18481914
)
18491915
)
@@ -1861,6 +1927,10 @@
18611927
{
18621928
'include': '#tag-names'
18631929
}
1930+
{
1931+
'match': '&'
1932+
'name': 'entity.name.tag.nesting.css'
1933+
}
18641934
{
18651935
'match': '\\*'
18661936
'name': 'entity.name.tag.wildcard.css'
@@ -2065,6 +2135,85 @@
20652135
'name': 'entity.name.tag.custom.css'
20662136
}
20672137
]
2138+
'shared-names':
2139+
# Shared names are keywords that can be used as selector or property names.
2140+
# If the following conditions are met, the keyword is considered a selector:
2141+
'begin': '''(?xi)
2142+
# Selector match must be preceded by one of the following:
2143+
(?<=
2144+
^ # Start of line
2145+
| (^|[^\\:])\\s # Whitespace, after the start of a line or any character except a colon
2146+
| [{}] # Opening or closing brace (condensed property list syntax)
2147+
| \\*/ # Comment end
2148+
| \\\\(?:[0-9a-fA-F]{1,6}|.) # Escape sequence
2149+
)
2150+
2151+
(?=
2152+
# Selector must match:
2153+
(?:
2154+
# HTML elements
2155+
content|font|header|image|label|mark|marquee|mask|nav|ruby|shadow|span|style
2156+
# SVG elements
2157+
|color-profile|cursor|filter|line|text
2158+
)
2159+
2160+
# Selector must NOT be followed by any any of the following:
2161+
(?!
2162+
.*; # Any characters followed by a semicolon (denotes a property)
2163+
| .*} # Any characters followed by a closing bracket (denotes a property)
2164+
| - # A dash (denotes a property name)
2165+
# | \\s*\\: # A colon, unless it's with one of the following:
2166+
# (?!
2167+
# # A opening bracket before an closing bracket
2168+
# [^}]*{
2169+
# # A pseudo-class selectors
2170+
# | active|any-link|checked|disabled|empty|enabled|first
2171+
# | (?:first|last|only)-(?:child|of-type)|focus|focus-visible|focus-within|fullscreen|host|hover
2172+
# | in-range|indeterminate|invalid|link|out-of-range
2173+
# | read-only|read-write|required|root|scope|target|unresolved
2174+
# | valid|visited
2175+
2176+
# # A functional pseudo-class selectors
2177+
# | (?: dir|lang
2178+
# | not|has|matches|where|is
2179+
# | nth-(?:last-)?(?:child|of-type)
2180+
# )\\(
2181+
2182+
# # A single-colon pseudo-element selectors
2183+
# | after
2184+
# | before
2185+
# | first-letter
2186+
# | first-line
2187+
# | (?:
2188+
# \\-
2189+
# (?:
2190+
# ah|apple|atsc|epub|hp|khtml|moz
2191+
# | ms|o|rim|ro|tc|wap|webkit|xv
2192+
# )
2193+
# | (?:
2194+
# mso|prince
2195+
# )
2196+
# )
2197+
# -[a-z-]+
2198+
# )
2199+
)
2200+
)
2201+
'''
2202+
'end': '''(?xi)
2203+
# Selector match ends with one of the following:
2204+
(?=
2205+
\\s # Whitespace
2206+
| \\/\\* # Comment
2207+
| , # Comma
2208+
| { # Opening property list brace
2209+
| $ # End of line
2210+
)
2211+
'''
2212+
'patterns': [
2213+
{
2214+
'include': '#selector'
2215+
}
2216+
]
20682217
'string':
20692218
'patterns': [
20702219
{
@@ -2190,3 +2339,4 @@
21902339
'include': '#escapes'
21912340
}
21922341
]
2342+

0 commit comments

Comments
 (0)