Skip to content

Commit 2c67380

Browse files
committed
Highlight theme options as constants
1 parent 0575db8 commit 2c67380

File tree

2 files changed

+52
-73
lines changed

2 files changed

+52
-73
lines changed

packages/tailwindcss-language-syntax/tests/__snapshots__/syntax.test.ts.snap

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ exports[`@import 1`] = `
205205
^ 1: punctuation.definition.string.end.css
206206
^^^^^ 1: support.function.theme.css
207207
^ 1: punctuation.section.function.begin.bracket.round.css
208-
^^^^^^ 1: variable.other.css
208+
^^^^^^ 1: support.constant.theme-option.css
209209
^ 1: punctuation.section.function.end.bracket.round.css
210210
^ 1: punctuation.terminator.rule.css
211211
@@ -218,7 +218,7 @@ exports[`@import 1`] = `
218218
^ 1: punctuation.definition.string.end.css
219219
^^^^^ 1: support.function.theme.css
220220
^ 1: punctuation.section.function.begin.bracket.round.css
221-
^^^^^^^^^^^^^^^^^^^^^ 5: variable.other.css
221+
^^^^^^ ^^^^^^^ ^^^^^^ 3: support.constant.theme-option.css
222222
^ 1: punctuation.section.function.end.bracket.round.css
223223
^ 1: punctuation.terminator.rule.css
224224
@@ -231,7 +231,7 @@ exports[`@import 1`] = `
231231
^ 1: punctuation.definition.string.end.css
232232
^^^^^ 1: support.function.theme.css
233233
^ 1: punctuation.section.function.begin.bracket.round.css
234-
^^^^^^^^^^^^^^^^^^^^ 3: variable.other.css
234+
^^^^^^^^^ ^^^^^^^^^^ 2: support.constant.theme-option.css
235235
^ 1: punctuation.section.function.end.bracket.round.css
236236
^ 1: punctuation.terminator.rule.css
237237
@@ -245,8 +245,9 @@ exports[`@import 1`] = `
245245
^^^^^ 1: support.function.theme.css
246246
^ ^ 2: punctuation.section.function.begin.bracket.round.css
247247
^^^^^^ 1: support.function.prefix.css
248-
^^ ^^^^^^^^^^ 3: variable.other.css
248+
^^ 1: variable.other.css
249249
^ ^ 2: punctuation.section.function.end.bracket.round.css
250+
^^^^^^^^^ 1: support.constant.theme-option.css
250251
^ 1: punctuation.terminator.rule.css
251252
252253
@import './test.css' theme(default invalid reference);
@@ -258,8 +259,8 @@ exports[`@import 1`] = `
258259
^ 1: punctuation.definition.string.end.css
259260
^^^^^ 1: support.function.theme.css
260261
^ 1: punctuation.section.function.begin.bracket.round.css
261-
^^^^^^^^ ^^^^^^^^^^ 4: variable.other.css
262-
^^^^^^^ 1: invalid.illegal.invalid-source.css
262+
^^^^^^^ ^^^^^^^^^ 2: support.constant.theme-option.css
263+
^^^^^^^ 1: invalid.illegal.theme-option.css
263264
^ 1: punctuation.section.function.end.bracket.round.css
264265
^ 1: punctuation.terminator.rule.css
265266
@@ -360,7 +361,7 @@ exports[`@import 1`] = `
360361
^ 1: punctuation.definition.string.end.css
361362
^^^^^ 1: support.function.theme.css
362363
^ 1: punctuation.section.function.begin.bracket.round.css
363-
^^^^^^ 1: variable.other.css
364+
^^^^^^ 1: support.constant.theme-option.css
364365
^ 1: punctuation.section.function.end.bracket.round.css
365366
^ 1: punctuation.terminator.rule.css
366367
@@ -373,7 +374,7 @@ exports[`@import 1`] = `
373374
^ 1: punctuation.definition.string.end.css
374375
^^^^^ 1: support.function.theme.css
375376
^ 1: punctuation.section.function.begin.bracket.round.css
376-
^^^^^^^^^^^^^^^^^^^^^ 5: variable.other.css
377+
^^^^^^ ^^^^^^^ ^^^^^^ 3: support.constant.theme-option.css
377378
^ 1: punctuation.section.function.end.bracket.round.css
378379
^ 1: punctuation.terminator.rule.css
379380
@@ -386,7 +387,7 @@ exports[`@import 1`] = `
386387
^ 1: punctuation.definition.string.end.css
387388
^^^^^ 1: support.function.theme.css
388389
^ 1: punctuation.section.function.begin.bracket.round.css
389-
^^^^^^^^^^^^^^^^^^^^ 3: variable.other.css
390+
^^^^^^^^^ ^^^^^^^^^^ 2: support.constant.theme-option.css
390391
^ 1: punctuation.section.function.end.bracket.round.css
391392
^ 1: punctuation.terminator.rule.css
392393
@@ -400,8 +401,9 @@ exports[`@import 1`] = `
400401
^^^^^ 1: support.function.theme.css
401402
^ ^ 2: punctuation.section.function.begin.bracket.round.css
402403
^^^^^^ 1: support.function.prefix.css
403-
^^ ^^^^^^^^^^ 3: variable.other.css
404+
^^ 1: variable.other.css
404405
^ ^ 2: punctuation.section.function.end.bracket.round.css
406+
^^^^^^^^^ 1: support.constant.theme-option.css
405407
^ 1: punctuation.terminator.rule.css
406408
407409
@reference './test.css' theme(default invalid reference);
@@ -413,8 +415,8 @@ exports[`@import 1`] = `
413415
^ 1: punctuation.definition.string.end.css
414416
^^^^^ 1: support.function.theme.css
415417
^ 1: punctuation.section.function.begin.bracket.round.css
416-
^^^^^^^^ ^^^^^^^^^^ 4: variable.other.css
417-
^^^^^^^ 1: invalid.illegal.invalid-source.css
418+
^^^^^^^ ^^^^^^^^^ 2: support.constant.theme-option.css
419+
^^^^^^^ 1: invalid.illegal.theme-option.css
418420
^ 1: punctuation.section.function.end.bracket.round.css
419421
^ 1: punctuation.terminator.rule.css
420422
"
@@ -727,7 +729,6 @@ exports[`@theme 1`] = `
727729
^^^^^^^^ 4: source.css.tailwind
728730
^^^^^^ 2: keyword.control.at-rule.theme.tailwind
729731
^ 1: punctuation.definition.keyword.css
730-
^ 1: variable.other.css
731732
^ 1: meta.at-rule.theme.body.tailwind punctuation.section.theme.begin.bracket.curly.tailwind
732733
733734
--color: red;
@@ -744,7 +745,7 @@ exports[`@theme 1`] = `
744745
^^^^^^^^^^^^^^^ 6: source.css.tailwind
745746
^^^^^^ 2: keyword.control.at-rule.theme.tailwind
746747
^ 1: punctuation.definition.keyword.css
747-
^^^^^^^^ 3: variable.other.css
748+
^^^^^^ 1: support.constant.theme-option.css
748749
^ 1: meta.at-rule.theme.body.tailwind punctuation.section.theme.begin.bracket.curly.tailwind
749750
750751
--color: red;
@@ -761,7 +762,7 @@ exports[`@theme 1`] = `
761762
^^^^^^^^^^^^^^^^^^^^^^^^^^ 8: source.css.tailwind
762763
^^^^^^ 2: keyword.control.at-rule.theme.tailwind
763764
^ 1: punctuation.definition.keyword.css
764-
^^^^^^^^^^^^^^^^^^^ 5: variable.other.css
765+
^^^^^^ ^^^^^^^^^^ 2: support.constant.theme-option.css
765766
^ 1: meta.at-rule.theme.body.tailwind punctuation.section.theme.begin.bracket.curly.tailwind
766767
767768
--color: red;
@@ -780,8 +781,9 @@ exports[`@theme 1`] = `
780781
^ 1: punctuation.definition.keyword.css
781782
^^^^^^ 1: support.function.prefix.css
782783
^ 1: punctuation.section.function.begin.bracket.round.css
783-
^^ ^^^^^^^^ 4: variable.other.css
784+
^^ 1: variable.other.css
784785
^ 1: punctuation.section.function.end.bracket.round.css
786+
^^^^^^ 1: support.constant.theme-option.css
785787
^ 1: meta.at-rule.theme.body.tailwind punctuation.section.theme.begin.bracket.curly.tailwind
786788
787789
--color: red;
@@ -801,7 +803,6 @@ exports[`@theme 1`] = `
801803
^^^^^^^^ 4: source.css.tailwind
802804
^^^^^^ 2: keyword.control.at-rule.theme.tailwind
803805
^ 1: punctuation.definition.keyword.css
804-
^ 1: variable.other.css
805806
^ 1: meta.at-rule.theme.body.tailwind punctuation.section.theme.begin.bracket.curly.tailwind
806807
807808
--spacing: initial;

packages/vscode-tailwindcss/syntaxes/at-rules.tmLanguage.json

Lines changed: 34 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -189,36 +189,10 @@
189189
},
190190
"end": "(?<=}|;)(?!\\G)",
191191
"patterns": [
192-
{
193-
"include": "#prefix-meta-fn"
194-
},
195-
{
196-
"match": "\\s+",
197-
"name": "variable.other.css"
198-
},
199-
{
200-
"match": "reference",
201-
"name": "variable.other.css"
202-
},
203-
{
204-
"match": "inline",
205-
"name": "variable.other.css"
206-
},
207-
{
208-
"match": "static",
209-
"name": "variable.other.css"
210-
},
211-
{
212-
"match": "default",
213-
"name": "variable.other.css"
214-
},
215-
{
216-
"match": "deprecated",
217-
"name": "variable.other.css"
218-
},
192+
{ "include": "#theme-options" },
219193
{
220194
"match": "[^{\\s]+",
221-
"name": "invalid.illegal.invalid-theme.css"
195+
"name": "invalid.illegal.theme-option.css"
222196
},
223197
{
224198
"begin": "{",
@@ -646,6 +620,36 @@
646620
}
647621
]
648622
},
623+
"theme-options": {
624+
"patterns": [
625+
{
626+
"match": "\\s+"
627+
},
628+
{
629+
"match": "reference",
630+
"name": "support.constant.theme-option.css"
631+
},
632+
{
633+
"match": "inline",
634+
"name": "support.constant.theme-option.css"
635+
},
636+
{
637+
"match": "static",
638+
"name": "support.constant.theme-option.css"
639+
},
640+
{
641+
"match": "default",
642+
"name": "support.constant.theme-option.css"
643+
},
644+
{
645+
"match": "deprecated",
646+
"name": "support.constant.theme-option.css"
647+
},
648+
{
649+
"include": "#prefix-meta-fn"
650+
}
651+
]
652+
},
649653
"theme-meta-fn": {
650654
"patterns": [
651655
{
@@ -665,36 +669,10 @@
665669
}
666670
},
667671
"patterns": [
668-
{
669-
"match": "\\s+",
670-
"name": "variable.other.css"
671-
},
672-
{
673-
"match": "reference",
674-
"name": "variable.other.css"
675-
},
676-
{
677-
"match": "inline",
678-
"name": "variable.other.css"
679-
},
680-
{
681-
"match": "static",
682-
"name": "variable.other.css"
683-
},
684-
{
685-
"match": "default",
686-
"name": "variable.other.css"
687-
},
688-
{
689-
"match": "deprecated",
690-
"name": "variable.other.css"
691-
},
692-
{
693-
"include": "#prefix-meta-fn"
694-
},
672+
{ "include": "#theme-options" },
695673
{
696674
"match": "[^)\\s]+",
697-
"name": "invalid.illegal.invalid-source.css"
675+
"name": "invalid.illegal.theme-option.css"
698676
}
699677
]
700678
}

0 commit comments

Comments
 (0)