@tenzir/codemirror-lang-tql 0.5.0 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -174,13 +174,18 @@ The highlight query's captures become these tags (`tqlCaptureTags`):
174
174
  | `attribute` | `tags.attributeName` |
175
175
  | `function` | `tags.function(tags.variableName)` |
176
176
  | `function.call` | `tags.function(tags.variableName)` |
177
+ | `function.operator` | `tags.function(tags.variableName)` |
177
178
  | `function.method` | `tags.function(tags.propertyName)` |
178
179
  | `string` | `tags.string` |
179
180
  | `string.escape` | `tags.escape` |
180
181
  | `string.special` | `tags.special(tags.string)` |
181
182
  | `number` | `tags.number` |
183
+ | `number.time` | `tags.number` |
184
+ | `number.duration` | `tags.number` |
182
185
  | `boolean` | `tags.bool` |
183
186
  | `constant` | `tags.constant(tags.name)` |
187
+ | `constant.ip` | `tags.constant(tags.name)` |
188
+ | `constant.subnet` | `tags.constant(tags.name)` |
184
189
  | `constant.builtin` | `tags.null` |
185
190
  | `variable` | `tags.variableName` |
186
191
  | `variable.builtin` | `tags.special(tags.variableName)` |
@@ -194,7 +199,11 @@ The highlight query's captures become these tags (`tqlCaptureTags`):
194
199
  | `punctuation.delimiter` | `tags.separator` |
195
200
 
196
201
  A capture without an entry takes the tag of the nearest capture it refines, so
197
- `function.builtin` would be a `function`. Captures starting with `_` never
202
+ `function.builtin` would be a `function`. Pipeline operators (`function.operator`),
203
+ times and durations (`number.time`, `number.duration`), and IP addresses and
204
+ subnets (`constant.ip`, `constant.subnet`) share the tags of the captures they
205
+ refine, so standard highlight styles color them as before, while
206
+ `tqlHighlighter` can color them apart by capture name. Captures starting with `_` never
198
207
  color.
199
208
 
200
209
  Captures follow tree-sitter's rules: an inner node's capture wins over the
@@ -226,9 +235,10 @@ const extensions = [
226
235
 
227
236
  ## Editing
228
237
 
229
- - **Quote pairing:** `closeBrackets()` pairs `(`, `[`, `{`, `"`, and `'`, also
230
- after the string prefixes `f` and `b`, and the raw prefixes `r` and `br`
231
- with up to 8 `#`. tree-sitter-tql parses a string without its closing quote
238
+ - **Quote pairing:** `closeBrackets()` pairs `(`, `[`, `{`, and `"`, also
239
+ after the format prefix `f` and the byte and raw prefixes `b`, `r`, and
240
+ `br` with up to 8 `#`. TQL has no single-quoted strings, so `'` doesn't
241
+ pair. tree-sitter-tql parses a string without its closing quote
232
242
  as a string that runs to the end of the document, as TQL's strings may span
233
243
  lines, so typing the closing quote doesn't insert a pair. The same goes for a
234
244
  `/*` comment without its `*/`.
package/dist/index.cjs CHANGED
@@ -8,7 +8,7 @@ var brackets = ";; Auto-generated by tenzir/tree-sitter-tql/scripts/generate-bra
8
8
 
9
9
  var folds = ";; Auto-generated by tenzir/tree-sitter-tql/scripts/generate-folds.mjs. DO NOT EDIT.\n\n[\n (then_block)\n (else_block)\n (pipeline_block)\n (pipeline_expression)\n (match_statement)\n (match_arm)\n (list)\n (record)\n (frontmatter)\n] @fold\n";
10
10
 
11
- var highlights = ";; Auto-generated by tenzir/tree-sitter-tql/scripts/generate-highlights.mjs. DO NOT EDIT.\n\n[\n \"let\"\n \"if\"\n \"else\"\n \"match\"\n \"and\"\n \"or\"\n \"not\"\n \"move\"\n \"in\"\n \"this\"\n \"?\"\n \".\"\n \"...\"\n \"[\"\n \"]\"\n \"{\"\n \"}\"\n \":\"\n] @keyword\n\n[\n \"+\"\n \"-\"\n \"*\"\n \"/\"\n] @keyword\n\n\"_\" @variable.builtin\n\n\"null\" @constant.builtin\n\n[\n \"true\"\n \"false\"\n] @boolean\n\n(dollar_var) @variable.builtin\n(global_sigil) @keyword\n(metadata_sigil) @keyword\n(meta_selector) @attribute\n(number) @number\n(string) @string\n(format_expr) @string\n(ip) @constant\n(subnet) @constant\n(time) @number\n(duration) @number\n(frontmatter_open) @comment\n(frontmatter_close) @comment\n(comment) @comment\n\n(invocation\n operator: (entity) @function.call)\n(call_expression\n (entity) @function.call)\n(call_expression\n method: (entity) @function.method)\n((identifier) @variable.builtin (#match? @variable.builtin \"^\\$[A-Za-z_]\\w*$\"))\n\n[\n \"(\"\n \")\"\n] @punctuation.bracket\n\n[\n \",\"\n] @punctuation.delimiter\n\n[\n \"=\"\n \"=>\"\n \"|\"\n \"..\"\n \"::\"\n \"==\"\n \"!=\"\n \">\"\n \">=\"\n \"<\"\n \"<=\"\n] @operator\n";
11
+ var highlights = ";; Auto-generated by tenzir/tree-sitter-tql/scripts/generate-highlights.mjs. DO NOT EDIT.\n\n[\n \"let\"\n \"if\"\n \"else\"\n \"match\"\n \"and\"\n \"or\"\n \"not\"\n \"move\"\n \"in\"\n \"this\"\n \"?\"\n \".\"\n \"...\"\n \"[\"\n \"]\"\n \"{\"\n \"}\"\n \":\"\n] @keyword\n\n[\n \"+\"\n \"-\"\n \"*\"\n \"/\"\n] @keyword\n\n\"_\" @variable.builtin\n\n\"null\" @constant.builtin\n\n[\n \"true\"\n \"false\"\n] @boolean\n\n(dollar_var) @variable.builtin\n(global_sigil) @keyword\n(metadata_sigil) @keyword\n(meta_selector) @attribute\n(number) @number\n(string) @string\n(format_expr) @string\n(ip) @constant.ip\n(subnet) @constant.subnet\n(time) @number.time\n(duration) @number.duration\n(frontmatter_open) @comment\n(frontmatter_close) @comment\n(comment) @comment\n\n(invocation\n operator: (entity) @function.operator)\n(call_expression\n (entity) @function.call)\n(call_expression\n method: (entity) @function.method)\n((identifier) @variable.builtin (#match? @variable.builtin \"^\\$[A-Za-z_]\\w*$\"))\n\n[\n \"(\"\n \")\"\n] @punctuation.bracket\n\n[\n \",\"\n] @punctuation.delimiter\n\n[\n \"=\"\n \"=>\"\n \"|\"\n \"..\"\n \"::\"\n \"==\"\n \"!=\"\n \">\"\n \">=\"\n \"<\"\n \"<=\"\n] @operator\n";
12
12
 
13
13
  var indents = ";; Auto-generated by tenzir/tree-sitter-tql/scripts/generate-indents.mjs. DO NOT EDIT.\n\n[\n (then_block)\n (else_block)\n (pipeline_block)\n (pipeline_expression)\n (match_statement)\n (match_arm)\n (list)\n (record)\n] @indent\n\n[\n \"}\"\n \"]\"\n] @outdent\n\n[\n (string)\n (format_text)\n (comment)\n (frontmatter_body)\n] @indent.auto\n";
14
14
 
@@ -27,13 +27,18 @@ const tqlCaptureTags = {
27
27
  attribute: highlight.tags.attributeName,
28
28
  function: highlight.tags.function(highlight.tags.variableName),
29
29
  "function.call": highlight.tags.function(highlight.tags.variableName),
30
+ "function.operator": highlight.tags.function(highlight.tags.variableName),
30
31
  "function.method": highlight.tags.function(highlight.tags.propertyName),
31
32
  string: highlight.tags.string,
32
33
  "string.escape": highlight.tags.escape,
33
34
  "string.special": highlight.tags.special(highlight.tags.string),
34
35
  number: highlight.tags.number,
36
+ "number.time": highlight.tags.number,
37
+ "number.duration": highlight.tags.number,
35
38
  boolean: highlight.tags.bool,
36
39
  constant: highlight.tags.constant(highlight.tags.name),
40
+ "constant.ip": highlight.tags.constant(highlight.tags.name),
41
+ "constant.subnet": highlight.tags.constant(highlight.tags.name),
37
42
  "constant.builtin": highlight.tags.null,
38
43
  variable: highlight.tags.variableName,
39
44
  "variable.builtin": highlight.tags.special(highlight.tags.variableName),
@@ -570,7 +575,7 @@ class TqlParse {
570
575
 
571
576
  /** The queries of tree-sitter-tql that `tql` uses unless given others. */
572
577
  const tqlQueries = { highlights, indents, folds, brackets, injections };
573
- const rawPrefixes = ["r", "br"].flatMap((prefix) => {
578
+ const hashedPrefixes = ["b", "r", "br"].flatMap((prefix) => {
574
579
  return Array.from({ length: 9 }, (_, hashes) => prefix + "#".repeat(hashes));
575
580
  });
576
581
  /**
@@ -591,8 +596,10 @@ function tql(treeSitter, options = {}) {
591
596
  const data = language.defineLanguageFacet({
592
597
  commentTokens: { line: "//", block: { open: "/*", close: "*/" } },
593
598
  closeBrackets: {
594
- // Raw strings take up to 8 hashes, as in tree-sitter-tql.
595
- stringPrefixes: ["f", "b", ...rawPrefixes],
599
+ // TQL has no single-quoted strings.
600
+ brackets: ["(", "[", "{", '"'],
601
+ // Byte and raw strings take up to 8 hashes, as in tree-sitter-tql.
602
+ stringPrefixes: ["f", ...hashedPrefixes],
596
603
  },
597
604
  indentOnInput: /^\s*[}\]]$/,
598
605
  });
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ var brackets = ";; Auto-generated by tenzir/tree-sitter-tql/scripts/generate-bra
6
6
 
7
7
  var folds = ";; Auto-generated by tenzir/tree-sitter-tql/scripts/generate-folds.mjs. DO NOT EDIT.\n\n[\n (then_block)\n (else_block)\n (pipeline_block)\n (pipeline_expression)\n (match_statement)\n (match_arm)\n (list)\n (record)\n (frontmatter)\n] @fold\n";
8
8
 
9
- var highlights = ";; Auto-generated by tenzir/tree-sitter-tql/scripts/generate-highlights.mjs. DO NOT EDIT.\n\n[\n \"let\"\n \"if\"\n \"else\"\n \"match\"\n \"and\"\n \"or\"\n \"not\"\n \"move\"\n \"in\"\n \"this\"\n \"?\"\n \".\"\n \"...\"\n \"[\"\n \"]\"\n \"{\"\n \"}\"\n \":\"\n] @keyword\n\n[\n \"+\"\n \"-\"\n \"*\"\n \"/\"\n] @keyword\n\n\"_\" @variable.builtin\n\n\"null\" @constant.builtin\n\n[\n \"true\"\n \"false\"\n] @boolean\n\n(dollar_var) @variable.builtin\n(global_sigil) @keyword\n(metadata_sigil) @keyword\n(meta_selector) @attribute\n(number) @number\n(string) @string\n(format_expr) @string\n(ip) @constant\n(subnet) @constant\n(time) @number\n(duration) @number\n(frontmatter_open) @comment\n(frontmatter_close) @comment\n(comment) @comment\n\n(invocation\n operator: (entity) @function.call)\n(call_expression\n (entity) @function.call)\n(call_expression\n method: (entity) @function.method)\n((identifier) @variable.builtin (#match? @variable.builtin \"^\\$[A-Za-z_]\\w*$\"))\n\n[\n \"(\"\n \")\"\n] @punctuation.bracket\n\n[\n \",\"\n] @punctuation.delimiter\n\n[\n \"=\"\n \"=>\"\n \"|\"\n \"..\"\n \"::\"\n \"==\"\n \"!=\"\n \">\"\n \">=\"\n \"<\"\n \"<=\"\n] @operator\n";
9
+ var highlights = ";; Auto-generated by tenzir/tree-sitter-tql/scripts/generate-highlights.mjs. DO NOT EDIT.\n\n[\n \"let\"\n \"if\"\n \"else\"\n \"match\"\n \"and\"\n \"or\"\n \"not\"\n \"move\"\n \"in\"\n \"this\"\n \"?\"\n \".\"\n \"...\"\n \"[\"\n \"]\"\n \"{\"\n \"}\"\n \":\"\n] @keyword\n\n[\n \"+\"\n \"-\"\n \"*\"\n \"/\"\n] @keyword\n\n\"_\" @variable.builtin\n\n\"null\" @constant.builtin\n\n[\n \"true\"\n \"false\"\n] @boolean\n\n(dollar_var) @variable.builtin\n(global_sigil) @keyword\n(metadata_sigil) @keyword\n(meta_selector) @attribute\n(number) @number\n(string) @string\n(format_expr) @string\n(ip) @constant.ip\n(subnet) @constant.subnet\n(time) @number.time\n(duration) @number.duration\n(frontmatter_open) @comment\n(frontmatter_close) @comment\n(comment) @comment\n\n(invocation\n operator: (entity) @function.operator)\n(call_expression\n (entity) @function.call)\n(call_expression\n method: (entity) @function.method)\n((identifier) @variable.builtin (#match? @variable.builtin \"^\\$[A-Za-z_]\\w*$\"))\n\n[\n \"(\"\n \")\"\n] @punctuation.bracket\n\n[\n \",\"\n] @punctuation.delimiter\n\n[\n \"=\"\n \"=>\"\n \"|\"\n \"..\"\n \"::\"\n \"==\"\n \"!=\"\n \">\"\n \">=\"\n \"<\"\n \"<=\"\n] @operator\n";
10
10
 
11
11
  var indents = ";; Auto-generated by tenzir/tree-sitter-tql/scripts/generate-indents.mjs. DO NOT EDIT.\n\n[\n (then_block)\n (else_block)\n (pipeline_block)\n (pipeline_expression)\n (match_statement)\n (match_arm)\n (list)\n (record)\n] @indent\n\n[\n \"}\"\n \"]\"\n] @outdent\n\n[\n (string)\n (format_text)\n (comment)\n (frontmatter_body)\n] @indent.auto\n";
12
12
 
@@ -25,13 +25,18 @@ const tqlCaptureTags = {
25
25
  attribute: tags.attributeName,
26
26
  function: tags.function(tags.variableName),
27
27
  "function.call": tags.function(tags.variableName),
28
+ "function.operator": tags.function(tags.variableName),
28
29
  "function.method": tags.function(tags.propertyName),
29
30
  string: tags.string,
30
31
  "string.escape": tags.escape,
31
32
  "string.special": tags.special(tags.string),
32
33
  number: tags.number,
34
+ "number.time": tags.number,
35
+ "number.duration": tags.number,
33
36
  boolean: tags.bool,
34
37
  constant: tags.constant(tags.name),
38
+ "constant.ip": tags.constant(tags.name),
39
+ "constant.subnet": tags.constant(tags.name),
35
40
  "constant.builtin": tags.null,
36
41
  variable: tags.variableName,
37
42
  "variable.builtin": tags.special(tags.variableName),
@@ -568,7 +573,7 @@ class TqlParse {
568
573
 
569
574
  /** The queries of tree-sitter-tql that `tql` uses unless given others. */
570
575
  const tqlQueries = { highlights, indents, folds, brackets, injections };
571
- const rawPrefixes = ["r", "br"].flatMap((prefix) => {
576
+ const hashedPrefixes = ["b", "r", "br"].flatMap((prefix) => {
572
577
  return Array.from({ length: 9 }, (_, hashes) => prefix + "#".repeat(hashes));
573
578
  });
574
579
  /**
@@ -589,8 +594,10 @@ function tql(treeSitter, options = {}) {
589
594
  const data = defineLanguageFacet({
590
595
  commentTokens: { line: "//", block: { open: "/*", close: "*/" } },
591
596
  closeBrackets: {
592
- // Raw strings take up to 8 hashes, as in tree-sitter-tql.
593
- stringPrefixes: ["f", "b", ...rawPrefixes],
597
+ // TQL has no single-quoted strings.
598
+ brackets: ["(", "[", "{", '"'],
599
+ // Byte and raw strings take up to 8 hashes, as in tree-sitter-tql.
600
+ stringPrefixes: ["f", ...hashedPrefixes],
594
601
  },
595
602
  indentOnInput: /^\s*[}\]]$/,
596
603
  });
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
10
- "version": "0.5.0",
10
+ "version": "0.5.2",
11
11
  "description": "Tenzir Query Language (TQL) support for CodeMirror, backed by tree-sitter-tql",
12
12
  "keywords": [
13
13
  "codemirror",
@@ -49,7 +49,7 @@
49
49
  "@rollup/plugin-typescript": "^12.3.1",
50
50
  "rollup": "^4.68.2",
51
51
  "rollup-plugin-dts": "^6.5.1",
52
- "tree-sitter-tql": "1.3.0",
52
+ "tree-sitter-tql": "1.5.0",
53
53
  "tslib": "^2.9.1",
54
54
  "typescript": "^5.9.3",
55
55
  "web-tree-sitter": "^0.26.13"