Add tree-sitter for css (#244112)

* Add tree-sitter for css

* Hard code root scopes

* Add some temp logging for test

* Exclude css from module ignore

* Remove log lines
This commit is contained in:
Alex Ross 2025-03-20 13:45:47 +01:00 committed by GitHub
parent 694d8e2dbe
commit 7249efcfae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
16 changed files with 8723 additions and 27 deletions

View File

@ -59,6 +59,7 @@ fsevents/test/**
!@vscode/tree-sitter-wasm/wasm/tree-sitter-typescript.wasm
!@vscode/tree-sitter-wasm/wasm/tree-sitter-regex.wasm
!@vscode/tree-sitter-wasm/wasm/tree-sitter-ini.wasm
!@vscode/tree-sitter-wasm/wasm/tree-sitter-css.wasm
native-keymap/binding.gyp
native-keymap/build/**

View File

@ -70,17 +70,20 @@ suite('colorization', () => {
suiteSetup(async function () {
originalSettingValues = [
workspace.getConfiguration('editor.experimental').get('preferTreeSitter.typescript'),
workspace.getConfiguration('editor.experimental').get('preferTreeSitter.ini'),
workspace.getConfiguration('editor.experimental').get('preferTreeSitter.regex'),
workspace.getConfiguration('editor.experimental').get('preferTreeSitter.ini')
workspace.getConfiguration('editor.experimental').get('preferTreeSitter.css')
];
await workspace.getConfiguration('editor.experimental').update('preferTreeSitter.typescript', true, ConfigurationTarget.Global);
await workspace.getConfiguration('editor.experimental').update('preferTreeSitter.regex', true, ConfigurationTarget.Global);
await workspace.getConfiguration('editor.experimental').update('preferTreeSitter.ini', true, ConfigurationTarget.Global);
await workspace.getConfiguration('editor.experimental').update('preferTreeSitter.regex', true, ConfigurationTarget.Global);
await workspace.getConfiguration('editor.experimental').update('preferTreeSitter.css', true, ConfigurationTarget.Global);
});
suiteTeardown(async function () {
await workspace.getConfiguration('editor.experimental').update('preferTreeSitter.typescript', originalSettingValues[0], ConfigurationTarget.Global);
await workspace.getConfiguration('editor.experimental').update('preferTreeSitter.regex', originalSettingValues[1], ConfigurationTarget.Global);
await workspace.getConfiguration('editor.experimental').update('preferTreeSitter.ini', originalSettingValues[2], ConfigurationTarget.Global);
await workspace.getConfiguration('editor.experimental').update('preferTreeSitter.ini', originalSettingValues[1], ConfigurationTarget.Global);
await workspace.getConfiguration('editor.experimental').update('preferTreeSitter.regex', originalSettingValues[2], ConfigurationTarget.Global);
await workspace.getConfiguration('editor.experimental').update('preferTreeSitter.css', originalSettingValues[3], ConfigurationTarget.Global);
});
for (const fixture of fs.readdirSync(fixturesPath)) {

View File

@ -156,4 +156,8 @@ footer a:visited {
right: 0;
width: 148px;
height: 110px;
}
}
.chat-feature-container .codicon[class*='codicon-'] {
font-size: 16px;
}

View File

@ -11633,6 +11633,314 @@
"light_modern": "default: #3B3B3B"
}
},
{
"c": "}",
"t": "source.css meta.property-list.css punctuation.section.property-list.end.bracket.curly.css",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "default: #FFFFFF",
"dark_modern": "default: #CCCCCC",
"hc_light": "default: #292929",
"light_modern": "default: #3B3B3B"
}
},
{
"c": ".",
"t": "source.css meta.selector.css entity.other.attribute-name.class.css punctuation.definition.entity.css",
"r": {
"dark_plus": "entity.other.attribute-name.class.css: #D7BA7D",
"light_plus": "entity.other.attribute-name.class.css: #800000",
"dark_vs": "entity.other.attribute-name.class.css: #D7BA7D",
"light_vs": "entity.other.attribute-name.class.css: #800000",
"hc_black": "entity.other.attribute-name.class.css: #D7BA7D",
"dark_modern": "entity.other.attribute-name.class.css: #D7BA7D",
"hc_light": "entity.other.attribute-name.class.css: #0F4A85",
"light_modern": "entity.other.attribute-name.class.css: #800000"
}
},
{
"c": "chat-feature-container",
"t": "source.css meta.selector.css entity.other.attribute-name.class.css",
"r": {
"dark_plus": "entity.other.attribute-name.class.css: #D7BA7D",
"light_plus": "entity.other.attribute-name.class.css: #800000",
"dark_vs": "entity.other.attribute-name.class.css: #D7BA7D",
"light_vs": "entity.other.attribute-name.class.css: #800000",
"hc_black": "entity.other.attribute-name.class.css: #D7BA7D",
"dark_modern": "entity.other.attribute-name.class.css: #D7BA7D",
"hc_light": "entity.other.attribute-name.class.css: #0F4A85",
"light_modern": "entity.other.attribute-name.class.css: #800000"
}
},
{
"c": " ",
"t": "source.css meta.selector.css",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "default: #FFFFFF",
"dark_modern": "default: #CCCCCC",
"hc_light": "default: #292929",
"light_modern": "default: #3B3B3B"
}
},
{
"c": ".",
"t": "source.css meta.selector.css entity.other.attribute-name.class.css punctuation.definition.entity.css",
"r": {
"dark_plus": "entity.other.attribute-name.class.css: #D7BA7D",
"light_plus": "entity.other.attribute-name.class.css: #800000",
"dark_vs": "entity.other.attribute-name.class.css: #D7BA7D",
"light_vs": "entity.other.attribute-name.class.css: #800000",
"hc_black": "entity.other.attribute-name.class.css: #D7BA7D",
"dark_modern": "entity.other.attribute-name.class.css: #D7BA7D",
"hc_light": "entity.other.attribute-name.class.css: #0F4A85",
"light_modern": "entity.other.attribute-name.class.css: #800000"
}
},
{
"c": "codicon",
"t": "source.css meta.selector.css entity.other.attribute-name.class.css",
"r": {
"dark_plus": "entity.other.attribute-name.class.css: #D7BA7D",
"light_plus": "entity.other.attribute-name.class.css: #800000",
"dark_vs": "entity.other.attribute-name.class.css: #D7BA7D",
"light_vs": "entity.other.attribute-name.class.css: #800000",
"hc_black": "entity.other.attribute-name.class.css: #D7BA7D",
"dark_modern": "entity.other.attribute-name.class.css: #D7BA7D",
"hc_light": "entity.other.attribute-name.class.css: #0F4A85",
"light_modern": "entity.other.attribute-name.class.css: #800000"
}
},
{
"c": "[",
"t": "source.css meta.selector.css meta.attribute-selector.css punctuation.definition.entity.begin.bracket.square.css",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "default: #FFFFFF",
"dark_modern": "default: #CCCCCC",
"hc_light": "default: #292929",
"light_modern": "default: #3B3B3B"
}
},
{
"c": "class",
"t": "source.css meta.selector.css meta.attribute-selector.css entity.other.attribute-name.css",
"r": {
"dark_plus": "entity.other.attribute-name: #9CDCFE",
"light_plus": "entity.other.attribute-name: #E50000",
"dark_vs": "entity.other.attribute-name: #9CDCFE",
"light_vs": "entity.other.attribute-name: #E50000",
"hc_black": "entity.other.attribute-name: #9CDCFE",
"dark_modern": "entity.other.attribute-name: #9CDCFE",
"hc_light": "entity.other.attribute-name: #264F78",
"light_modern": "entity.other.attribute-name: #E50000"
}
},
{
"c": "*=",
"t": "source.css meta.selector.css meta.attribute-selector.css keyword.operator.pattern.css",
"r": {
"dark_plus": "keyword.operator: #D4D4D4",
"light_plus": "keyword.operator: #000000",
"dark_vs": "keyword.operator: #D4D4D4",
"light_vs": "keyword.operator: #000000",
"hc_black": "keyword.operator: #D4D4D4",
"dark_modern": "keyword.operator: #D4D4D4",
"hc_light": "keyword.operator: #000000",
"light_modern": "keyword.operator: #000000"
}
},
{
"c": "'",
"t": "source.css meta.selector.css meta.attribute-selector.css string.quoted.single.css punctuation.definition.string.begin.css",
"r": {
"dark_plus": "string: #CE9178",
"light_plus": "string: #A31515",
"dark_vs": "string: #CE9178",
"light_vs": "string: #A31515",
"hc_black": "string: #CE9178",
"dark_modern": "string: #CE9178",
"hc_light": "string: #0F4A85",
"light_modern": "string: #A31515"
}
},
{
"c": "codicon-",
"t": "source.css meta.selector.css meta.attribute-selector.css string.quoted.single.css",
"r": {
"dark_plus": "string: #CE9178",
"light_plus": "string: #A31515",
"dark_vs": "string: #CE9178",
"light_vs": "string: #A31515",
"hc_black": "string: #CE9178",
"dark_modern": "string: #CE9178",
"hc_light": "string: #0F4A85",
"light_modern": "string: #A31515"
}
},
{
"c": "'",
"t": "source.css meta.selector.css meta.attribute-selector.css string.quoted.single.css punctuation.definition.string.end.css",
"r": {
"dark_plus": "string: #CE9178",
"light_plus": "string: #A31515",
"dark_vs": "string: #CE9178",
"light_vs": "string: #A31515",
"hc_black": "string: #CE9178",
"dark_modern": "string: #CE9178",
"hc_light": "string: #0F4A85",
"light_modern": "string: #A31515"
}
},
{
"c": "]",
"t": "source.css meta.selector.css meta.attribute-selector.css punctuation.definition.entity.end.bracket.square.css",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "default: #FFFFFF",
"dark_modern": "default: #CCCCCC",
"hc_light": "default: #292929",
"light_modern": "default: #3B3B3B"
}
},
{
"c": " ",
"t": "source.css",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "default: #FFFFFF",
"dark_modern": "default: #CCCCCC",
"hc_light": "default: #292929",
"light_modern": "default: #3B3B3B"
}
},
{
"c": "{",
"t": "source.css meta.property-list.css punctuation.section.property-list.begin.bracket.curly.css",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "default: #FFFFFF",
"dark_modern": "default: #CCCCCC",
"hc_light": "default: #292929",
"light_modern": "default: #3B3B3B"
}
},
{
"c": " ",
"t": "source.css meta.property-list.css",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "default: #FFFFFF",
"dark_modern": "default: #CCCCCC",
"hc_light": "default: #292929",
"light_modern": "default: #3B3B3B"
}
},
{
"c": "font-size",
"t": "source.css meta.property-list.css meta.property-name.css support.type.property-name.css",
"r": {
"dark_plus": "support.type.property-name: #9CDCFE",
"light_plus": "support.type.property-name: #E50000",
"dark_vs": "support.type.property-name: #9CDCFE",
"light_vs": "support.type.property-name: #E50000",
"hc_black": "support.type.property-name: #D4D4D4",
"dark_modern": "support.type.property-name: #9CDCFE",
"hc_light": "support.type.property-name: #264F78",
"light_modern": "support.type.property-name: #E50000"
}
},
{
"c": ":",
"t": "source.css meta.property-list.css punctuation.separator.key-value.css",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "default: #FFFFFF",
"dark_modern": "default: #CCCCCC",
"hc_light": "default: #292929",
"light_modern": "default: #3B3B3B"
}
},
{
"c": " ",
"t": "source.css meta.property-list.css",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "default: #FFFFFF",
"dark_modern": "default: #CCCCCC",
"hc_light": "default: #292929",
"light_modern": "default: #3B3B3B"
}
},
{
"c": "16",
"t": "source.css meta.property-list.css meta.property-value.css constant.numeric.css",
"r": {
"dark_plus": "constant.numeric: #B5CEA8",
"light_plus": "constant.numeric: #098658",
"dark_vs": "constant.numeric: #B5CEA8",
"light_vs": "constant.numeric: #098658",
"hc_black": "constant.numeric: #B5CEA8",
"dark_modern": "constant.numeric: #B5CEA8",
"hc_light": "constant.numeric: #096D48",
"light_modern": "constant.numeric: #098658"
}
},
{
"c": "px",
"t": "source.css meta.property-list.css meta.property-value.css constant.numeric.css keyword.other.unit.px.css",
"r": {
"dark_plus": "keyword.other.unit: #B5CEA8",
"light_plus": "keyword.other.unit: #098658",
"dark_vs": "keyword.other.unit: #B5CEA8",
"light_vs": "keyword.other.unit: #098658",
"hc_black": "keyword.other.unit: #B5CEA8",
"dark_modern": "keyword.other.unit: #B5CEA8",
"hc_light": "keyword.other.unit: #096D48",
"light_modern": "keyword.other.unit: #098658"
}
},
{
"c": ";",
"t": "source.css meta.property-list.css punctuation.terminator.rule.css",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "default: #FFFFFF",
"dark_modern": "default: #CCCCCC",
"hc_light": "default: #292929",
"light_modern": "default: #3B3B3B"
}
},
{
"c": "}",
"t": "source.css meta.property-list.css punctuation.section.property-list.end.bracket.curly.css",

View File

@ -1 +1,506 @@
[]
[
{
"c": ":",
"t": "meta.selector.css entity.other.attribute-name.pseudo-class.css",
"r": {
"dark_plus": "entity.other.attribute-name: #9CDCFE",
"light_plus": "entity.other.attribute-name: #E50000",
"dark_vs": "entity.other.attribute-name: #9CDCFE",
"light_vs": "entity.other.attribute-name: #E50000",
"hc_black": "entity.other.attribute-name: #9CDCFE",
"dark_modern": "entity.other.attribute-name: #9CDCFE",
"hc_light": "entity.other.attribute-name: #264F78",
"light_modern": "entity.other.attribute-name: #E50000"
}
},
{
"c": "root",
"t": "meta.selector.css entity.other.attribute-name.pseudo-class.css",
"r": {
"dark_plus": "entity.other.attribute-name: #9CDCFE",
"light_plus": "entity.other.attribute-name: #E50000",
"dark_vs": "entity.other.attribute-name: #9CDCFE",
"light_vs": "entity.other.attribute-name: #E50000",
"hc_black": "entity.other.attribute-name: #9CDCFE",
"dark_modern": "entity.other.attribute-name: #9CDCFE",
"hc_light": "entity.other.attribute-name: #264F78",
"light_modern": "entity.other.attribute-name: #E50000"
}
},
{
"c": "{",
"t": "punctuation.css",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "default: #FFFFFF",
"dark_modern": "default: #CCCCCC",
"hc_light": "default: #292929",
"light_modern": "default: #3B3B3B"
}
},
{
"c": "--spacing-unit",
"t": "support.type.property-name.css",
"r": {
"dark_plus": "support.type.property-name: #9CDCFE",
"light_plus": "support.type.property-name: #E50000",
"dark_vs": "support.type.property-name: #9CDCFE",
"light_vs": "support.type.property-name: #E50000",
"hc_black": "support.type.property-name: #D4D4D4",
"dark_modern": "support.type.property-name: #9CDCFE",
"hc_light": "support.type.property-name: #264F78",
"light_modern": "support.type.property-name: #E50000"
}
},
{
"c": ":",
"t": "",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "default: #FFFFFF",
"dark_modern": "default: #CCCCCC",
"hc_light": "default: #292929",
"light_modern": "default: #3B3B3B"
}
},
{
"c": "px",
"t": "constant.numeric.css keyword.other.unit.css",
"r": {
"dark_plus": "keyword.other.unit: #B5CEA8",
"light_plus": "keyword.other.unit: #098658",
"dark_vs": "keyword.other.unit: #B5CEA8",
"light_vs": "keyword.other.unit: #098658",
"hc_black": "keyword.other.unit: #B5CEA8",
"dark_modern": "keyword.other.unit: #B5CEA8",
"hc_light": "keyword.other.unit: #096D48",
"light_modern": "keyword.other.unit: #098658"
}
},
{
"c": ";",
"t": "",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "default: #FFFFFF",
"dark_modern": "default: #CCCCCC",
"hc_light": "default: #292929",
"light_modern": "default: #3B3B3B"
}
},
{
"c": "--cell-padding",
"t": "support.type.property-name.css",
"r": {
"dark_plus": "support.type.property-name: #9CDCFE",
"light_plus": "support.type.property-name: #E50000",
"dark_vs": "support.type.property-name: #9CDCFE",
"light_vs": "support.type.property-name: #E50000",
"hc_black": "support.type.property-name: #D4D4D4",
"dark_modern": "support.type.property-name: #9CDCFE",
"hc_light": "support.type.property-name: #264F78",
"light_modern": "support.type.property-name: #E50000"
}
},
{
"c": ":",
"t": "",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "default: #FFFFFF",
"dark_modern": "default: #CCCCCC",
"hc_light": "default: #292929",
"light_modern": "default: #3B3B3B"
}
},
{
"c": "(",
"t": "punctuation.css",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "default: #FFFFFF",
"dark_modern": "default: #CCCCCC",
"hc_light": "default: #292929",
"light_modern": "default: #3B3B3B"
}
},
{
"c": "4",
"t": "constant.numeric.css",
"r": {
"dark_plus": "constant.numeric: #B5CEA8",
"light_plus": "constant.numeric: #098658",
"dark_vs": "constant.numeric: #B5CEA8",
"light_vs": "constant.numeric: #098658",
"hc_black": "constant.numeric: #B5CEA8",
"dark_modern": "constant.numeric: #B5CEA8",
"hc_light": "constant.numeric: #096D48",
"light_modern": "constant.numeric: #098658"
}
},
{
"c": "*",
"t": "",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "default: #FFFFFF",
"dark_modern": "default: #CCCCCC",
"hc_light": "default: #292929",
"light_modern": "default: #3B3B3B"
}
},
{
"c": "var",
"t": "support.function.css",
"r": {
"dark_plus": "support.function: #DCDCAA",
"light_plus": "support.function: #795E26",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "support.function: #DCDCAA",
"dark_modern": "support.function: #DCDCAA",
"hc_light": "support.function: #5E2CBC",
"light_modern": "support.function: #795E26"
}
},
{
"c": "(",
"t": "punctuation.css",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "default: #FFFFFF",
"dark_modern": "default: #CCCCCC",
"hc_light": "default: #292929",
"light_modern": "default: #3B3B3B"
}
},
{
"c": "--spacing-unit",
"t": "support.constant.property-value.css",
"r": {
"dark_plus": "support.constant.property-value: #CE9178",
"light_plus": "support.constant.property-value: #0451A5",
"dark_vs": "default: #D4D4D4",
"light_vs": "support.constant.property-value: #0451A5",
"hc_black": "support.constant.property-value: #CE9178",
"dark_modern": "support.constant.property-value: #CE9178",
"hc_light": "support.constant.property-value: #0451A5",
"light_modern": "support.constant.property-value: #0451A5"
}
},
{
"c": ")",
"t": "punctuation.css",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "default: #FFFFFF",
"dark_modern": "default: #CCCCCC",
"hc_light": "default: #292929",
"light_modern": "default: #3B3B3B"
}
},
{
"c": ")",
"t": "punctuation.css",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "default: #FFFFFF",
"dark_modern": "default: #CCCCCC",
"hc_light": "default: #292929",
"light_modern": "default: #3B3B3B"
}
},
{
"c": ";",
"t": "",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "default: #FFFFFF",
"dark_modern": "default: #CCCCCC",
"hc_light": "default: #292929",
"light_modern": "default: #3B3B3B"
}
},
{
"c": "}",
"t": "punctuation.css",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "default: #FFFFFF",
"dark_modern": "default: #CCCCCC",
"hc_light": "default: #292929",
"light_modern": "default: #3B3B3B"
}
},
{
"c": "body",
"t": "meta.selector.css entity.name.tag.css",
"r": {
"dark_plus": "entity.name.tag.css: #D7BA7D",
"light_plus": "entity.name.tag: #800000",
"dark_vs": "entity.name.tag.css: #D7BA7D",
"light_vs": "entity.name.tag: #800000",
"hc_black": "entity.name.tag.css: #D7BA7D",
"dark_modern": "entity.name.tag.css: #D7BA7D",
"hc_light": "entity.name.tag: #0F4A85",
"light_modern": "entity.name.tag: #800000"
}
},
{
"c": "{",
"t": "punctuation.css",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "default: #FFFFFF",
"dark_modern": "default: #CCCCCC",
"hc_light": "default: #292929",
"light_modern": "default: #3B3B3B"
}
},
{
"c": "padding-left",
"t": "support.type.property-name.css",
"r": {
"dark_plus": "support.type.property-name: #9CDCFE",
"light_plus": "support.type.property-name: #E50000",
"dark_vs": "support.type.property-name: #9CDCFE",
"light_vs": "support.type.property-name: #E50000",
"hc_black": "support.type.property-name: #D4D4D4",
"dark_modern": "support.type.property-name: #9CDCFE",
"hc_light": "support.type.property-name: #264F78",
"light_modern": "support.type.property-name: #E50000"
}
},
{
"c": ":",
"t": "",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "default: #FFFFFF",
"dark_modern": "default: #CCCCCC",
"hc_light": "default: #292929",
"light_modern": "default: #3B3B3B"
}
},
{
"c": "calc",
"t": "support.function.css",
"r": {
"dark_plus": "support.function: #DCDCAA",
"light_plus": "support.function: #795E26",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "support.function: #DCDCAA",
"dark_modern": "support.function: #DCDCAA",
"hc_light": "support.function: #5E2CBC",
"light_modern": "support.function: #795E26"
}
},
{
"c": "(",
"t": "punctuation.css",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "default: #FFFFFF",
"dark_modern": "default: #CCCCCC",
"hc_light": "default: #292929",
"light_modern": "default: #3B3B3B"
}
},
{
"c": "4",
"t": "constant.numeric.css",
"r": {
"dark_plus": "constant.numeric: #B5CEA8",
"light_plus": "constant.numeric: #098658",
"dark_vs": "constant.numeric: #B5CEA8",
"light_vs": "constant.numeric: #098658",
"hc_black": "constant.numeric: #B5CEA8",
"dark_modern": "constant.numeric: #B5CEA8",
"hc_light": "constant.numeric: #096D48",
"light_modern": "constant.numeric: #098658"
}
},
{
"c": "*",
"t": "",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "default: #FFFFFF",
"dark_modern": "default: #CCCCCC",
"hc_light": "default: #292929",
"light_modern": "default: #3B3B3B"
}
},
{
"c": "var",
"t": "support.function.css",
"r": {
"dark_plus": "support.function: #DCDCAA",
"light_plus": "support.function: #795E26",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "support.function: #DCDCAA",
"dark_modern": "support.function: #DCDCAA",
"hc_light": "support.function: #5E2CBC",
"light_modern": "support.function: #795E26"
}
},
{
"c": "(",
"t": "punctuation.css",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "default: #FFFFFF",
"dark_modern": "default: #CCCCCC",
"hc_light": "default: #292929",
"light_modern": "default: #3B3B3B"
}
},
{
"c": "--spacing-unit",
"t": "support.constant.property-value.css",
"r": {
"dark_plus": "support.constant.property-value: #CE9178",
"light_plus": "support.constant.property-value: #0451A5",
"dark_vs": "default: #D4D4D4",
"light_vs": "support.constant.property-value: #0451A5",
"hc_black": "support.constant.property-value: #CE9178",
"dark_modern": "support.constant.property-value: #CE9178",
"hc_light": "support.constant.property-value: #0451A5",
"light_modern": "support.constant.property-value: #0451A5"
}
},
{
"c": ",",
"t": "",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "default: #FFFFFF",
"dark_modern": "default: #CCCCCC",
"hc_light": "default: #292929",
"light_modern": "default: #3B3B3B"
}
},
{
"c": "px",
"t": "constant.numeric.css keyword.other.unit.css",
"r": {
"dark_plus": "keyword.other.unit: #B5CEA8",
"light_plus": "keyword.other.unit: #098658",
"dark_vs": "keyword.other.unit: #B5CEA8",
"light_vs": "keyword.other.unit: #098658",
"hc_black": "keyword.other.unit: #B5CEA8",
"dark_modern": "keyword.other.unit: #B5CEA8",
"hc_light": "keyword.other.unit: #096D48",
"light_modern": "keyword.other.unit: #098658"
}
},
{
"c": ")",
"t": "punctuation.css",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "default: #FFFFFF",
"dark_modern": "default: #CCCCCC",
"hc_light": "default: #292929",
"light_modern": "default: #3B3B3B"
}
},
{
"c": ")",
"t": "punctuation.css",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "default: #FFFFFF",
"dark_modern": "default: #CCCCCC",
"hc_light": "default: #292929",
"light_modern": "default: #3B3B3B"
}
},
{
"c": ";",
"t": "",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "default: #FFFFFF",
"dark_modern": "default: #CCCCCC",
"hc_light": "default: #292929",
"light_modern": "default: #3B3B3B"
}
},
{
"c": "}",
"t": "punctuation.css",
"r": {
"dark_plus": "default: #D4D4D4",
"light_plus": "default: #000000",
"dark_vs": "default: #D4D4D4",
"light_vs": "default: #000000",
"hc_black": "default: #FFFFFF",
"dark_modern": "default: #CCCCCC",
"hc_light": "default: #292929",
"light_modern": "default: #3B3B3B"
}
}
]

8
package-lock.json generated
View File

@ -23,7 +23,7 @@
"@vscode/spdlog": "^0.15.0",
"@vscode/sqlite3": "5.1.8-vscode",
"@vscode/sudo-prompt": "9.3.1",
"@vscode/tree-sitter-wasm": "^0.1.3",
"@vscode/tree-sitter-wasm": "^0.1.4",
"@vscode/vscode-languagedetection": "1.0.21",
"@vscode/windows-mutex": "^0.5.0",
"@vscode/windows-process-tree": "^0.6.0",
@ -3170,9 +3170,9 @@
}
},
"node_modules/@vscode/tree-sitter-wasm": {
"version": "0.1.3",
"resolved": "https://registry.npmjs.org/@vscode/tree-sitter-wasm/-/tree-sitter-wasm-0.1.3.tgz",
"integrity": "sha512-gs0+tlOfriWc6h1kXTCZvmPTuusN+SeDs7yDVZn/kKLGgqlhXFbl/gWKItxaTeryTDalN8N+ikneni6+3UDOag==",
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/@vscode/tree-sitter-wasm/-/tree-sitter-wasm-0.1.4.tgz",
"integrity": "sha512-kQVVg/CamCYDM+/XYCZuNTQyixjZd8ts/Gf84UzjEY0eRnbg6kiy5I9z2/2i3XdqwhI87iG07rkMR2KwhqcSbA==",
"license": "MIT"
},
"node_modules/@vscode/v8-heap-parser": {

View File

@ -82,7 +82,7 @@
"@vscode/spdlog": "^0.15.0",
"@vscode/sqlite3": "5.1.8-vscode",
"@vscode/sudo-prompt": "9.3.1",
"@vscode/tree-sitter-wasm": "^0.1.3",
"@vscode/tree-sitter-wasm": "^0.1.4",
"@vscode/vscode-languagedetection": "1.0.21",
"@vscode/windows-mutex": "^0.5.0",
"@vscode/windows-process-tree": "^0.6.0",

View File

@ -16,7 +16,7 @@
"@vscode/proxy-agent": "^0.32.0",
"@vscode/ripgrep": "^1.15.11",
"@vscode/spdlog": "^0.15.0",
"@vscode/tree-sitter-wasm": "^0.1.3",
"@vscode/tree-sitter-wasm": "^0.1.4",
"@vscode/vscode-languagedetection": "1.0.21",
"@vscode/windows-process-tree": "^0.6.0",
"@vscode/windows-registry": "^1.1.0",
@ -470,9 +470,9 @@
}
},
"node_modules/@vscode/tree-sitter-wasm": {
"version": "0.1.3",
"resolved": "https://registry.npmjs.org/@vscode/tree-sitter-wasm/-/tree-sitter-wasm-0.1.3.tgz",
"integrity": "sha512-gs0+tlOfriWc6h1kXTCZvmPTuusN+SeDs7yDVZn/kKLGgqlhXFbl/gWKItxaTeryTDalN8N+ikneni6+3UDOag==",
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/@vscode/tree-sitter-wasm/-/tree-sitter-wasm-0.1.4.tgz",
"integrity": "sha512-kQVVg/CamCYDM+/XYCZuNTQyixjZd8ts/Gf84UzjEY0eRnbg6kiy5I9z2/2i3XdqwhI87iG07rkMR2KwhqcSbA==",
"license": "MIT"
},
"node_modules/@vscode/vscode-languagedetection": {

View File

@ -11,7 +11,7 @@
"@vscode/proxy-agent": "^0.32.0",
"@vscode/ripgrep": "^1.15.11",
"@vscode/spdlog": "^0.15.0",
"@vscode/tree-sitter-wasm": "^0.1.3",
"@vscode/tree-sitter-wasm": "^0.1.4",
"@vscode/vscode-languagedetection": "1.0.21",
"@vscode/windows-process-tree": "^0.6.0",
"@vscode/windows-registry": "^1.1.0",

View File

@ -11,7 +11,7 @@
"@microsoft/1ds-core-js": "^3.2.13",
"@microsoft/1ds-post-js": "^3.2.13",
"@vscode/iconv-lite-umd": "0.7.0",
"@vscode/tree-sitter-wasm": "^0.1.3",
"@vscode/tree-sitter-wasm": "^0.1.4",
"@vscode/vscode-languagedetection": "1.0.21",
"@xterm/addon-clipboard": "^0.2.0-beta.82",
"@xterm/addon-image": "^0.9.0-beta.99",
@ -76,9 +76,9 @@
"integrity": "sha512-bRRFxLfg5dtAyl5XyiVWz/ZBPahpOpPrNYnnHpOpUZvam4tKH35wdhP4Kj6PbM0+KdliOsPzbGWpkxcdpNB/sg=="
},
"node_modules/@vscode/tree-sitter-wasm": {
"version": "0.1.3",
"resolved": "https://registry.npmjs.org/@vscode/tree-sitter-wasm/-/tree-sitter-wasm-0.1.3.tgz",
"integrity": "sha512-gs0+tlOfriWc6h1kXTCZvmPTuusN+SeDs7yDVZn/kKLGgqlhXFbl/gWKItxaTeryTDalN8N+ikneni6+3UDOag==",
"version": "0.1.4",
"resolved": "https://registry.npmjs.org/@vscode/tree-sitter-wasm/-/tree-sitter-wasm-0.1.4.tgz",
"integrity": "sha512-kQVVg/CamCYDM+/XYCZuNTQyixjZd8ts/Gf84UzjEY0eRnbg6kiy5I9z2/2i3XdqwhI87iG07rkMR2KwhqcSbA==",
"license": "MIT"
},
"node_modules/@vscode/vscode-languagedetection": {

View File

@ -6,7 +6,7 @@
"@microsoft/1ds-core-js": "^3.2.13",
"@microsoft/1ds-post-js": "^3.2.13",
"@vscode/iconv-lite-umd": "0.7.0",
"@vscode/tree-sitter-wasm": "^0.1.3",
"@vscode/tree-sitter-wasm": "^0.1.4",
"@vscode/vscode-languagedetection": "1.0.21",
"@xterm/addon-clipboard": "^0.2.0-beta.82",
"@xterm/addon-image": "^0.9.0-beta.99",

View File

@ -117,6 +117,12 @@ const editorConfiguration: IConfigurationNode = {
markdownDescription: nls.localize('editor.experimental.treeSitterTelemetry', "Controls whether tree sitter parsing should be turned on and telemetry collected. Setting `editor.experimental.preferTreeSitter` for specific languages will take precedence."),
tags: ['experimental', 'onExP']
},
'editor.experimental.preferTreeSitter.css': {
type: 'boolean',
default: false,
markdownDescription: nls.localize('editor.experimental.preferTreeSitter.css', "Controls whether tree sitter parsing should be turned on for css. This will take precedence over `editor.experimental.treeSitterTelemetry` for css."),
tags: ['experimental', 'onExP']
},
'editor.experimental.preferTreeSitter.typescript': {
type: 'boolean',
default: false,

View File

@ -0,0 +1,90 @@
; Order matters! Place lower precedence first.
[
"{"
"}"
"("
")"
"["
"]"
] @punctuation.css
[
"*="
] @keyword.operator.css
(comment) @comment.block.css
; Selectors
(selectors) @meta.selector.css
(class_selector) @entity.other.attribute-name.class.css
(tag_name) @entity.name.tag.css
(pseudo_class_selector) @entity.other.attribute-name.pseudo-class.css
(attribute_name) @entity.other.attribute-name.css
; @ Rules
[
("@import")
("@charset")
("@namespace")
("@media")
("@supports")
("@keyframes")
] @keyword.control.at-rule.css
(keyword_query) @support.constant.media.css
(keyframes_name) @variable.parameter.keyframe-list.css
; Functions
(function_name) @support.function.css
; Properties
(property_name) @support.type.property-name.css
; Other values
(plain_value) @support.constant.property-value.css
; Strings
((string_value) @string.quoted.single.css
(#match? @string.quoted.single.css "^'.*'$"))
((string_value) @string.quoted.double.css
(#match? @string.quoted.double.css "^\".*\"$"))
; Numbers
([
(integer_value)
(float_value)
]) @constant.numeric.css
(unit) @keyword.other.unit.css
; Special values
(declaration
((property_name) @support.type.property-name.css
(#eq? @support.type.property-name.css "font"))
(plain_value) @support.constant.font-name.css)
((color_value) @constant.other.color.rgb-value.hex.css
(#match? @constant.other.color.rgb-value.hex.css "^#.*"))
; Special Functions
(call_expression
((function_name) @support.function.url.css
(#eq? @support.function.url.css "url"))
(arguments
(plain_value) @variable.parameter.url.css))

View File

@ -12,7 +12,7 @@ import { importAMDNodeModule } from '../../../amdX.js';
import { IModelContentChangedEvent } from '../textModelEvents.js';
export const EDITOR_EXPERIMENTAL_PREFER_TREESITTER = 'editor.experimental.preferTreeSitter';
export const TREESITTER_ALLOWED_SUPPORT = ['typescript', 'ini', 'regex'];
export const TREESITTER_ALLOWED_SUPPORT = ['css', 'typescript', 'ini', 'regex'];
export const ITreeSitterParserService = createDecorator<ITreeSitterParserService>('treeSitterParserService');

View File

@ -53,6 +53,13 @@ interface EndOffsetWithMeta extends EndOffsetAndScopes {
metadata?: number;
}
export const TREESITTER_BASE_SCOPES: Record<string, string> = {
'css': 'source.css',
'typescript': 'source.ts',
'ini': 'source.ini',
'regex': 'source.regex',
};
const BRACKETS = /[\{\}\[\]\<\>\(\)]/g;
export class TreeSitterTokenizationFeature extends Disposable implements ITreeSitterTokenizationFeature {
@ -634,6 +641,7 @@ export class TreeSitterTokenizationSupport extends Disposable implements ITreeSi
const stopwatch = StopWatch.create();
const rangeLength = rangeEndOffset - rangeStartOffset;
const encodedLanguageId = this._languageIdCodec.encodeLanguageId(this._languageId);
const baseScope: string = TREESITTER_BASE_SCOPES[this._languageId] || 'source';
if (captures.length === 0) {
if (tree) {
@ -645,11 +653,11 @@ export class TreeSitterTokenizationSupport extends Disposable implements ITreeSi
}
const endOffsetsAndScopes: EndOffsetAndScopes[] = Array(captures.length);
endOffsetsAndScopes.fill({ endOffset: 0, scopes: [], encodedLanguageId });
endOffsetsAndScopes.fill({ endOffset: 0, scopes: [baseScope], encodedLanguageId });
let tokenIndex = 0;
const increaseSizeOfTokensByOneToken = () => {
endOffsetsAndScopes.push({ endOffset: 0, scopes: [], encodedLanguageId });
endOffsetsAndScopes.push({ endOffset: 0, scopes: [baseScope], encodedLanguageId });
};
const brackets = (capture: QueryCapture, startOffset: number): number[] | undefined => {
@ -694,7 +702,7 @@ export class TreeSitterTokenizationSupport extends Disposable implements ITreeSi
endOffsetsAndScopes.splice(position, 0, { endOffset: endOffset, scopes: [...oldScopes, capture.name], bracket: brackets(capture, startOffset), encodedLanguageId: capture.encodedLanguageId });
endOffsetsAndScopes[tokenIndex].bracket = oldBracket;
} else {
endOffsetsAndScopes[tokenIndex] = { endOffset: endOffset, scopes: [capture.name], bracket: brackets(capture, startOffset), encodedLanguageId: capture.encodedLanguageId };
endOffsetsAndScopes[tokenIndex] = { endOffset: endOffset, scopes: [baseScope, capture.name], bracket: brackets(capture, startOffset), encodedLanguageId: capture.encodedLanguageId };
}
tokenIndex++;
};
@ -718,7 +726,7 @@ export class TreeSitterTokenizationSupport extends Disposable implements ITreeSi
const startOffset = endOffset - currentTokenLength;
if ((previousEndOffset >= 0) && (previousEndOffset < startOffset)) {
// Add en empty token to cover the space where there were no captures
endOffsetsAndScopes[tokenIndex] = { endOffset: startOffset, scopes: [], encodedLanguageId: this._encodedLanguageId };
endOffsetsAndScopes[tokenIndex] = { endOffset: startOffset, scopes: [baseScope], encodedLanguageId: this._encodedLanguageId };
tokenIndex++;
increaseSizeOfTokensByOneToken();