Skip to content

Commit c14e7b4

Browse files
authored
Add tree-sitter for css (#243988)
* Add tree-sitter for css * Hard code root scopes
1 parent 4cdd8bf commit c14e7b4

File tree

15 files changed

+8722
-27
lines changed

15 files changed

+8722
-27
lines changed

extensions/vscode-colorize-tests/src/colorizer.test.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,20 @@ suite('colorization', () => {
7070
suiteSetup(async function () {
7171
originalSettingValues = [
7272
workspace.getConfiguration('editor.experimental').get('preferTreeSitter.typescript'),
73+
workspace.getConfiguration('editor.experimental').get('preferTreeSitter.ini'),
7374
workspace.getConfiguration('editor.experimental').get('preferTreeSitter.regex'),
74-
workspace.getConfiguration('editor.experimental').get('preferTreeSitter.ini')
75+
workspace.getConfiguration('editor.experimental').get('preferTreeSitter.css')
7576
];
7677
await workspace.getConfiguration('editor.experimental').update('preferTreeSitter.typescript', true, ConfigurationTarget.Global);
77-
await workspace.getConfiguration('editor.experimental').update('preferTreeSitter.regex', true, ConfigurationTarget.Global);
7878
await workspace.getConfiguration('editor.experimental').update('preferTreeSitter.ini', true, ConfigurationTarget.Global);
79+
await workspace.getConfiguration('editor.experimental').update('preferTreeSitter.regex', true, ConfigurationTarget.Global);
80+
await workspace.getConfiguration('editor.experimental').update('preferTreeSitter.css', true, ConfigurationTarget.Global);
7981
});
8082
suiteTeardown(async function () {
8183
await workspace.getConfiguration('editor.experimental').update('preferTreeSitter.typescript', originalSettingValues[0], ConfigurationTarget.Global);
82-
await workspace.getConfiguration('editor.experimental').update('preferTreeSitter.regex', originalSettingValues[1], ConfigurationTarget.Global);
83-
await workspace.getConfiguration('editor.experimental').update('preferTreeSitter.ini', originalSettingValues[2], ConfigurationTarget.Global);
84+
await workspace.getConfiguration('editor.experimental').update('preferTreeSitter.ini', originalSettingValues[1], ConfigurationTarget.Global);
85+
await workspace.getConfiguration('editor.experimental').update('preferTreeSitter.regex', originalSettingValues[2], ConfigurationTarget.Global);
86+
await workspace.getConfiguration('editor.experimental').update('preferTreeSitter.css', originalSettingValues[3], ConfigurationTarget.Global);
8487
});
8588

8689
for (const fixture of fs.readdirSync(fixturesPath)) {

extensions/vscode-colorize-tests/test/colorize-fixtures/test.css

+5-1
Original file line numberDiff line numberDiff line change
@@ -156,4 +156,8 @@ footer a:visited {
156156
right: 0;
157157
width: 148px;
158158
height: 110px;
159-
}
159+
}
160+
161+
.chat-feature-container .codicon[class*='codicon-'] {
162+
font-size: 16px;
163+
}

extensions/vscode-colorize-tests/test/colorize-results/test_css.json

+308
Original file line numberDiff line numberDiff line change
@@ -11633,6 +11633,314 @@
1163311633
"light_modern": "default: #3B3B3B"
1163411634
}
1163511635
},
11636+
{
11637+
"c": "}",
11638+
"t": "source.css meta.property-list.css punctuation.section.property-list.end.bracket.curly.css",
11639+
"r": {
11640+
"dark_plus": "default: #D4D4D4",
11641+
"light_plus": "default: #000000",
11642+
"dark_vs": "default: #D4D4D4",
11643+
"light_vs": "default: #000000",
11644+
"hc_black": "default: #FFFFFF",
11645+
"dark_modern": "default: #CCCCCC",
11646+
"hc_light": "default: #292929",
11647+
"light_modern": "default: #3B3B3B"
11648+
}
11649+
},
11650+
{
11651+
"c": ".",
11652+
"t": "source.css meta.selector.css entity.other.attribute-name.class.css punctuation.definition.entity.css",
11653+
"r": {
11654+
"dark_plus": "entity.other.attribute-name.class.css: #D7BA7D",
11655+
"light_plus": "entity.other.attribute-name.class.css: #800000",
11656+
"dark_vs": "entity.other.attribute-name.class.css: #D7BA7D",
11657+
"light_vs": "entity.other.attribute-name.class.css: #800000",
11658+
"hc_black": "entity.other.attribute-name.class.css: #D7BA7D",
11659+
"dark_modern": "entity.other.attribute-name.class.css: #D7BA7D",
11660+
"hc_light": "entity.other.attribute-name.class.css: #0F4A85",
11661+
"light_modern": "entity.other.attribute-name.class.css: #800000"
11662+
}
11663+
},
11664+
{
11665+
"c": "chat-feature-container",
11666+
"t": "source.css meta.selector.css entity.other.attribute-name.class.css",
11667+
"r": {
11668+
"dark_plus": "entity.other.attribute-name.class.css: #D7BA7D",
11669+
"light_plus": "entity.other.attribute-name.class.css: #800000",
11670+
"dark_vs": "entity.other.attribute-name.class.css: #D7BA7D",
11671+
"light_vs": "entity.other.attribute-name.class.css: #800000",
11672+
"hc_black": "entity.other.attribute-name.class.css: #D7BA7D",
11673+
"dark_modern": "entity.other.attribute-name.class.css: #D7BA7D",
11674+
"hc_light": "entity.other.attribute-name.class.css: #0F4A85",
11675+
"light_modern": "entity.other.attribute-name.class.css: #800000"
11676+
}
11677+
},
11678+
{
11679+
"c": " ",
11680+
"t": "source.css meta.selector.css",
11681+
"r": {
11682+
"dark_plus": "default: #D4D4D4",
11683+
"light_plus": "default: #000000",
11684+
"dark_vs": "default: #D4D4D4",
11685+
"light_vs": "default: #000000",
11686+
"hc_black": "default: #FFFFFF",
11687+
"dark_modern": "default: #CCCCCC",
11688+
"hc_light": "default: #292929",
11689+
"light_modern": "default: #3B3B3B"
11690+
}
11691+
},
11692+
{
11693+
"c": ".",
11694+
"t": "source.css meta.selector.css entity.other.attribute-name.class.css punctuation.definition.entity.css",
11695+
"r": {
11696+
"dark_plus": "entity.other.attribute-name.class.css: #D7BA7D",
11697+
"light_plus": "entity.other.attribute-name.class.css: #800000",
11698+
"dark_vs": "entity.other.attribute-name.class.css: #D7BA7D",
11699+
"light_vs": "entity.other.attribute-name.class.css: #800000",
11700+
"hc_black": "entity.other.attribute-name.class.css: #D7BA7D",
11701+
"dark_modern": "entity.other.attribute-name.class.css: #D7BA7D",
11702+
"hc_light": "entity.other.attribute-name.class.css: #0F4A85",
11703+
"light_modern": "entity.other.attribute-name.class.css: #800000"
11704+
}
11705+
},
11706+
{
11707+
"c": "codicon",
11708+
"t": "source.css meta.selector.css entity.other.attribute-name.class.css",
11709+
"r": {
11710+
"dark_plus": "entity.other.attribute-name.class.css: #D7BA7D",
11711+
"light_plus": "entity.other.attribute-name.class.css: #800000",
11712+
"dark_vs": "entity.other.attribute-name.class.css: #D7BA7D",
11713+
"light_vs": "entity.other.attribute-name.class.css: #800000",
11714+
"hc_black": "entity.other.attribute-name.class.css: #D7BA7D",
11715+
"dark_modern": "entity.other.attribute-name.class.css: #D7BA7D",
11716+
"hc_light": "entity.other.attribute-name.class.css: #0F4A85",
11717+
"light_modern": "entity.other.attribute-name.class.css: #800000"
11718+
}
11719+
},
11720+
{
11721+
"c": "[",
11722+
"t": "source.css meta.selector.css meta.attribute-selector.css punctuation.definition.entity.begin.bracket.square.css",
11723+
"r": {
11724+
"dark_plus": "default: #D4D4D4",
11725+
"light_plus": "default: #000000",
11726+
"dark_vs": "default: #D4D4D4",
11727+
"light_vs": "default: #000000",
11728+
"hc_black": "default: #FFFFFF",
11729+
"dark_modern": "default: #CCCCCC",
11730+
"hc_light": "default: #292929",
11731+
"light_modern": "default: #3B3B3B"
11732+
}
11733+
},
11734+
{
11735+
"c": "class",
11736+
"t": "source.css meta.selector.css meta.attribute-selector.css entity.other.attribute-name.css",
11737+
"r": {
11738+
"dark_plus": "entity.other.attribute-name: #9CDCFE",
11739+
"light_plus": "entity.other.attribute-name: #E50000",
11740+
"dark_vs": "entity.other.attribute-name: #9CDCFE",
11741+
"light_vs": "entity.other.attribute-name: #E50000",
11742+
"hc_black": "entity.other.attribute-name: #9CDCFE",
11743+
"dark_modern": "entity.other.attribute-name: #9CDCFE",
11744+
"hc_light": "entity.other.attribute-name: #264F78",
11745+
"light_modern": "entity.other.attribute-name: #E50000"
11746+
}
11747+
},
11748+
{
11749+
"c": "*=",
11750+
"t": "source.css meta.selector.css meta.attribute-selector.css keyword.operator.pattern.css",
11751+
"r": {
11752+
"dark_plus": "keyword.operator: #D4D4D4",
11753+
"light_plus": "keyword.operator: #000000",
11754+
"dark_vs": "keyword.operator: #D4D4D4",
11755+
"light_vs": "keyword.operator: #000000",
11756+
"hc_black": "keyword.operator: #D4D4D4",
11757+
"dark_modern": "keyword.operator: #D4D4D4",
11758+
"hc_light": "keyword.operator: #000000",
11759+
"light_modern": "keyword.operator: #000000"
11760+
}
11761+
},
11762+
{
11763+
"c": "'",
11764+
"t": "source.css meta.selector.css meta.attribute-selector.css string.quoted.single.css punctuation.definition.string.begin.css",
11765+
"r": {
11766+
"dark_plus": "string: #CE9178",
11767+
"light_plus": "string: #A31515",
11768+
"dark_vs": "string: #CE9178",
11769+
"light_vs": "string: #A31515",
11770+
"hc_black": "string: #CE9178",
11771+
"dark_modern": "string: #CE9178",
11772+
"hc_light": "string: #0F4A85",
11773+
"light_modern": "string: #A31515"
11774+
}
11775+
},
11776+
{
11777+
"c": "codicon-",
11778+
"t": "source.css meta.selector.css meta.attribute-selector.css string.quoted.single.css",
11779+
"r": {
11780+
"dark_plus": "string: #CE9178",
11781+
"light_plus": "string: #A31515",
11782+
"dark_vs": "string: #CE9178",
11783+
"light_vs": "string: #A31515",
11784+
"hc_black": "string: #CE9178",
11785+
"dark_modern": "string: #CE9178",
11786+
"hc_light": "string: #0F4A85",
11787+
"light_modern": "string: #A31515"
11788+
}
11789+
},
11790+
{
11791+
"c": "'",
11792+
"t": "source.css meta.selector.css meta.attribute-selector.css string.quoted.single.css punctuation.definition.string.end.css",
11793+
"r": {
11794+
"dark_plus": "string: #CE9178",
11795+
"light_plus": "string: #A31515",
11796+
"dark_vs": "string: #CE9178",
11797+
"light_vs": "string: #A31515",
11798+
"hc_black": "string: #CE9178",
11799+
"dark_modern": "string: #CE9178",
11800+
"hc_light": "string: #0F4A85",
11801+
"light_modern": "string: #A31515"
11802+
}
11803+
},
11804+
{
11805+
"c": "]",
11806+
"t": "source.css meta.selector.css meta.attribute-selector.css punctuation.definition.entity.end.bracket.square.css",
11807+
"r": {
11808+
"dark_plus": "default: #D4D4D4",
11809+
"light_plus": "default: #000000",
11810+
"dark_vs": "default: #D4D4D4",
11811+
"light_vs": "default: #000000",
11812+
"hc_black": "default: #FFFFFF",
11813+
"dark_modern": "default: #CCCCCC",
11814+
"hc_light": "default: #292929",
11815+
"light_modern": "default: #3B3B3B"
11816+
}
11817+
},
11818+
{
11819+
"c": " ",
11820+
"t": "source.css",
11821+
"r": {
11822+
"dark_plus": "default: #D4D4D4",
11823+
"light_plus": "default: #000000",
11824+
"dark_vs": "default: #D4D4D4",
11825+
"light_vs": "default: #000000",
11826+
"hc_black": "default: #FFFFFF",
11827+
"dark_modern": "default: #CCCCCC",
11828+
"hc_light": "default: #292929",
11829+
"light_modern": "default: #3B3B3B"
11830+
}
11831+
},
11832+
{
11833+
"c": "{",
11834+
"t": "source.css meta.property-list.css punctuation.section.property-list.begin.bracket.curly.css",
11835+
"r": {
11836+
"dark_plus": "default: #D4D4D4",
11837+
"light_plus": "default: #000000",
11838+
"dark_vs": "default: #D4D4D4",
11839+
"light_vs": "default: #000000",
11840+
"hc_black": "default: #FFFFFF",
11841+
"dark_modern": "default: #CCCCCC",
11842+
"hc_light": "default: #292929",
11843+
"light_modern": "default: #3B3B3B"
11844+
}
11845+
},
11846+
{
11847+
"c": " ",
11848+
"t": "source.css meta.property-list.css",
11849+
"r": {
11850+
"dark_plus": "default: #D4D4D4",
11851+
"light_plus": "default: #000000",
11852+
"dark_vs": "default: #D4D4D4",
11853+
"light_vs": "default: #000000",
11854+
"hc_black": "default: #FFFFFF",
11855+
"dark_modern": "default: #CCCCCC",
11856+
"hc_light": "default: #292929",
11857+
"light_modern": "default: #3B3B3B"
11858+
}
11859+
},
11860+
{
11861+
"c": "font-size",
11862+
"t": "source.css meta.property-list.css meta.property-name.css support.type.property-name.css",
11863+
"r": {
11864+
"dark_plus": "support.type.property-name: #9CDCFE",
11865+
"light_plus": "support.type.property-name: #E50000",
11866+
"dark_vs": "support.type.property-name: #9CDCFE",
11867+
"light_vs": "support.type.property-name: #E50000",
11868+
"hc_black": "support.type.property-name: #D4D4D4",
11869+
"dark_modern": "support.type.property-name: #9CDCFE",
11870+
"hc_light": "support.type.property-name: #264F78",
11871+
"light_modern": "support.type.property-name: #E50000"
11872+
}
11873+
},
11874+
{
11875+
"c": ":",
11876+
"t": "source.css meta.property-list.css punctuation.separator.key-value.css",
11877+
"r": {
11878+
"dark_plus": "default: #D4D4D4",
11879+
"light_plus": "default: #000000",
11880+
"dark_vs": "default: #D4D4D4",
11881+
"light_vs": "default: #000000",
11882+
"hc_black": "default: #FFFFFF",
11883+
"dark_modern": "default: #CCCCCC",
11884+
"hc_light": "default: #292929",
11885+
"light_modern": "default: #3B3B3B"
11886+
}
11887+
},
11888+
{
11889+
"c": " ",
11890+
"t": "source.css meta.property-list.css",
11891+
"r": {
11892+
"dark_plus": "default: #D4D4D4",
11893+
"light_plus": "default: #000000",
11894+
"dark_vs": "default: #D4D4D4",
11895+
"light_vs": "default: #000000",
11896+
"hc_black": "default: #FFFFFF",
11897+
"dark_modern": "default: #CCCCCC",
11898+
"hc_light": "default: #292929",
11899+
"light_modern": "default: #3B3B3B"
11900+
}
11901+
},
11902+
{
11903+
"c": "16",
11904+
"t": "source.css meta.property-list.css meta.property-value.css constant.numeric.css",
11905+
"r": {
11906+
"dark_plus": "constant.numeric: #B5CEA8",
11907+
"light_plus": "constant.numeric: #098658",
11908+
"dark_vs": "constant.numeric: #B5CEA8",
11909+
"light_vs": "constant.numeric: #098658",
11910+
"hc_black": "constant.numeric: #B5CEA8",
11911+
"dark_modern": "constant.numeric: #B5CEA8",
11912+
"hc_light": "constant.numeric: #096D48",
11913+
"light_modern": "constant.numeric: #098658"
11914+
}
11915+
},
11916+
{
11917+
"c": "px",
11918+
"t": "source.css meta.property-list.css meta.property-value.css constant.numeric.css keyword.other.unit.px.css",
11919+
"r": {
11920+
"dark_plus": "keyword.other.unit: #B5CEA8",
11921+
"light_plus": "keyword.other.unit: #098658",
11922+
"dark_vs": "keyword.other.unit: #B5CEA8",
11923+
"light_vs": "keyword.other.unit: #098658",
11924+
"hc_black": "keyword.other.unit: #B5CEA8",
11925+
"dark_modern": "keyword.other.unit: #B5CEA8",
11926+
"hc_light": "keyword.other.unit: #096D48",
11927+
"light_modern": "keyword.other.unit: #098658"
11928+
}
11929+
},
11930+
{
11931+
"c": ";",
11932+
"t": "source.css meta.property-list.css punctuation.terminator.rule.css",
11933+
"r": {
11934+
"dark_plus": "default: #D4D4D4",
11935+
"light_plus": "default: #000000",
11936+
"dark_vs": "default: #D4D4D4",
11937+
"light_vs": "default: #000000",
11938+
"hc_black": "default: #FFFFFF",
11939+
"dark_modern": "default: #CCCCCC",
11940+
"hc_light": "default: #292929",
11941+
"light_modern": "default: #3B3B3B"
11942+
}
11943+
},
1163611944
{
1163711945
"c": "}",
1163811946
"t": "source.css meta.property-list.css punctuation.section.property-list.end.bracket.curly.css",

0 commit comments

Comments
 (0)