Skip to content

Commit a934dd5

Browse files
committed
add grammar (#6)
1 parent ca715d1 commit a934dd5

File tree

2 files changed

+89
-1
lines changed

2 files changed

+89
-1
lines changed

package.json

+14-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,20 @@
2525
"workspaceContains:**/{tailwind,tailwind.config,tailwind-config,.tailwindrc}.js"
2626
],
2727
"main": "./out/extension",
28-
"contributes": {},
28+
"contributes": {
29+
"grammars": [
30+
{
31+
"scopeName": "source.css.tailwind",
32+
"path": "./syntaxes/tailwind.tmLanguage.json",
33+
"injectTo": [
34+
"source.css",
35+
"source.css.scss",
36+
"source.css.less",
37+
"source.css.postcss"
38+
]
39+
}
40+
]
41+
},
2942
"preview": true,
3043
"scripts": {
3144
"vscode:prepublish": "npm run compile",

syntaxes/tailwind.tmLanguage.json

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
{
2+
"scopeName": "source.css.tailwind",
3+
"fileTypes": [],
4+
"injectionSelector": "meta.property-list.css, meta.property-list.scss",
5+
"name": "TailwindCSS",
6+
"patterns": [
7+
{
8+
"begin": "^\\s*(@)apply\\b",
9+
"beginCaptures": {
10+
"0": {
11+
"name": "keyword.control.at-rule.apply.tailwind"
12+
},
13+
"1": {
14+
"name": "punctuation.definition.keyword.tailwind"
15+
}
16+
},
17+
"end": ";",
18+
"endCaptures": {
19+
"0": {
20+
"name": "punctuation.terminator.rule.tailwind"
21+
}
22+
},
23+
"patterns": [
24+
{
25+
"begin": "(?x)\n(?=\n (?:\\|)? # Possible anonymous namespace prefix\n (?:\n [-\\[:.*\\#a-zA-Z_] # Valid selector character\n |\n [^\\x00-\\x7F] # Which can include non-ASCII symbols\n |\n \\\\ # Or an escape sequence\n (?:[0-9a-fA-F]{1,6}|.)\n )\n)",
26+
"end": "(?=\\s*[;])",
27+
"patterns": [
28+
{
29+
"match": "!\\s*important(?![\\w-])",
30+
"name": "keyword.other.important.tailwind"
31+
},
32+
{
33+
"captures": {
34+
"1": {
35+
"name": "punctuation.definition.entity.tailwind"
36+
},
37+
"2": {
38+
"patterns": [
39+
{
40+
"include": "source.css#escapes"
41+
}
42+
]
43+
}
44+
},
45+
"match": "(?x)\n(\\.)? # Valid class-name\n(\n (?: [-a-zA-Z_0-9]|[^\\x00-\\x7F] # Valid identifier characters\n | \\\\(?:[0-9a-fA-F]{1,6}|.) # Escape sequence\n )+\n) # Followed by either:\n(?= $ # - End of the line\n | [\\s,.\\#)\\[:{>;+~|] # - Another selector\n | /\\* # - A block comment\n)",
46+
"name": "entity.other.attribute-name.class.tailwind"
47+
}
48+
]
49+
}
50+
]
51+
},
52+
{
53+
"begin": "(?i)(?<![\\w-])(config)(\\()",
54+
"beginCaptures": {
55+
"1": {
56+
"name": "support.function.config.tailwind"
57+
},
58+
"2": {
59+
"name": "punctuation.section.function.begin.bracket.round.tailwind"
60+
}
61+
},
62+
"end": "\\)",
63+
"endCaptures": {
64+
"0": {
65+
"name": "punctuation.section.function.end.bracket.round.tailwind"
66+
}
67+
},
68+
"patterns": [
69+
{
70+
"include": "source.css#property-values"
71+
}
72+
]
73+
}
74+
]
75+
}

0 commit comments

Comments
 (0)