From 7761e3b6f816228b1a762e5dd32f487c9708eeee Mon Sep 17 00:00:00 2001 From: Nikita Revenco <154856872+NikitaRevenco@users.noreply.github.com> Date: Tue, 4 Feb 2025 17:58:12 +0000 Subject: [PATCH 1/3] feat: Language support for Tree Sitter Test files --- languages.toml | 9 +++++++++ runtime/queries/test/highlights.scm | 21 +++++++++++++++++++++ runtime/queries/test/injections.scm | 15 +++++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 runtime/queries/test/highlights.scm create mode 100644 runtime/queries/test/injections.scm diff --git a/languages.toml b/languages.toml index a3cb0cfa1..775cb2c8f 100644 --- a/languages.toml +++ b/languages.toml @@ -4111,3 +4111,12 @@ indent = { tab-width = 2, unit = " " } [[grammar]] name = "ghostty" source = { git = "https://github.com/bezhermoso/tree-sitter-ghostty" , rev = "8438a93b44367e962b2ea3a3b6511885bebd196a" } + +[[language]] +name = "test" +scope = "source.test" +file-types = [{ glob = "test/corpus/*.txt" }] + +[[grammar]] +name = "test" +source = { git = "https://github.com/tree-sitter-grammars/tree-sitter-test", rev = "93746e2e387ae757d21088ab0ab5657efffb973e" } diff --git a/runtime/queries/test/highlights.scm b/runtime/queries/test/highlights.scm new file mode 100644 index 000000000..b5ff8edf9 --- /dev/null +++ b/runtime/queries/test/highlights.scm @@ -0,0 +1,21 @@ +(name) @markup.heading.1 + +[ + ":skip" + ":error" + ":fail-fast" + ":language" + ":platform" +] @attribute + +(attribute + language: (parameter) @string) + +(attribute + platform: (parameter) @constant.builtin) + +[ + (separator) + ")" + "(" +] @punctuation diff --git a/runtime/queries/test/injections.scm b/runtime/queries/test/injections.scm new file mode 100644 index 000000000..685890a05 --- /dev/null +++ b/runtime/queries/test/injections.scm @@ -0,0 +1,15 @@ +(test + (header + (name) + (attributes + . ; skip over non-language attributes + (attribute + !language)* + . ; select only the first language attribute + (attribute + language: (parameter) @injection.language))) + (input) @injection.content) + +((test + (output) @injection.content) + (#set! injection.language "tsq")) From 751e004b717ad94414a58df7f48617e970afbbe9 Mon Sep 17 00:00:00 2001 From: Nikita Revenco <154856872+NikitaRevenco@users.noreply.github.com> Date: Tue, 4 Feb 2025 18:15:21 +0000 Subject: [PATCH 2/3] feat: use a general (attribute) --- runtime/queries/test/highlights.scm | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/runtime/queries/test/highlights.scm b/runtime/queries/test/highlights.scm index b5ff8edf9..68f099613 100644 --- a/runtime/queries/test/highlights.scm +++ b/runtime/queries/test/highlights.scm @@ -1,12 +1,6 @@ (name) @markup.heading.1 -[ - ":skip" - ":error" - ":fail-fast" - ":language" - ":platform" -] @attribute +(attribute) @attribute (attribute language: (parameter) @string) From e3353abb99c0d5f9154e13e7c89165284949ba4e Mon Sep 17 00:00:00 2001 From: Nikita Revenco <154856872+NikitaRevenco@users.noreply.github.com> Date: Thu, 6 Feb 2025 13:38:05 +0000 Subject: [PATCH 3/3] docs: document tree-sitter-test support --- book/src/generated/lang-support.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index 906548e65..be5089cc7 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -215,6 +215,8 @@ | tcl | ✓ | | ✓ | | | teal | ✓ | | | `teal-language-server` | | templ | ✓ | | | `templ` | +| tera | ✓ | | | | +| test | ✓ | | | | | textproto | ✓ | ✓ | ✓ | | | tfvars | ✓ | | ✓ | `terraform-ls` | | thrift | ✓ | | | |