-
-
Notifications
You must be signed in to change notification settings - Fork 30
/
source.postcss.js
229 lines (227 loc) · 7.49 KB
/
source.postcss.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
// This is a TextMate grammar distributed by `starry-night`.
// This grammar is licensed `mit`.
// See <https://github.com/wooorm/starry-night> for more info.
/**
* @import {Grammar} from '@wooorm/starry-night'
*/
/** @type {Grammar} */
const grammar = {
extensions: ['.pcss', '.postcss'],
names: ['postcss'],
patterns: [
{
begin: '/\\*',
end: '\\*/',
name: 'comment.block.postcss',
patterns: [{include: '#comment-tag'}]
},
{include: '#double-slash'},
{include: '#double-quoted'},
{include: '#single-quoted'},
{include: '#interpolation'},
{include: '#placeholder-selector'},
{include: '#variable'},
{include: '#variable-root-css'},
{include: '#numeric'},
{include: '#unit'},
{include: '#flag'},
{include: '#dotdotdot'},
{
begin: '@include',
captures: {0: {name: 'keyword.control.at-rule.css.postcss'}},
end: '(?=\\n|\\(|{|;)',
name: 'support.function.name.postcss.library'
},
{
begin: '@mixin|@function',
captures: {0: {name: 'keyword.control.at-rule.css.postcss'}},
end: '$\\n?|(?=\\(|{)',
name: 'support.function.name.postcss.no-completions',
patterns: [{match: '[\\w-]+', name: 'entity.name.function'}]
},
{
match: '(?<=@import)\\s[\\w/.*-]+',
name: 'string.quoted.double.css.postcss'
},
{
begin: '@',
end: '$\\n?|\\s(?!(all|braille|embossed|handheld|print|projection|screen|speech|tty|tv|if|only|not)(\\s|,))|(?=;)',
name: 'keyword.control.at-rule.css.postcss'
},
{
begin: '#',
end: '$\\n?|(?=\\s|,|;|\\(|\\)|\\.|\\[|{|>)',
name: 'entity.other.attribute-name.id.css.postcss',
patterns: [{include: '#interpolation'}, {include: '#pseudo-class'}]
},
{
begin: '\\.|(?<=&)(-|_)',
end: '$\\n?|(?=\\s|,|;|\\(|\\)|\\[|{|>)',
name: 'entity.other.attribute-name.class.css.postcss',
patterns: [{include: '#interpolation'}, {include: '#pseudo-class'}]
},
{
begin: '\\[',
end: '\\]',
name: 'entity.other.attribute-selector.postcss',
patterns: [
{include: '#double-quoted'},
{include: '#single-quoted'},
{match: '\\^|\\$|\\*|~', name: 'keyword.other.regex.postcss'}
]
},
{
match: '(?<=\\]|\\)|not\\(|\\*|>|>\\s):[a-z:-]+|(::|:-)[a-z:-]+',
name: 'entity.other.attribute-name.pseudo-class.css.postcss'
},
{
begin: ':',
end: '$\\n?|(?=;|\\s\\(|and\\(|{|}|\\),)',
name: 'meta.property-list.css.postcss',
patterns: [
{include: '#double-slash'},
{include: '#double-quoted'},
{include: '#single-quoted'},
{include: '#interpolation'},
{include: '#variable'},
{include: '#rgb-value'},
{include: '#numeric'},
{include: '#unit'},
{include: '#flag'},
{include: '#function'},
{include: '#function-content'},
{include: '#function-content-var'},
{include: '#operator'},
{include: '#parent-selector'},
{include: '#property-value'}
]
},
{include: '#rgb-value'},
{include: '#function'},
{include: '#function-content'},
{
begin:
'(?<!\\-|\\()\\b(a|abbr|acronym|address|applet|area|article|aside|audio|b|base|big|blockquote|body|br|button|canvas|caption|cite|code|col|colgroup|datalist|dd|del|details|dfn|dialog|div|dl|dt|em|embed|eventsource|fieldset|figure|figcaption|footer|form|frame|frameset|(h[1-6])|head|header|hgroup|hr|html|i|iframe|img|input|ins|kbd|label|legend|li|link|map|mark|menu|meta|meter|nav|noframes|noscript|object|ol|optgroup|option|output|p|param|picture|pre|progress|q|samp|script|section|select|small|source|span|strike|strong|style|sub|summary|sup|table|tbody|td|textarea|tfoot|th|thead|time|title|tr|tt|ul|var|video|main|svg|rect|ruby|center|circle|ellipse|line|polyline|polygon|path|text|u|x)\\b(?!-|\\)|:\\s)|&',
end: '(?=\\s|,|;|\\(|\\)|\\.|\\[|{|>|-|_)',
name: 'entity.name.tag.css.postcss.symbol',
patterns: [{include: '#interpolation'}, {include: '#pseudo-class'}]
},
{include: '#operator'},
{
match: '[a-z-]+((?=:|#{))',
name: 'support.type.property-name.css.postcss'
},
{include: '#reserved-words'},
{include: '#property-value'}
],
repository: {
'comment-tag': {
begin: '{{',
end: '}}',
name: 'comment.tags.postcss',
patterns: [{match: '[\\w-]+', name: 'comment.tag.postcss'}]
},
dotdotdot: {match: '\\.{3}', name: 'variable.other'},
'double-quoted': {
begin: '"',
end: '"',
name: 'string.quoted.double.css.postcss',
patterns: [{include: '#quoted-interpolation'}]
},
'double-slash': {
begin: '//',
end: '$',
name: 'comment.line.postcss',
patterns: [{include: '#comment-tag'}]
},
flag: {
match: '!(important|default|optional|global)',
name: 'keyword.other.important.css.postcss'
},
function: {
match: '(?<=[\\s|\\(|,|:])(?!url|format|attr)[\\w-][\\w-]*(?=\\()',
name: 'support.function.name.postcss'
},
'function-content': {
match: '(?<=url\\(|format\\(|attr\\().+?(?=\\))',
name: 'string.quoted.double.css.postcss'
},
'function-content-var': {
match: '(?<=var\\()[\\w-]+(?=\\))',
name: 'variable.parameter.postcss'
},
interpolation: {
begin: '#{',
end: '}',
name: 'support.function.interpolation.postcss',
patterns: [
{include: '#variable'},
{include: '#numeric'},
{include: '#operator'},
{include: '#unit'},
{include: '#double-quoted'},
{include: '#single-quoted'}
]
},
numeric: {
match: '(-|\\.)?[0-9]+(\\.[0-9]+)?',
name: 'constant.numeric.css.postcss'
},
operator: {
match:
'\\+|\\s-\\s|\\s-(?=\\$)|(?<=\\()-(?=\\$)|\\s-(?=\\()|\\*|/|%|=|!|<|>|~',
name: 'keyword.operator.postcss'
},
'parent-selector': {match: '&', name: 'entity.name.tag.css.postcss'},
'placeholder-selector': {
begin: '(?<!\\d)%(?!\\d)',
end: '$\\n?|\\s|(?=;|{)',
name: 'entity.other.attribute-name.placeholder-selector.postcss'
},
'property-value': {
match: '[\\w-]+',
name: 'meta.property-value.css.postcss, support.constant.property-value.css.postcss'
},
'pseudo-class': {
match: ':[a-z:-]+',
name: 'entity.other.attribute-name.pseudo-class.css.postcss'
},
'quoted-interpolation': {
begin: '#{',
end: '}',
name: 'support.function.interpolation.postcss',
patterns: [
{include: '#variable'},
{include: '#numeric'},
{include: '#operator'},
{include: '#unit'}
]
},
'reserved-words': {
match: '\\b(false|from|in|not|null|through|to|true)\\b',
name: 'support.type.property-name.css.postcss'
},
'rgb-value': {
match: '(#)([0-9a-fA-F]{3}|[0-9a-fA-F]{6})\\b',
name: 'constant.other.color.rgb-value.css.postcss'
},
'single-quoted': {
begin: "'",
end: "'",
name: 'string.quoted.single.css.postcss',
patterns: [{include: '#quoted-interpolation'}]
},
unit: {
match:
'(?<=[\\d]|})(ch|cm|deg|dpcm|dpi|dppx|em|ex|grad|Hz|in|kHz|mm|ms|pc|pt|px|rad|rem|s|turn|vh|vmax|vmin|vw|%)',
name: 'keyword.other.unit.css.postcss'
},
variable: {match: '\\$[\\w-]+', name: 'variable.parameter.postcss'},
'variable-root-css': {
match: '(?<!&)--[\\w-]+',
name: 'variable.parameter.postcss'
}
},
scopeName: 'source.postcss'
}
export default grammar