From e2a3691756246693948f868f8603588c91c563d2 Mon Sep 17 00:00:00 2001 From: Alex Ross Date: Thu, 13 Feb 2025 08:36:42 +0100 Subject: [PATCH] Use tree sitter for ini (#240534) * Use tree sitter for ini Part of #210475 * Include ini in tree sitter colorization tests * Remove /r --- build/.moduleignore | 5 + .../src/colorizer.test.ts | 2 +- .../test/colorize-fixtures/test.ini | 5 +- .../test/colorize-results/test_ini.json | 210 ++++++++ .../test_ini.json | 451 +++++++++++++++++- package-lock.json | 8 +- package.json | 2 +- remote/package-lock.json | 8 +- remote/package.json | 2 +- remote/web/package-lock.json | 8 +- remote/web/package.json | 2 +- .../config/editorConfigurationSchema.ts | 4 +- .../common/languages/highlights/ini.scm | 12 + .../treeSitter/treeSitterParserService.ts | 16 +- .../browser/treeSitterTokenizationFeature.ts | 5 +- 15 files changed, 714 insertions(+), 26 deletions(-) create mode 100644 src/vs/editor/common/languages/highlights/ini.scm diff --git a/build/.moduleignore b/build/.moduleignore index 01541e8c40a..5f7f287a88e 100644 --- a/build/.moduleignore +++ b/build/.moduleignore @@ -55,6 +55,11 @@ fsevents/test/** @vscode/windows-registry/build/** !@vscode/windows-registry/build/Release/*.node +@vscode/tree-sitter-wasm/wasm/tree-sitter-*.wasm +!@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 + native-keymap/binding.gyp native-keymap/build/** native-keymap/src/** diff --git a/extensions/vscode-colorize-tests/src/colorizer.test.ts b/extensions/vscode-colorize-tests/src/colorizer.test.ts index 0722490093d..815f548fee3 100644 --- a/extensions/vscode-colorize-tests/src/colorizer.test.ts +++ b/extensions/vscode-colorize-tests/src/colorizer.test.ts @@ -69,7 +69,7 @@ suite('colorization', () => { suiteSetup(async function () { originalSettingValue = workspace.getConfiguration('editor').get('experimental.preferTreeSitter'); - await workspace.getConfiguration('editor').update('experimental.preferTreeSitter', ["typescript"], ConfigurationTarget.Global); + await workspace.getConfiguration('editor').update('experimental.preferTreeSitter', ["typescript", "ini"], ConfigurationTarget.Global); }); suiteTeardown(async function () { await workspace.getConfiguration('editor').update('experimental.preferTreeSitter', originalSettingValue, ConfigurationTarget.Global); diff --git a/extensions/vscode-colorize-tests/test/colorize-fixtures/test.ini b/extensions/vscode-colorize-tests/test/colorize-fixtures/test.ini index 1461ad45d9e..079f2b5f6a9 100644 --- a/extensions/vscode-colorize-tests/test/colorize-fixtures/test.ini +++ b/extensions/vscode-colorize-tests/test/colorize-fixtures/test.ini @@ -7,4 +7,7 @@ organization=Acme Widgets Inc. ; use IP address in case network name resolution is not working server=192.0.2.62 port=143 -file="payroll.dat" \ No newline at end of file +file="payroll.dat" +user=u#ser +test=te;st +quote=qu'ote diff --git a/extensions/vscode-colorize-tests/test/colorize-results/test_ini.json b/extensions/vscode-colorize-tests/test/colorize-results/test_ini.json index c4babf18a6a..418312f5e07 100644 --- a/extensions/vscode-colorize-tests/test/colorize-results/test_ini.json +++ b/extensions/vscode-colorize-tests/test/colorize-results/test_ini.json @@ -376,5 +376,215 @@ "hc_light": "string: #0F4A85", "light_modern": "string: #A31515" } + }, + { + "c": "user", + "t": "source.ini keyword.other.definition.ini", + "r": { + "dark_plus": "keyword: #569CD6", + "light_plus": "keyword: #0000FF", + "dark_vs": "keyword: #569CD6", + "light_vs": "keyword: #0000FF", + "hc_black": "keyword: #569CD6", + "dark_modern": "keyword: #569CD6", + "hc_light": "keyword: #0F4A85", + "light_modern": "keyword: #0000FF" + } + }, + { + "c": "=", + "t": "source.ini punctuation.separator.key-value.ini", + "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": "u", + "t": "source.ini", + "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.ini comment.line.number-sign.ini punctuation.definition.comment.ini", + "r": { + "dark_plus": "comment: #6A9955", + "light_plus": "comment: #008000", + "dark_vs": "comment: #6A9955", + "light_vs": "comment: #008000", + "hc_black": "comment: #7CA668", + "dark_modern": "comment: #6A9955", + "hc_light": "comment: #515151", + "light_modern": "comment: #008000" + } + }, + { + "c": "ser", + "t": "source.ini comment.line.number-sign.ini", + "r": { + "dark_plus": "comment: #6A9955", + "light_plus": "comment: #008000", + "dark_vs": "comment: #6A9955", + "light_vs": "comment: #008000", + "hc_black": "comment: #7CA668", + "dark_modern": "comment: #6A9955", + "hc_light": "comment: #515151", + "light_modern": "comment: #008000" + } + }, + { + "c": "test", + "t": "source.ini keyword.other.definition.ini", + "r": { + "dark_plus": "keyword: #569CD6", + "light_plus": "keyword: #0000FF", + "dark_vs": "keyword: #569CD6", + "light_vs": "keyword: #0000FF", + "hc_black": "keyword: #569CD6", + "dark_modern": "keyword: #569CD6", + "hc_light": "keyword: #0F4A85", + "light_modern": "keyword: #0000FF" + } + }, + { + "c": "=", + "t": "source.ini punctuation.separator.key-value.ini", + "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": "te", + "t": "source.ini", + "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.ini comment.line.semicolon.ini punctuation.definition.comment.ini", + "r": { + "dark_plus": "comment: #6A9955", + "light_plus": "comment: #008000", + "dark_vs": "comment: #6A9955", + "light_vs": "comment: #008000", + "hc_black": "comment: #7CA668", + "dark_modern": "comment: #6A9955", + "hc_light": "comment: #515151", + "light_modern": "comment: #008000" + } + }, + { + "c": "st", + "t": "source.ini comment.line.semicolon.ini", + "r": { + "dark_plus": "comment: #6A9955", + "light_plus": "comment: #008000", + "dark_vs": "comment: #6A9955", + "light_vs": "comment: #008000", + "hc_black": "comment: #7CA668", + "dark_modern": "comment: #6A9955", + "hc_light": "comment: #515151", + "light_modern": "comment: #008000" + } + }, + { + "c": "quote", + "t": "source.ini keyword.other.definition.ini", + "r": { + "dark_plus": "keyword: #569CD6", + "light_plus": "keyword: #0000FF", + "dark_vs": "keyword: #569CD6", + "light_vs": "keyword: #0000FF", + "hc_black": "keyword: #569CD6", + "dark_modern": "keyword: #569CD6", + "hc_light": "keyword: #0F4A85", + "light_modern": "keyword: #0000FF" + } + }, + { + "c": "=", + "t": "source.ini punctuation.separator.key-value.ini", + "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": "qu", + "t": "source.ini", + "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.ini string.quoted.single.ini punctuation.definition.string.begin.ini", + "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": "ote", + "t": "source.ini string.quoted.single.ini", + "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" + } } ] \ No newline at end of file diff --git a/extensions/vscode-colorize-tests/test/colorize-tree-sitter-results/test_ini.json b/extensions/vscode-colorize-tests/test/colorize-tree-sitter-results/test_ini.json index 0637a088a01..c6d521cdcb6 100644 --- a/extensions/vscode-colorize-tests/test/colorize-tree-sitter-results/test_ini.json +++ b/extensions/vscode-colorize-tests/test/colorize-tree-sitter-results/test_ini.json @@ -1 +1,450 @@ -[] \ No newline at end of file +[ + { + "c": " last modified 1 April 2001 by John Doe", + "t": "comment.line.semicolon", + "r": { + "dark_plus": "comment: #6A9955", + "light_plus": "comment: #008000", + "dark_vs": "comment: #6A9955", + "light_vs": "comment: #008000", + "hc_black": "comment: #7CA668", + "dark_modern": "comment: #6A9955", + "hc_light": "comment: #515151", + "light_modern": "comment: #008000" + } + }, + { + "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": "owner", + "t": "entity.name.section.group-title", + "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": "name", + "t": "keyword.other.definition", + "r": { + "dark_plus": "keyword: #569CD6", + "light_plus": "keyword: #0000FF", + "dark_vs": "keyword: #569CD6", + "light_vs": "keyword: #0000FF", + "hc_black": "keyword: #569CD6", + "dark_modern": "keyword: #569CD6", + "hc_light": "keyword: #0F4A85", + "light_modern": "keyword: #0000FF" + } + }, + { + "c": "=", + "t": "punctuation.separator.key-value", + "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": "John Doe", + "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": "organization", + "t": "keyword.other.definition", + "r": { + "dark_plus": "keyword: #569CD6", + "light_plus": "keyword: #0000FF", + "dark_vs": "keyword: #569CD6", + "light_vs": "keyword: #0000FF", + "hc_black": "keyword: #569CD6", + "dark_modern": "keyword: #569CD6", + "hc_light": "keyword: #0F4A85", + "light_modern": "keyword: #0000FF" + } + }, + { + "c": "=", + "t": "punctuation.separator.key-value", + "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": "Acme Widgets Inc.", + "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": "", + "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": "database", + "t": "entity.name.section.group-title", + "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": " use IP address in case network name resolution is not working", + "t": "comment.line.semicolon", + "r": { + "dark_plus": "comment: #6A9955", + "light_plus": "comment: #008000", + "dark_vs": "comment: #6A9955", + "light_vs": "comment: #008000", + "hc_black": "comment: #7CA668", + "dark_modern": "comment: #6A9955", + "hc_light": "comment: #515151", + "light_modern": "comment: #008000" + } + }, + { + "c": "server", + "t": "keyword.other.definition", + "r": { + "dark_plus": "keyword: #569CD6", + "light_plus": "keyword: #0000FF", + "dark_vs": "keyword: #569CD6", + "light_vs": "keyword: #0000FF", + "hc_black": "keyword: #569CD6", + "dark_modern": "keyword: #569CD6", + "hc_light": "keyword: #0F4A85", + "light_modern": "keyword: #0000FF" + } + }, + { + "c": "=", + "t": "punctuation.separator.key-value", + "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": "192.0.2.62", + "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": "port", + "t": "keyword.other.definition", + "r": { + "dark_plus": "keyword: #569CD6", + "light_plus": "keyword: #0000FF", + "dark_vs": "keyword: #569CD6", + "light_vs": "keyword: #0000FF", + "hc_black": "keyword: #569CD6", + "dark_modern": "keyword: #569CD6", + "hc_light": "keyword: #0F4A85", + "light_modern": "keyword: #0000FF" + } + }, + { + "c": "=", + "t": "punctuation.separator.key-value", + "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": "143", + "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": "file", + "t": "keyword.other.definition", + "r": { + "dark_plus": "keyword: #569CD6", + "light_plus": "keyword: #0000FF", + "dark_vs": "keyword: #569CD6", + "light_vs": "keyword: #0000FF", + "hc_black": "keyword: #569CD6", + "dark_modern": "keyword: #569CD6", + "hc_light": "keyword: #0F4A85", + "light_modern": "keyword: #0000FF" + } + }, + { + "c": "=", + "t": "punctuation.separator.key-value", + "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": "\"payroll.dat\"", + "t": "string.quoted.double", + "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": "user", + "t": "keyword.other.definition", + "r": { + "dark_plus": "keyword: #569CD6", + "light_plus": "keyword: #0000FF", + "dark_vs": "keyword: #569CD6", + "light_vs": "keyword: #0000FF", + "hc_black": "keyword: #569CD6", + "dark_modern": "keyword: #569CD6", + "hc_light": "keyword: #0F4A85", + "light_modern": "keyword: #0000FF" + } + }, + { + "c": "=", + "t": "punctuation.separator.key-value", + "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": "u#ser", + "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": "test", + "t": "keyword.other.definition", + "r": { + "dark_plus": "keyword: #569CD6", + "light_plus": "keyword: #0000FF", + "dark_vs": "keyword: #569CD6", + "light_vs": "keyword: #0000FF", + "hc_black": "keyword: #569CD6", + "dark_modern": "keyword: #569CD6", + "hc_light": "keyword: #0F4A85", + "light_modern": "keyword: #0000FF" + } + }, + { + "c": "=", + "t": "punctuation.separator.key-value", + "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": "te;st", + "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": "quote", + "t": "keyword.other.definition", + "r": { + "dark_plus": "keyword: #569CD6", + "light_plus": "keyword: #0000FF", + "dark_vs": "keyword: #569CD6", + "light_vs": "keyword: #0000FF", + "hc_black": "keyword: #569CD6", + "dark_modern": "keyword: #569CD6", + "hc_light": "keyword: #0F4A85", + "light_modern": "keyword: #0000FF" + } + }, + { + "c": "=", + "t": "punctuation.separator.key-value", + "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": "qu'ote", + "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" + } + } +] diff --git a/package-lock.json b/package-lock.json index 4341d5c7dc7..d8bc9b89ab2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,7 +22,7 @@ "@vscode/spdlog": "^0.15.0", "@vscode/sqlite3": "5.1.8-vscode", "@vscode/sudo-prompt": "9.3.1", - "@vscode/tree-sitter-wasm": "^0.1.1", + "@vscode/tree-sitter-wasm": "^0.1.2", "@vscode/vscode-languagedetection": "1.0.21", "@vscode/windows-mutex": "^0.5.0", "@vscode/windows-process-tree": "^0.6.0", @@ -3157,9 +3157,9 @@ } }, "node_modules/@vscode/tree-sitter-wasm": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/@vscode/tree-sitter-wasm/-/tree-sitter-wasm-0.1.1.tgz", - "integrity": "sha512-2KHGbX2krHP/LyfpDB6QnSAqyqIL7N2Md7KTMuoqq8+GhUzrgXwIClhpm7lqL/isNTYVzsEubR7YI6f2YfAqqQ==", + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/@vscode/tree-sitter-wasm/-/tree-sitter-wasm-0.1.2.tgz", + "integrity": "sha512-nXFrHey/TdhN2v15Qurs+trTSQB2ad0O8I8R7RMAjvrZi9qXAE+H+l9ZHHsA14fjZxKIyGg+nFmNpdEAuQALpw==", "license": "MIT" }, "node_modules/@vscode/v8-heap-parser": { diff --git a/package.json b/package.json index 0e69539c325..9ccac245c25 100644 --- a/package.json +++ b/package.json @@ -80,7 +80,7 @@ "@vscode/spdlog": "^0.15.0", "@vscode/sqlite3": "5.1.8-vscode", "@vscode/sudo-prompt": "9.3.1", - "@vscode/tree-sitter-wasm": "^0.1.1", + "@vscode/tree-sitter-wasm": "^0.1.2", "@vscode/vscode-languagedetection": "1.0.21", "@vscode/windows-mutex": "^0.5.0", "@vscode/windows-process-tree": "^0.6.0", diff --git a/remote/package-lock.json b/remote/package-lock.json index 23040a369a8..915e2f727f9 100644 --- a/remote/package-lock.json +++ b/remote/package-lock.json @@ -16,7 +16,7 @@ "@vscode/proxy-agent": "^0.31.0", "@vscode/ripgrep": "^1.15.10", "@vscode/spdlog": "^0.15.0", - "@vscode/tree-sitter-wasm": "^0.1.1", + "@vscode/tree-sitter-wasm": "^0.1.2", "@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.1", - "resolved": "https://registry.npmjs.org/@vscode/tree-sitter-wasm/-/tree-sitter-wasm-0.1.1.tgz", - "integrity": "sha512-2KHGbX2krHP/LyfpDB6QnSAqyqIL7N2Md7KTMuoqq8+GhUzrgXwIClhpm7lqL/isNTYVzsEubR7YI6f2YfAqqQ==", + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/@vscode/tree-sitter-wasm/-/tree-sitter-wasm-0.1.2.tgz", + "integrity": "sha512-nXFrHey/TdhN2v15Qurs+trTSQB2ad0O8I8R7RMAjvrZi9qXAE+H+l9ZHHsA14fjZxKIyGg+nFmNpdEAuQALpw==", "license": "MIT" }, "node_modules/@vscode/vscode-languagedetection": { diff --git a/remote/package.json b/remote/package.json index 1401dc44f84..9e875c0ba42 100644 --- a/remote/package.json +++ b/remote/package.json @@ -11,7 +11,7 @@ "@vscode/proxy-agent": "^0.31.0", "@vscode/ripgrep": "^1.15.10", "@vscode/spdlog": "^0.15.0", - "@vscode/tree-sitter-wasm": "^0.1.1", + "@vscode/tree-sitter-wasm": "^0.1.2", "@vscode/vscode-languagedetection": "1.0.21", "@vscode/windows-process-tree": "^0.6.0", "@vscode/windows-registry": "^1.1.0", diff --git a/remote/web/package-lock.json b/remote/web/package-lock.json index e0fafc8881b..60427702f86 100644 --- a/remote/web/package-lock.json +++ b/remote/web/package-lock.json @@ -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.1", + "@vscode/tree-sitter-wasm": "^0.1.2", "@vscode/vscode-languagedetection": "1.0.21", "@xterm/addon-clipboard": "^0.2.0-beta.80", "@xterm/addon-image": "^0.9.0-beta.97", @@ -76,9 +76,9 @@ "integrity": "sha512-bRRFxLfg5dtAyl5XyiVWz/ZBPahpOpPrNYnnHpOpUZvam4tKH35wdhP4Kj6PbM0+KdliOsPzbGWpkxcdpNB/sg==" }, "node_modules/@vscode/tree-sitter-wasm": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/@vscode/tree-sitter-wasm/-/tree-sitter-wasm-0.1.1.tgz", - "integrity": "sha512-2KHGbX2krHP/LyfpDB6QnSAqyqIL7N2Md7KTMuoqq8+GhUzrgXwIClhpm7lqL/isNTYVzsEubR7YI6f2YfAqqQ==", + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/@vscode/tree-sitter-wasm/-/tree-sitter-wasm-0.1.2.tgz", + "integrity": "sha512-nXFrHey/TdhN2v15Qurs+trTSQB2ad0O8I8R7RMAjvrZi9qXAE+H+l9ZHHsA14fjZxKIyGg+nFmNpdEAuQALpw==", "license": "MIT" }, "node_modules/@vscode/vscode-languagedetection": { diff --git a/remote/web/package.json b/remote/web/package.json index fc12486c248..b10d5635d21 100644 --- a/remote/web/package.json +++ b/remote/web/package.json @@ -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.1", + "@vscode/tree-sitter-wasm": "^0.1.2", "@vscode/vscode-languagedetection": "1.0.21", "@xterm/addon-clipboard": "^0.2.0-beta.80", "@xterm/addon-image": "^0.9.0-beta.97", diff --git a/src/vs/editor/common/config/editorConfigurationSchema.ts b/src/vs/editor/common/config/editorConfigurationSchema.ts index 436daa7e04c..cae3fb2bb94 100644 --- a/src/vs/editor/common/config/editorConfigurationSchema.ts +++ b/src/vs/editor/common/config/editorConfigurationSchema.ts @@ -119,9 +119,9 @@ const editorConfiguration: IConfigurationNode = { type: 'array', items: { type: 'string', - enum: ['typescript'] + enum: ['typescript', 'ini'] }, - default: [], + default: ['ini'], markdownDescription: nls.localize('editor.experimental.preferTreeSitter', "Controls whether tree sitter parsing should be turned on for specific languages. This will take precedence over `editor.experimental.treeSitterTelemetry` for the specified languages."), tags: ['experimental'] }, diff --git a/src/vs/editor/common/languages/highlights/ini.scm b/src/vs/editor/common/languages/highlights/ini.scm new file mode 100644 index 00000000000..2d68e7c76dd --- /dev/null +++ b/src/vs/editor/common/languages/highlights/ini.scm @@ -0,0 +1,12 @@ +; Order matters! Place lower precedence first. + +(section_name (text) @entity.name.section.group-title) + +(setting_name) @keyword.other.definition + +(setting ("=") @punctuation.separator.key-value) + +(comment) @comment.line.semicolon + +((setting_value) @string.quoted.double + (#match? @string.quoted.double "^\".*\"")) diff --git a/src/vs/editor/common/services/treeSitter/treeSitterParserService.ts b/src/vs/editor/common/services/treeSitter/treeSitterParserService.ts index 592d674b1e0..c54327aa420 100644 --- a/src/vs/editor/common/services/treeSitter/treeSitterParserService.ts +++ b/src/vs/editor/common/services/treeSitter/treeSitterParserService.ts @@ -660,12 +660,18 @@ export class TreeSitterTextModelService extends Disposable implements ITreeSitte if (setting.length === 0) { hasLanguages = false; } + + const handleLanguage = (languageId: string) => { + if (setting.includes(languageId)) { + this._addGrammar(languageId, `tree-sitter-${languageId}`); + } else { + this._removeGrammar(languageId); + } + }; + // Eventually, this should actually use an extension point to add tree sitter grammars, but for now they are hard coded in core - if (setting.includes('typescript')) { - this._addGrammar('typescript', 'tree-sitter-typescript'); - } else { - this._removeGrammar('typescript'); - } + handleLanguage('typescript'); + handleLanguage('ini'); return this._initParser(hasLanguages); } diff --git a/src/vs/workbench/services/treeSitter/browser/treeSitterTokenizationFeature.ts b/src/vs/workbench/services/treeSitter/browser/treeSitterTokenizationFeature.ts index 23294d665b3..6ed4ed3223a 100644 --- a/src/vs/workbench/services/treeSitter/browser/treeSitterTokenizationFeature.ts +++ b/src/vs/workbench/services/treeSitter/browser/treeSitterTokenizationFeature.ts @@ -28,7 +28,7 @@ import { setTimeout0 } from '../../../../base/common/platform.js'; import { findLikelyRelevantLines } from '../../../../editor/common/model/textModelTokens.js'; import { TreeSitterCodeEditors } from './treeSitterCodeEditors.js'; -const ALLOWED_SUPPORT = ['typescript']; +const ALLOWED_SUPPORT = ['typescript', 'ini']; type TreeSitterQueries = string; export const ITreeSitterTokenizationFeature = createDecorator('treeSitterTokenizationFeature'); @@ -126,6 +126,9 @@ export class TreeSitterTokenizationSupport extends Disposable implements ITreeSi this._parseAndTokenizeViewPort(e.model, e.ranges); })); this._register(this._treeSitterService.onDidUpdateTree((e) => { + if (e.textModel.getLanguageId() !== this._languageId) { + return; + } if (this._tokenizationStoreService.hasTokens(e.textModel)) { // Mark the range for refresh immediately for (const range of e.ranges) {