Unnamed repository; edit this file 'description' to name the repository.
Add TQL language (#15394)
Aljaž Mur Eržen 4 months ago
parent 26b1377 · commit e2932b4
-rw-r--r--book/src/generated/lang-support.md1
-rw-r--r--languages.toml12
-rw-r--r--runtime/queries/tql/highlights.scm92
-rw-r--r--runtime/queries/tql/indents.scm16
4 files changed, 121 insertions, 0 deletions
diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md
index 493db5b7..e417db01 100644
--- a/book/src/generated/lang-support.md
+++ b/book/src/generated/lang-support.md
@@ -296,6 +296,7 @@
| tlaplus | ✓ | | | | | |
| todotxt | ✓ | | | | | |
| toml | ✓ | ✓ | | ✓ | ✓ | `taplo`, `tombi` |
+| tql | ✓ | | ✓ | | | |
| tsq | ✓ | | | | ✓ | `ts_query_ls` |
| tsx | ✓ | ✓ | ✓ | ✓ | ✓ | `typescript-language-server` |
| twig | ✓ | | | | | |
diff --git a/languages.toml b/languages.toml
index 74908c7d..45347221 100644
--- a/languages.toml
+++ b/languages.toml
@@ -5412,3 +5412,15 @@ indent = { tab-width = 4, unit = " " }
[[grammar]]
name = "ptx"
source = { git = "https://codeberg.org/jer-gremlin/tree-sitter-ptx", rev = "3dfa6758d4c15832d051f933101992b9e01d6611" }
+
+[[language]]
+name = "tql"
+scope = "source.tql"
+file-types = [ "tql" ]
+injection-regex = "tql"
+indent = {tab-width = 2, unit = " "}
+comment-token = "//"
+
+[[grammar]]
+name = "tql"
+source = { git = "https://github.com/tenzir/tree-sitter-tql", rev = "d3b3b2699bc09fd0c63e2c13f15f6e474665c62e" }
diff --git a/runtime/queries/tql/highlights.scm b/runtime/queries/tql/highlights.scm
new file mode 100644
index 00000000..42e4c6c5
--- /dev/null
+++ b/runtime/queries/tql/highlights.scm
@@ -0,0 +1,92 @@
+;; Upstream: https://github.com/tenzir/tree-sitter-tql/blob/main/queries/tql/highlights.scm
+
+"move" @keyword
+
+[
+ "let"
+] @keyword.storage
+
+[
+ "and"
+ "or"
+ "not"
+ "in"
+] @keyword.operator
+
+[
+ "if"
+ "else"
+ "match"
+] @keyword.control.conditional
+
+"this" @variable.builtin
+
+[
+ "."
+ ":"
+] @punctuation.delimiter
+
+[
+ "["
+ "]"
+ "{"
+ "}"
+] @punctuation.bracket
+
+[
+ "?"
+ "..."
+ "+"
+ "-"
+ "*"
+ "/"
+ "="
+ "=>"
+ "|"
+ "::"
+ "=="
+ "!="
+ ">"
+ ">="
+ "<"
+ "<="
+] @operator
+
+[
+ "("
+ ")"
+] @punctuation.bracket
+
+[
+ ","
+] @punctuation.delimiter
+
+"_" @variable.builtin
+
+"null" @constant.builtin
+
+[
+ "true"
+ "false"
+] @constant.builtin.boolean
+
+(dollar_var) @variable
+(meta_selector) @attribute
+(number) @constant.numeric
+(string) @string
+(format_expr) @string
+(ip) @constant
+(subnet) @constant
+(time) @number
+(duration) @constant.numeric
+(frontmatter_open) @comment
+(frontmatter_close) @comment
+(comment) @comment
+
+(invocation
+ operator: (entity) @function.call)
+(call_expression
+ (entity) @function.call)
+(call_expression
+ method: (entity) @function.method)
+(identifier) @variable
diff --git a/runtime/queries/tql/indents.scm b/runtime/queries/tql/indents.scm
new file mode 100644
index 00000000..3d41fd51
--- /dev/null
+++ b/runtime/queries/tql/indents.scm
@@ -0,0 +1,16 @@
+;; Upstream: https://github.com/tenzir/tree-sitter-tql/blob/main/queries/tql/indents.scm
+
+[
+ (then_block)
+ (else_block)
+ (pipeline_block)
+ (match_statement)
+ (match_arm)
+ (list)
+ (record)
+] @indent
+
+[
+ "}"
+ "]"
+] @outdent