From 3cb55ab8b422bf3ad3fc08cecef79c3944f0045c Mon Sep 17 00:00:00 2001 From: Anthony Manning-Franklin Date: Thu, 27 Nov 2025 16:55:03 +0800 Subject: [PATCH 01/18] Add first zig scope facet --- data/fixtures/scopes/zig/namedFunction.scope | 10 +++++++ data/playground/zig.zig | 3 ++ .../languageScopeSupport.ts | 2 ++ packages/common/src/scopeSupportFacets/zig.ts | 30 +++++++++++++++++++ queries/zig.scm | 14 +++++++++ 5 files changed, 59 insertions(+) create mode 100644 data/fixtures/scopes/zig/namedFunction.scope create mode 100644 data/playground/zig.zig create mode 100644 packages/common/src/scopeSupportFacets/zig.ts create mode 100644 queries/zig.scm diff --git a/data/fixtures/scopes/zig/namedFunction.scope b/data/fixtures/scopes/zig/namedFunction.scope new file mode 100644 index 0000000000..da391d1a06 --- /dev/null +++ b/data/fixtures/scopes/zig/namedFunction.scope @@ -0,0 +1,10 @@ +fn someFunk() void {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:21 + >---------------------< +0| fn someFunk() void {} + +[Insertion delimiter] = "\n\n" diff --git a/data/playground/zig.zig b/data/playground/zig.zig new file mode 100644 index 0000000000..29e9078871 --- /dev/null +++ b/data/playground/zig.zig @@ -0,0 +1,3 @@ +const bob = "bobert"; + +fn myFunk() void {} diff --git a/packages/common/src/scopeSupportFacets/languageScopeSupport.ts b/packages/common/src/scopeSupportFacets/languageScopeSupport.ts index d1cfc7879b..41cefba4aa 100644 --- a/packages/common/src/scopeSupportFacets/languageScopeSupport.ts +++ b/packages/common/src/scopeSupportFacets/languageScopeSupport.ts @@ -32,6 +32,7 @@ import { typescriptScopeSupport } from "./typescript"; import { typescriptreactScopeSupport } from "./typescriptreact"; import { xmlScopeSupport } from "./xml"; import { yamlScopeSupport } from "./yaml"; +import { zigScopeSupport } from "./zig"; /* eslint-disable @typescript-eslint/naming-convention */ @@ -69,4 +70,5 @@ export const languageScopeSupport: StringRecord = typescriptreact: typescriptreactScopeSupport, xml: xmlScopeSupport, yaml: yamlScopeSupport, + zig: zigScopeSupport, }; diff --git a/packages/common/src/scopeSupportFacets/zig.ts b/packages/common/src/scopeSupportFacets/zig.ts new file mode 100644 index 0000000000..ed1284bac3 --- /dev/null +++ b/packages/common/src/scopeSupportFacets/zig.ts @@ -0,0 +1,30 @@ +import type { LanguageScopeSupportFacetMap } from "./scopeSupportFacets.types"; +import { ScopeSupportFacetLevel } from "./scopeSupportFacets.types"; + +const { supported, notApplicable, unsupported } = ScopeSupportFacetLevel; + +export const zigScopeSupport: LanguageScopeSupportFacetMap = { + namedFunction: supported, + list: unsupported, + + "textFragment.string.singleLine": unsupported, + "textFragment.string.multiLine": unsupported, + "textFragment.comment.line": unsupported, + "textFragment.comment.block": unsupported, + + // SectionIf I Take Under + section: notApplicable, + "section.iteration.document": notApplicable, + "section.iteration.parent": notApplicable, + + // Command + command: notApplicable, + "statement.command": notApplicable, + "name.command": notApplicable, + "value.command": notApplicable, + "interior.command": notApplicable, + + // Notebook cell + notebookCell: notApplicable, + "interior.cell": notApplicable, +}; diff --git a/queries/zig.scm b/queries/zig.scm new file mode 100644 index 0000000000..450174fda1 --- /dev/null +++ b/queries/zig.scm @@ -0,0 +1,14 @@ +;;!! (fn foo() void {}) +(function_declaration + "fn" + name: (identifier) + (parameters + "(" + ")" + ) + type: (_) + body: (block + "{" + "}" + ) +) @namedFunction From 0abea276538389a7277c0ceee6c58c689524f911 Mon Sep 17 00:00:00 2001 From: Anthony Manning-Franklin <4970703+Antman261@users.noreply.github.com> Date: Thu, 27 Nov 2025 19:16:56 +0800 Subject: [PATCH 02/18] Update queries/zig.scm Co-authored-by: Andreas Arvidsson --- queries/zig.scm | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/queries/zig.scm b/queries/zig.scm index 450174fda1..11124aeafc 100644 --- a/queries/zig.scm +++ b/queries/zig.scm @@ -1,14 +1,2 @@ ;;!! (fn foo() void {}) -(function_declaration - "fn" - name: (identifier) - (parameters - "(" - ")" - ) - type: (_) - body: (block - "{" - "}" - ) -) @namedFunction +(function_declaration) @namedFunction From c2fe2deb811af77710db94a4ce3cef1aff3ca0b4 Mon Sep 17 00:00:00 2001 From: Anthony Manning-Franklin <4970703+Antman261@users.noreply.github.com> Date: Thu, 27 Nov 2025 19:17:44 +0800 Subject: [PATCH 03/18] Update packages/common/src/scopeSupportFacets/zig.ts Co-authored-by: Andreas Arvidsson --- packages/common/src/scopeSupportFacets/zig.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/common/src/scopeSupportFacets/zig.ts b/packages/common/src/scopeSupportFacets/zig.ts index ed1284bac3..0a8d681f05 100644 --- a/packages/common/src/scopeSupportFacets/zig.ts +++ b/packages/common/src/scopeSupportFacets/zig.ts @@ -7,6 +7,8 @@ export const zigScopeSupport: LanguageScopeSupportFacetMap = { namedFunction: supported, list: unsupported, +/* UNSUPPORTED */ + "textFragment.string.singleLine": unsupported, "textFragment.string.multiLine": unsupported, "textFragment.comment.line": unsupported, From d56874b4ae3c0ca3aa83e2dc649685319785950b Mon Sep 17 00:00:00 2001 From: Anthony Manning-Franklin <4970703+Antman261@users.noreply.github.com> Date: Thu, 27 Nov 2025 19:17:57 +0800 Subject: [PATCH 04/18] Update packages/common/src/scopeSupportFacets/zig.ts Co-authored-by: Andreas Arvidsson --- packages/common/src/scopeSupportFacets/zig.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/common/src/scopeSupportFacets/zig.ts b/packages/common/src/scopeSupportFacets/zig.ts index 0a8d681f05..9e68840d68 100644 --- a/packages/common/src/scopeSupportFacets/zig.ts +++ b/packages/common/src/scopeSupportFacets/zig.ts @@ -14,7 +14,7 @@ export const zigScopeSupport: LanguageScopeSupportFacetMap = { "textFragment.comment.line": unsupported, "textFragment.comment.block": unsupported, - // SectionIf I Take Under + // Section section: notApplicable, "section.iteration.document": notApplicable, "section.iteration.parent": notApplicable, From 1f32c82b7a1458560815941b6468db75085cf0b2 Mon Sep 17 00:00:00 2001 From: Anthony Manning-Franklin <4970703+Antman261@users.noreply.github.com> Date: Thu, 27 Nov 2025 19:20:33 +0800 Subject: [PATCH 05/18] Apply suggestion from @AndreasArvidsson Co-authored-by: Andreas Arvidsson --- packages/common/src/scopeSupportFacets/zig.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/common/src/scopeSupportFacets/zig.ts b/packages/common/src/scopeSupportFacets/zig.ts index 9e68840d68..e9575cb666 100644 --- a/packages/common/src/scopeSupportFacets/zig.ts +++ b/packages/common/src/scopeSupportFacets/zig.ts @@ -14,6 +14,8 @@ export const zigScopeSupport: LanguageScopeSupportFacetMap = { "textFragment.comment.line": unsupported, "textFragment.comment.block": unsupported, +/* NOT APPLICABLE */ + // Section section: notApplicable, "section.iteration.document": notApplicable, From 94a9433721852db78423bc305b6cf2961c4c3b9c Mon Sep 17 00:00:00 2001 From: Anthony Manning-Franklin Date: Thu, 27 Nov 2025 23:29:38 +0800 Subject: [PATCH 06/18] add more scopes and scope tests --- .../zig/argument.actual.singleLine.scope | 10 +++ .../zig/argument.formal.singleLine.scope | 10 +++ .../zig/argumentList.actual.singleLine.scope | 10 +++ .../zig/argumentList.formal.singleLine.scope | 10 +++ data/fixtures/scopes/zig/functionCall.scope | 10 +++ data/fixtures/scopes/zig/functionCallee.scope | 10 +++ .../scopes/zig/statement.assignment.scope | 10 +++ packages/common/src/scopeSupportFacets/zig.ts | 78 +++++++++++++++++-- queries/zig.scm | 49 ++++++++++++ 9 files changed, 191 insertions(+), 6 deletions(-) create mode 100644 data/fixtures/scopes/zig/argument.actual.singleLine.scope create mode 100644 data/fixtures/scopes/zig/argument.formal.singleLine.scope create mode 100644 data/fixtures/scopes/zig/argumentList.actual.singleLine.scope create mode 100644 data/fixtures/scopes/zig/argumentList.formal.singleLine.scope create mode 100644 data/fixtures/scopes/zig/functionCall.scope create mode 100644 data/fixtures/scopes/zig/functionCallee.scope create mode 100644 data/fixtures/scopes/zig/statement.assignment.scope diff --git a/data/fixtures/scopes/zig/argument.actual.singleLine.scope b/data/fixtures/scopes/zig/argument.actual.singleLine.scope new file mode 100644 index 0000000000..9fca368176 --- /dev/null +++ b/data/fixtures/scopes/zig/argument.actual.singleLine.scope @@ -0,0 +1,10 @@ +foo(aa); +--- + +[Content] = +[Removal] = +[Domain] = 0:4-0:6 + >--< +0| foo(aa); + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/zig/argument.formal.singleLine.scope b/data/fixtures/scopes/zig/argument.formal.singleLine.scope new file mode 100644 index 0000000000..513cc99885 --- /dev/null +++ b/data/fixtures/scopes/zig/argument.formal.singleLine.scope @@ -0,0 +1,10 @@ +fn foo(arg: u8) void {} +--- + +[Content] = +[Removal] = +[Domain] = 0:7-0:14 + >-------< +0| fn foo(arg: u8) void {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/zig/argumentList.actual.singleLine.scope b/data/fixtures/scopes/zig/argumentList.actual.singleLine.scope new file mode 100644 index 0000000000..87e925ee76 --- /dev/null +++ b/data/fixtures/scopes/zig/argumentList.actual.singleLine.scope @@ -0,0 +1,10 @@ +foo(aaa, bbb); +--- + +[Content] = +[Removal] = +[Domain] = 0:4-0:12 + >--------< +0| foo(aaa, bbb); + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/zig/argumentList.formal.singleLine.scope b/data/fixtures/scopes/zig/argumentList.formal.singleLine.scope new file mode 100644 index 0000000000..2ffdfcb5df --- /dev/null +++ b/data/fixtures/scopes/zig/argumentList.formal.singleLine.scope @@ -0,0 +1,10 @@ +fn foo(aaa: u8, bbb: u8) void {} +--- + +[Content] = +[Removal] = +[Domain] = 0:7-0:23 + >----------------< +0| fn foo(aaa: u8, bbb: u8) void {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/zig/functionCall.scope b/data/fixtures/scopes/zig/functionCall.scope new file mode 100644 index 0000000000..633f02ca5e --- /dev/null +++ b/data/fixtures/scopes/zig/functionCall.scope @@ -0,0 +1,10 @@ +foo(); +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:5 + >-----< +0| foo(); + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/zig/functionCallee.scope b/data/fixtures/scopes/zig/functionCallee.scope new file mode 100644 index 0000000000..e2e112d6fd --- /dev/null +++ b/data/fixtures/scopes/zig/functionCallee.scope @@ -0,0 +1,10 @@ +foo(); +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:3 + >---< +0| foo(); + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/zig/statement.assignment.scope b/data/fixtures/scopes/zig/statement.assignment.scope new file mode 100644 index 0000000000..60eb993e9e --- /dev/null +++ b/data/fixtures/scopes/zig/statement.assignment.scope @@ -0,0 +1,10 @@ +const foo = "hello"; +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:20 + >--------------------< +0| const foo = "hello"; + +[Insertion delimiter] = "\n" diff --git a/packages/common/src/scopeSupportFacets/zig.ts b/packages/common/src/scopeSupportFacets/zig.ts index e9575cb666..3e6599c37a 100644 --- a/packages/common/src/scopeSupportFacets/zig.ts +++ b/packages/common/src/scopeSupportFacets/zig.ts @@ -5,16 +5,82 @@ const { supported, notApplicable, unsupported } = ScopeSupportFacetLevel; export const zigScopeSupport: LanguageScopeSupportFacetMap = { namedFunction: supported, + functionCall: supported, + functionCallee: supported, + "argument.formal.singleLine": supported, + "argument.actual.singleLine": supported, + "argumentList.formal.singleLine": supported, + "argumentList.actual.singleLine": supported, + "statement.assignment": supported, + + /* UNSUPPORTED */ + list: unsupported, -/* UNSUPPORTED */ + "statement.function": unsupported, + "statement.if": unsupported, + "statement.try": unsupported, + "statement.for": unsupported, + "statement.foreach": unsupported, + "statement.return": unsupported, + "statement.break": unsupported, + "statement.continue": unsupported, + + "argumentList.formal.empty": unsupported, + "argumentList.formal.multiLine": unsupported, + "argumentList.actual.empty": unsupported, + "argumentList.actual.multiLine": unsupported, + "argument.actual.multiLine": unsupported, + + "comment.line": unsupported, + "comment.block": unsupported, + + "branch.if": unsupported, + "branch.if.elif.else": unsupported, + "branch.if.else": unsupported, + "branch.if.iteration": unsupported, + "branch.try": unsupported, + "branch.try.iteration": unsupported, + "branch.switchCase": unsupported, + "branch.switchCase.iteration": unsupported, + + "condition.if": unsupported, + "condition.while": unsupported, + "condition.doWhile": unsupported, + "condition.for": unsupported, + "condition.ternary": unsupported, + "condition.switchCase": unsupported, + "condition.switchCase.iteration": unsupported, + + "name.assignment": unsupported, + "name.function": unsupported, + "name.argument.catch": unsupported, + "name.foreach": unsupported, + + "value.argument.formal": unsupported, + "value.argument.formal.iteration": unsupported, + "value.assignment": unsupported, + "value.variable": unsupported, + "value.foreach": unsupported, + "value.return": unsupported, + "value.switch": unsupported, + "value.iteration.block": unsupported, - "textFragment.string.singleLine": unsupported, - "textFragment.string.multiLine": unsupported, - "textFragment.comment.line": unsupported, - "textFragment.comment.block": unsupported, + "interior.class": unsupported, + "interior.function": unsupported, + // "interior.constructor": unsupported, + // "interior.method": unsupported, + "interior.if": unsupported, + // "interior.lambda": unsupported, + "interior.for": unsupported, + "interior.foreach": unsupported, + "interior.while": unsupported, + "interior.doWhile": unsupported, + "interior.switch": unsupported, + "interior.switchCase": unsupported, + "interior.try": unsupported, -/* NOT APPLICABLE */ + // /* NOT APPLICABLE */ // Section section: notApplicable, diff --git a/queries/zig.scm b/queries/zig.scm index 11124aeafc..860c4f41d5 100644 --- a/queries/zig.scm +++ b/queries/zig.scm @@ -1,2 +1,51 @@ ;;!! (fn foo() void {}) +;;! ^^^^^^^^^^^^^^^^ (function_declaration) @namedFunction + +;;!! (fn foo() void {}) +;;! ^^^^ +(function_declaration + (builtin_type) @type +) + +;;!! (fn foo(aa: u8, bb:u8) void {}) +(_ + (parameters + "(" @argumentList.removal.start.endOf + (parameter + (identifier) @name + ":" + (builtin_type) @type + ) @argumentOrParameter + ")" @argumentList.removal.end.startOf + ) @argumentList + (#child-range! @argumentList 1 -2) +) + +(call_expression + (identifier) @functionCallee + (arguments + "(" + (_)* @argumentOrParameter + ")" + ) @argumentList + (#child-range! @argumentList 1 -2) +) @functionCall + +(statement) @statement + +(variable_declaration + (identifier) @name + ":" + (_) @type + "=" + (_) @value + ";" +) @statement + +(variable_declaration + (identifier) @name + "=" + (_) @value + ";" +) @statement From 957ca9240618ffa46b35306bd2bf260fb1a99c6c Mon Sep 17 00:00:00 2001 From: Anthony Manning-Franklin Date: Fri, 28 Nov 2025 11:42:40 +0800 Subject: [PATCH 07/18] wip: improving zig scm --- data/playground/zig.zig | 11 +++++++++-- queries/zig.scm | 21 +++++++++++++-------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/data/playground/zig.zig b/data/playground/zig.zig index 29e9078871..9a86925df6 100644 --- a/data/playground/zig.zig +++ b/data/playground/zig.zig @@ -1,3 +1,10 @@ -const bob = "bobert"; +const std = @import("std"); -fn myFunk() void {} +const bob: *const [6]u8 = "bobert"; +const b = "bobert"; +fn printNumber(num: u8, numTwo: u8, numThree: u8) void { + std.debug.print("%n", .{ num, numTwo, numThree }); +} +fn main() !void { + printNumber(3, 4, 20); +} diff --git a/queries/zig.scm b/queries/zig.scm index 860c4f41d5..813addcb20 100644 --- a/queries/zig.scm +++ b/queries/zig.scm @@ -1,22 +1,27 @@ -;;!! (fn foo() void {}) -;;! ^^^^^^^^^^^^^^^^ -(function_declaration) @namedFunction - -;;!! (fn foo() void {}) -;;! ^^^^ +;;!! fn foo() void {} +;;! ^^^^ +;;! ^^^^^^^^^^^^^^^^ (function_declaration (builtin_type) @type -) +) @namedFunction -;;!! (fn foo(aa: u8, bb:u8) void {}) +;;!! fn foo(aa: u8, bb:u8) void {} +;;! ^^^^^^^^^^^^^ argumentList +;;! ^^ name +;;! ^^ type +;;! ^^^^^^ argumentOrParameter (_ (parameters "(" @argumentList.removal.start.endOf + (_)? @_.leading.endOf + . (parameter (identifier) @name ":" (builtin_type) @type ) @argumentOrParameter + . + (_)? @_.trailing.startOf ")" @argumentList.removal.end.startOf ) @argumentList (#child-range! @argumentList 1 -2) From 15b273cc71e397e4cf31b805cc11f844e5d5dd11 Mon Sep 17 00:00:00 2001 From: Anthony Manning-Franklin Date: Fri, 28 Nov 2025 13:32:38 +0800 Subject: [PATCH 08/18] wip: improve Zig scm --- queries/zig.scm | 61 ++++++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 28 deletions(-) diff --git a/queries/zig.scm b/queries/zig.scm index 813addcb20..4dd54ac9f4 100644 --- a/queries/zig.scm +++ b/queries/zig.scm @@ -1,56 +1,61 @@ ;;!! fn foo() void {} -;;! ^^^^ -;;! ^^^^^^^^^^^^^^^^ +;;! ^^^ name +;;! ^^^^ type +;;! ^^^^^^^^^^^^^^^^ namedFunction (function_declaration - (builtin_type) @type -) @namedFunction + name: (_) @name + type: (_) @type +) @namedFunction @_.domain -;;!! fn foo(aa: u8, bb:u8) void {} +;;!! fn foo(aa: u8) void {} ;;! ^^^^^^^^^^^^^ argumentList ;;! ^^ name ;;! ^^ type -;;! ^^^^^^ argumentOrParameter -(_ +(function_declaration (parameters - "(" @argumentList.removal.start.endOf (_)? @_.leading.endOf . (parameter (identifier) @name ":" - (builtin_type) @type - ) @argumentOrParameter + type: (_) @type + ) @argumentOrParameter @_.domain . (_)? @_.trailing.startOf - ")" @argumentList.removal.end.startOf - ) @argumentList - (#child-range! @argumentList 1 -2) + ) ) +;;!! fn foo(aa: u8, bb:u8) void {} +;;! ^^^^^^^^^^^^^ argumentList +(function_declaration + (parameters) @argumentList + (#child-range! @argumentList 1 -2) +) @argumentList.domain + +;;!! foo(aa, bb); +;;! ^^^ functionCallee +;;! ^^^^^^ argumentList +;;! ^^ ^^ argumentOrParameter +;;! ----------- functionCall ^domain (call_expression - (identifier) @functionCallee + function: (_) @functionCallee (arguments - "(" (_)* @argumentOrParameter - ")" - ) @argumentList + ) @argumentList @_.domain (#child-range! @argumentList 1 -2) -) @functionCall +) @functionCall @_.domain (statement) @statement +;;!! const foo: *const [3]u8 = "bar"; +;;! ^^^ name +;;! ^^^^^^^^^^^^ type +;;! ^^^^^ value +;;! -------------------------------- statement ^domain (variable_declaration (identifier) @name - ":" - (_) @type - "=" - (_) @value - ";" -) @statement - -(variable_declaration - (identifier) @name + type: (_)? @type "=" (_) @value ";" -) @statement +) @statement @_.domain From 1c060d3e199099e6d36672f79b5064560c7e8b36 Mon Sep 17 00:00:00 2001 From: Anthony Manning-Franklin Date: Mon, 1 Dec 2025 22:35:45 +0800 Subject: [PATCH 09/18] Improve scm examples --- queries/zig.scm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/queries/zig.scm b/queries/zig.scm index 4dd54ac9f4..8e02ee6260 100644 --- a/queries/zig.scm +++ b/queries/zig.scm @@ -8,7 +8,7 @@ ) @namedFunction @_.domain ;;!! fn foo(aa: u8) void {} -;;! ^^^^^^^^^^^^^ argumentList +;;! ^^^^^^ argumentOrParameter ;;! ^^ name ;;! ^^ type (function_declaration @@ -27,6 +27,7 @@ ;;!! fn foo(aa: u8, bb:u8) void {} ;;! ^^^^^^^^^^^^^ argumentList +;;! ----------------------------- ^domain (function_declaration (parameters) @argumentList (#child-range! @argumentList 1 -2) From 69cd67bf791d0f60a3fbe3df3b7fcae09ffe4726 Mon Sep 17 00:00:00 2001 From: Anthony Manning-Franklin Date: Mon, 1 Dec 2025 22:46:56 +0800 Subject: [PATCH 10/18] Update arg list test --- .../scopes/zig/argumentList.formal.singleLine.scope | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/data/fixtures/scopes/zig/argumentList.formal.singleLine.scope b/data/fixtures/scopes/zig/argumentList.formal.singleLine.scope index 2ffdfcb5df..4f2ffb899b 100644 --- a/data/fixtures/scopes/zig/argumentList.formal.singleLine.scope +++ b/data/fixtures/scopes/zig/argumentList.formal.singleLine.scope @@ -2,9 +2,12 @@ fn foo(aaa: u8, bbb: u8) void {} --- [Content] = -[Removal] = -[Domain] = 0:7-0:23 +[Removal] = 0:7-0:23 >----------------< 0| fn foo(aaa: u8, bbb: u8) void {} +[Domain] = 0:0-0:32 + >--------------------------------< +0| fn foo(aaa: u8, bbb: u8) void {} + [Insertion delimiter] = " " From e03a4f6e71e5f4b508073b64484f7549e216debd Mon Sep 17 00:00:00 2001 From: Anthony Manning-Franklin Date: Tue, 2 Dec 2025 00:37:29 +0800 Subject: [PATCH 11/18] wip: add more scope tests --- .../zig/argument.actual.iteration.scope | 2 + .../zig/argument.actual.multiLine.scope | 5 ++ .../zig/argument.actual.singleLine.scope | 2 +- .../zig/argument.formal.iteration.scope | 10 +++ .../zig/argument.formal.multiLine.scope | 44 +++++++++++++ .../zig/argument.formal.singleLine.scope | 2 +- .../zig/argumentList.actual.empty.scope | 13 ++++ .../zig/argumentList.actual.multiLine.scope | 2 + .../zig/argumentList.actual.singleLine.scope | 7 ++- .../zig/argumentList.formal.empty.scope | 13 ++++ .../zig/argumentList.formal.multiLine.scope | 32 ++++++++++ data/fixtures/scopes/zig/functionCallee.scope | 11 ++-- .../scopes/zig/name.argument.formal.scope | 55 ++++++++++++++++ .../fixtures/scopes/zig/name.assignment.scope | 24 +++++++ data/fixtures/scopes/zig/name.function.scope | 17 +++++ .../zig/type.argument.formal.iteration.scope | 2 + .../scopes/zig/type.argument.formal.scope | 62 +++++++++++++++++++ data/fixtures/scopes/zig/type.return.scope | 62 +++++++++++++++++++ data/fixtures/scopes/zig/type.variable.scope | 24 +++++++ .../scopes/zig/value.assignment.scope | 20 ++++++ data/playground/zig.zig | 2 + packages/common/src/scopeSupportFacets/zig.ts | 42 +++++++++---- queries/zig.scm | 11 ++-- 23 files changed, 440 insertions(+), 24 deletions(-) create mode 100644 data/fixtures/scopes/zig/argument.actual.iteration.scope create mode 100644 data/fixtures/scopes/zig/argument.actual.multiLine.scope create mode 100644 data/fixtures/scopes/zig/argument.formal.iteration.scope create mode 100644 data/fixtures/scopes/zig/argument.formal.multiLine.scope create mode 100644 data/fixtures/scopes/zig/argumentList.actual.empty.scope create mode 100644 data/fixtures/scopes/zig/argumentList.actual.multiLine.scope create mode 100644 data/fixtures/scopes/zig/argumentList.formal.empty.scope create mode 100644 data/fixtures/scopes/zig/argumentList.formal.multiLine.scope create mode 100644 data/fixtures/scopes/zig/name.argument.formal.scope create mode 100644 data/fixtures/scopes/zig/name.assignment.scope create mode 100644 data/fixtures/scopes/zig/name.function.scope create mode 100644 data/fixtures/scopes/zig/type.argument.formal.iteration.scope create mode 100644 data/fixtures/scopes/zig/type.argument.formal.scope create mode 100644 data/fixtures/scopes/zig/type.return.scope create mode 100644 data/fixtures/scopes/zig/type.variable.scope create mode 100644 data/fixtures/scopes/zig/value.assignment.scope diff --git a/data/fixtures/scopes/zig/argument.actual.iteration.scope b/data/fixtures/scopes/zig/argument.actual.iteration.scope new file mode 100644 index 0000000000..131575792b --- /dev/null +++ b/data/fixtures/scopes/zig/argument.actual.iteration.scope @@ -0,0 +1,2 @@ +foo(aaa, bbb); +--- diff --git a/data/fixtures/scopes/zig/argument.actual.multiLine.scope b/data/fixtures/scopes/zig/argument.actual.multiLine.scope new file mode 100644 index 0000000000..f5787791ec --- /dev/null +++ b/data/fixtures/scopes/zig/argument.actual.multiLine.scope @@ -0,0 +1,5 @@ +foo( + aaa, + bbb +); +--- diff --git a/data/fixtures/scopes/zig/argument.actual.singleLine.scope b/data/fixtures/scopes/zig/argument.actual.singleLine.scope index 9fca368176..6568e7a68c 100644 --- a/data/fixtures/scopes/zig/argument.actual.singleLine.scope +++ b/data/fixtures/scopes/zig/argument.actual.singleLine.scope @@ -1,4 +1,4 @@ -foo(aa); +foo(aaa, bbb); --- [Content] = diff --git a/data/fixtures/scopes/zig/argument.formal.iteration.scope b/data/fixtures/scopes/zig/argument.formal.iteration.scope new file mode 100644 index 0000000000..39b5001413 --- /dev/null +++ b/data/fixtures/scopes/zig/argument.formal.iteration.scope @@ -0,0 +1,10 @@ +fn foo(aaa: u8, bbb: u8) void {} +--- + +[Content] = 0:7-0:23 + >----------------< +0| fn foo(aaa: u8, bbb: u8) void {} + +[Domain] = 0:0-0:32 + >--------------------------------< +0| fn foo(aaa: u8, bbb: u8) void {} diff --git a/data/fixtures/scopes/zig/argument.formal.multiLine.scope b/data/fixtures/scopes/zig/argument.formal.multiLine.scope new file mode 100644 index 0000000000..1d5a0a7a7c --- /dev/null +++ b/data/fixtures/scopes/zig/argument.formal.multiLine.scope @@ -0,0 +1,44 @@ +fn foo( + aa: u8, + bb: u8, +) void {} +--- + +[#1 Content] = +[#1 Domain] = 1:4-1:10 + >------< +1| aa: u8, + +[#1 Removal] = 1:4-2:4 + >------- +1| aa: u8, +2| bb: u8, + ----< + +[#1 Trailing delimiter] = 1:10-2:4 + >- +1| aa: u8, +2| bb: u8, + ----< + +[#1 Insertion delimiter] = ",\n" + + +[#2 Content] = +[#2 Domain] = 2:4-2:10 + >------< +2| bb: u8, + +[#2 Removal] = 1:10-2:10 + >- +1| aa: u8, +2| bb: u8, + ----------< + +[#2 Leading delimiter] = 1:10-2:4 + >- +1| aa: u8, +2| bb: u8, + ----< + +[#2 Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/zig/argument.formal.singleLine.scope b/data/fixtures/scopes/zig/argument.formal.singleLine.scope index 513cc99885..04edfa7086 100644 --- a/data/fixtures/scopes/zig/argument.formal.singleLine.scope +++ b/data/fixtures/scopes/zig/argument.formal.singleLine.scope @@ -7,4 +7,4 @@ fn foo(arg: u8) void {} >-------< 0| fn foo(arg: u8) void {} -[Insertion delimiter] = " " +[Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/zig/argumentList.actual.empty.scope b/data/fixtures/scopes/zig/argumentList.actual.empty.scope new file mode 100644 index 0000000000..7f62df58de --- /dev/null +++ b/data/fixtures/scopes/zig/argumentList.actual.empty.scope @@ -0,0 +1,13 @@ +foo(); +--- + +[Content] = +[Removal] = 0:4-0:4 + >< +0| foo(); + +[Domain] = 0:0-0:5 + >-----< +0| foo(); + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/zig/argumentList.actual.multiLine.scope b/data/fixtures/scopes/zig/argumentList.actual.multiLine.scope new file mode 100644 index 0000000000..131575792b --- /dev/null +++ b/data/fixtures/scopes/zig/argumentList.actual.multiLine.scope @@ -0,0 +1,2 @@ +foo(aaa, bbb); +--- diff --git a/data/fixtures/scopes/zig/argumentList.actual.singleLine.scope b/data/fixtures/scopes/zig/argumentList.actual.singleLine.scope index 87e925ee76..e11f994e9f 100644 --- a/data/fixtures/scopes/zig/argumentList.actual.singleLine.scope +++ b/data/fixtures/scopes/zig/argumentList.actual.singleLine.scope @@ -2,9 +2,12 @@ foo(aaa, bbb); --- [Content] = -[Removal] = -[Domain] = 0:4-0:12 +[Removal] = 0:4-0:12 >--------< 0| foo(aaa, bbb); +[Domain] = 0:0-0:13 + >-------------< +0| foo(aaa, bbb); + [Insertion delimiter] = " " diff --git a/data/fixtures/scopes/zig/argumentList.formal.empty.scope b/data/fixtures/scopes/zig/argumentList.formal.empty.scope new file mode 100644 index 0000000000..1f9b49ec0f --- /dev/null +++ b/data/fixtures/scopes/zig/argumentList.formal.empty.scope @@ -0,0 +1,13 @@ +fn foo() void {} +--- + +[Content] = +[Removal] = 0:7-0:7 + >< +0| fn foo() void {} + +[Domain] = 0:0-0:16 + >----------------< +0| fn foo() void {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/zig/argumentList.formal.multiLine.scope b/data/fixtures/scopes/zig/argumentList.formal.multiLine.scope new file mode 100644 index 0000000000..5ef23675b0 --- /dev/null +++ b/data/fixtures/scopes/zig/argumentList.formal.multiLine.scope @@ -0,0 +1,32 @@ +foo( + aaa, + bbb +); +--- + +[Content] = 1:4-2:7 + >----- +1| aaa, +2| bbb + -------< + +[Removal] = 1:0-3:0 + >--------- +1| aaa, +2| bbb +3| ); + < + +[Leading delimiter] = 1:0-1:4 + >----< +1| aaa, + +[Domain] = 0:0-3:1 + >---- +0| foo( +1| aaa, +2| bbb +3| ); + -< + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/zig/functionCallee.scope b/data/fixtures/scopes/zig/functionCallee.scope index e2e112d6fd..66bd7c37f6 100644 --- a/data/fixtures/scopes/zig/functionCallee.scope +++ b/data/fixtures/scopes/zig/functionCallee.scope @@ -1,10 +1,13 @@ -foo(); +foo(aa, bb); --- [Content] = -[Removal] = -[Domain] = 0:0-0:3 +[Removal] = 0:0-0:3 >---< -0| foo(); +0| foo(aa, bb); + +[Domain] = 0:0-0:11 + >-----------< +0| foo(aa, bb); [Insertion delimiter] = " " diff --git a/data/fixtures/scopes/zig/name.argument.formal.scope b/data/fixtures/scopes/zig/name.argument.formal.scope new file mode 100644 index 0000000000..f042beeb11 --- /dev/null +++ b/data/fixtures/scopes/zig/name.argument.formal.scope @@ -0,0 +1,55 @@ +fn foo(aaa: u8, bbb: u8) void {} +--- + +[#1 Content] = +[#1 Removal] = 0:3-0:6 + >---< +0| fn foo(aaa: u8, bbb: u8) void {} + +[#1 Leading delimiter] = 0:2-0:3 + >-< +0| fn foo(aaa: u8, bbb: u8) void {} + +[#1 Domain] = 0:0-0:32 + >--------------------------------< +0| fn foo(aaa: u8, bbb: u8) void {} + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 0:7-0:10 + >---< +0| fn foo(aaa: u8, bbb: u8) void {} + +[#2 Removal] = 0:7-0:16 + >---------< +0| fn foo(aaa: u8, bbb: u8) void {} + +[#2 Trailing delimiter] = 0:10-0:16 + >------< +0| fn foo(aaa: u8, bbb: u8) void {} + +[#2 Domain] = 0:7-0:14 + >-------< +0| fn foo(aaa: u8, bbb: u8) void {} + +[#2 Insertion delimiter] = " " + + +[#3 Content] = 0:16-0:19 + >---< +0| fn foo(aaa: u8, bbb: u8) void {} + +[#3 Removal] = 0:14-0:19 + >-----< +0| fn foo(aaa: u8, bbb: u8) void {} + +[#3 Leading delimiter] = 0:14-0:16 + >--< +0| fn foo(aaa: u8, bbb: u8) void {} + +[#3 Domain] = 0:16-0:23 + >-------< +0| fn foo(aaa: u8, bbb: u8) void {} + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/zig/name.assignment.scope b/data/fixtures/scopes/zig/name.assignment.scope new file mode 100644 index 0000000000..cb6a3eab56 --- /dev/null +++ b/data/fixtures/scopes/zig/name.assignment.scope @@ -0,0 +1,24 @@ +const foo = "bar"; +--- + +[Content] = 0:6-0:9 + >---< +0| const foo = "bar"; + +[Removal] = 0:6-0:10 + >----< +0| const foo = "bar"; + +[Leading delimiter] = 0:5-0:6 + >-< +0| const foo = "bar"; + +[Trailing delimiter] = 0:9-0:10 + >-< +0| const foo = "bar"; + +[Domain] = 0:0-0:18 + >------------------< +0| const foo = "bar"; + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/zig/name.function.scope b/data/fixtures/scopes/zig/name.function.scope new file mode 100644 index 0000000000..cce2929c6d --- /dev/null +++ b/data/fixtures/scopes/zig/name.function.scope @@ -0,0 +1,17 @@ +fn foo() void {} +--- + +[Content] = +[Removal] = 0:3-0:6 + >---< +0| fn foo() void {} + +[Leading delimiter] = 0:2-0:3 + >-< +0| fn foo() void {} + +[Domain] = 0:0-0:16 + >----------------< +0| fn foo() void {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/zig/type.argument.formal.iteration.scope b/data/fixtures/scopes/zig/type.argument.formal.iteration.scope new file mode 100644 index 0000000000..571c7b2966 --- /dev/null +++ b/data/fixtures/scopes/zig/type.argument.formal.iteration.scope @@ -0,0 +1,2 @@ +fn foo(aaa: u8, bbb: u8) void {} +--- diff --git a/data/fixtures/scopes/zig/type.argument.formal.scope b/data/fixtures/scopes/zig/type.argument.formal.scope new file mode 100644 index 0000000000..8a179c3571 --- /dev/null +++ b/data/fixtures/scopes/zig/type.argument.formal.scope @@ -0,0 +1,62 @@ +fn foo(aaa: u8, bbb: u8) void {} +--- + +[#1 Content] = 0:25-0:29 + >----< +0| fn foo(aaa: u8, bbb: u8) void {} + +[#1 Removal] = 0:25-0:30 + >-----< +0| fn foo(aaa: u8, bbb: u8) void {} + +[#1 Leading delimiter] = 0:24-0:25 + >-< +0| fn foo(aaa: u8, bbb: u8) void {} + +[#1 Trailing delimiter] = 0:29-0:30 + >-< +0| fn foo(aaa: u8, bbb: u8) void {} + +[#1 Domain] = 0:0-0:32 + >--------------------------------< +0| fn foo(aaa: u8, bbb: u8) void {} + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 0:12-0:14 + >--< +0| fn foo(aaa: u8, bbb: u8) void {} + +[#2 Removal] = 0:12-0:16 + >----< +0| fn foo(aaa: u8, bbb: u8) void {} + +[#2 Trailing delimiter] = 0:14-0:16 + >--< +0| fn foo(aaa: u8, bbb: u8) void {} + +[#2 Domain] = 0:7-0:14 + >-------< +0| fn foo(aaa: u8, bbb: u8) void {} + +[#2 Insertion delimiter] = " " + + +[#3 Content] = 0:21-0:23 + >--< +0| fn foo(aaa: u8, bbb: u8) void {} + +[#3 Removal] = 0:14-0:23 + >---------< +0| fn foo(aaa: u8, bbb: u8) void {} + +[#3 Leading delimiter] = 0:14-0:21 + >-------< +0| fn foo(aaa: u8, bbb: u8) void {} + +[#3 Domain] = 0:16-0:23 + >-------< +0| fn foo(aaa: u8, bbb: u8) void {} + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/zig/type.return.scope b/data/fixtures/scopes/zig/type.return.scope new file mode 100644 index 0000000000..8a179c3571 --- /dev/null +++ b/data/fixtures/scopes/zig/type.return.scope @@ -0,0 +1,62 @@ +fn foo(aaa: u8, bbb: u8) void {} +--- + +[#1 Content] = 0:25-0:29 + >----< +0| fn foo(aaa: u8, bbb: u8) void {} + +[#1 Removal] = 0:25-0:30 + >-----< +0| fn foo(aaa: u8, bbb: u8) void {} + +[#1 Leading delimiter] = 0:24-0:25 + >-< +0| fn foo(aaa: u8, bbb: u8) void {} + +[#1 Trailing delimiter] = 0:29-0:30 + >-< +0| fn foo(aaa: u8, bbb: u8) void {} + +[#1 Domain] = 0:0-0:32 + >--------------------------------< +0| fn foo(aaa: u8, bbb: u8) void {} + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 0:12-0:14 + >--< +0| fn foo(aaa: u8, bbb: u8) void {} + +[#2 Removal] = 0:12-0:16 + >----< +0| fn foo(aaa: u8, bbb: u8) void {} + +[#2 Trailing delimiter] = 0:14-0:16 + >--< +0| fn foo(aaa: u8, bbb: u8) void {} + +[#2 Domain] = 0:7-0:14 + >-------< +0| fn foo(aaa: u8, bbb: u8) void {} + +[#2 Insertion delimiter] = " " + + +[#3 Content] = 0:21-0:23 + >--< +0| fn foo(aaa: u8, bbb: u8) void {} + +[#3 Removal] = 0:14-0:23 + >---------< +0| fn foo(aaa: u8, bbb: u8) void {} + +[#3 Leading delimiter] = 0:14-0:21 + >-------< +0| fn foo(aaa: u8, bbb: u8) void {} + +[#3 Domain] = 0:16-0:23 + >-------< +0| fn foo(aaa: u8, bbb: u8) void {} + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/zig/type.variable.scope b/data/fixtures/scopes/zig/type.variable.scope new file mode 100644 index 0000000000..33ba156573 --- /dev/null +++ b/data/fixtures/scopes/zig/type.variable.scope @@ -0,0 +1,24 @@ +const foo: u8 = 0; +--- + +[Content] = 0:11-0:13 + >--< +0| const foo: u8 = 0; + +[Removal] = 0:11-0:14 + >---< +0| const foo: u8 = 0; + +[Leading delimiter] = 0:10-0:11 + >-< +0| const foo: u8 = 0; + +[Trailing delimiter] = 0:13-0:14 + >-< +0| const foo: u8 = 0; + +[Domain] = 0:0-0:18 + >------------------< +0| const foo: u8 = 0; + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/zig/value.assignment.scope b/data/fixtures/scopes/zig/value.assignment.scope new file mode 100644 index 0000000000..b679fbff3b --- /dev/null +++ b/data/fixtures/scopes/zig/value.assignment.scope @@ -0,0 +1,20 @@ +const foo = "bar"; +--- + +[Content] = 0:12-0:17 + >-----< +0| const foo = "bar"; + +[Removal] = 0:11-0:17 + >------< +0| const foo = "bar"; + +[Leading delimiter] = 0:11-0:12 + >-< +0| const foo = "bar"; + +[Domain] = 0:0-0:18 + >------------------< +0| const foo = "bar"; + +[Insertion delimiter] = " " diff --git a/data/playground/zig.zig b/data/playground/zig.zig index 9a86925df6..be68c8c3b7 100644 --- a/data/playground/zig.zig +++ b/data/playground/zig.zig @@ -5,6 +5,8 @@ const b = "bobert"; fn printNumber(num: u8, numTwo: u8, numThree: u8) void { std.debug.print("%n", .{ num, numTwo, numThree }); } +fn foo() void {} fn main() !void { printNumber(3, 4, 20); + foo(); } diff --git a/packages/common/src/scopeSupportFacets/zig.ts b/packages/common/src/scopeSupportFacets/zig.ts index 3e6599c37a..057a21933d 100644 --- a/packages/common/src/scopeSupportFacets/zig.ts +++ b/packages/common/src/scopeSupportFacets/zig.ts @@ -8,16 +8,33 @@ export const zigScopeSupport: LanguageScopeSupportFacetMap = { functionCall: supported, functionCallee: supported, "argument.formal.singleLine": supported, + "argument.formal.multiLine": supported, + "argument.formal.iteration": supported, "argument.actual.singleLine": supported, + "argument.actual.multiLine": supported, + "argument.actual.iteration": supported, "argumentList.formal.singleLine": supported, + "argumentList.formal.multiLine": supported, + "argumentList.formal.empty": supported, "argumentList.actual.singleLine": supported, + "argumentList.actual.multiLine": supported, + "argumentList.actual.empty": supported, "statement.assignment": supported, + "name.assignment": supported, + "name.function": supported, + "name.argument.formal": supported, + "value.assignment": supported, + "type.argument.formal": supported, + "type.argument.formal.iteration": supported, + "type.return": supported, + "type.variable": supported, /* UNSUPPORTED */ list: unsupported, "statement.function": unsupported, + "statement.class": unsupported, "statement.if": unsupported, "statement.try": unsupported, "statement.for": unsupported, @@ -25,16 +42,20 @@ export const zigScopeSupport: LanguageScopeSupportFacetMap = { "statement.return": unsupported, "statement.break": unsupported, "statement.continue": unsupported, - - "argumentList.formal.empty": unsupported, - "argumentList.formal.multiLine": unsupported, - "argumentList.actual.empty": unsupported, - "argumentList.actual.multiLine": unsupported, - "argument.actual.multiLine": unsupported, + "statement.doWhile": unsupported, + "statement.enum": unsupported, + "statement.field.class": unsupported, + "statement.method": unsupported, + "statement.misc": unsupported, + "statement.switch": unsupported, + "statement.variable": unsupported, "comment.line": unsupported, "comment.block": unsupported, + "string.multiLine": unsupported, + "string.singleLine": unsupported, + "branch.if": unsupported, "branch.if.elif.else": unsupported, "branch.if.else": unsupported, @@ -52,14 +73,11 @@ export const zigScopeSupport: LanguageScopeSupportFacetMap = { "condition.switchCase": unsupported, "condition.switchCase.iteration": unsupported, - "name.assignment": unsupported, - "name.function": unsupported, "name.argument.catch": unsupported, "name.foreach": unsupported, "value.argument.formal": unsupported, "value.argument.formal.iteration": unsupported, - "value.assignment": unsupported, "value.variable": unsupported, "value.foreach": unsupported, "value.return": unsupported, @@ -68,10 +86,10 @@ export const zigScopeSupport: LanguageScopeSupportFacetMap = { "interior.class": unsupported, "interior.function": unsupported, - // "interior.constructor": unsupported, - // "interior.method": unsupported, + "interior.constructor": unsupported, + "interior.method": unsupported, "interior.if": unsupported, - // "interior.lambda": unsupported, + "interior.lambda": unsupported, "interior.for": unsupported, "interior.foreach": unsupported, "interior.while": unsupported, diff --git a/queries/zig.scm b/queries/zig.scm index 8e02ee6260..dbd2a6bedb 100644 --- a/queries/zig.scm +++ b/queries/zig.scm @@ -1,16 +1,17 @@ ;;!! fn foo() void {} ;;! ^^^ name ;;! ^^^^ type -;;! ^^^^^^^^^^^^^^^^ namedFunction +;;! ---------------- namedFunction ^domain (function_declaration name: (_) @name type: (_) @type ) @namedFunction @_.domain ;;!! fn foo(aa: u8) void {} -;;! ^^^^^^ argumentOrParameter ;;! ^^ name ;;! ^^ type +;;! ^^^^^^ argumentOrParameter ^domain +;;! ---------------------- ^domain (function_declaration (parameters (_)? @_.leading.endOf @@ -22,8 +23,10 @@ ) @argumentOrParameter @_.domain . (_)? @_.trailing.startOf - ) -) + ) @_dummy + (#not-type? @argumentOrParameter "comment") + (#single-or-multi-line-delimiter! @argumentOrParameter @_dummy ", " ",\n") +) @argumentOrParameter.domain @_.domain ;;!! fn foo(aa: u8, bb:u8) void {} ;;! ^^^^^^^^^^^^^ argumentList From f35dd75b5f2e7dc33930e032d12a2ea68f44ce7e Mon Sep 17 00:00:00 2001 From: Anthony Manning-Franklin Date: Mon, 22 Dec 2025 17:01:14 +0800 Subject: [PATCH 12/18] wip: improving argument iteration and domain --- .../zig/argument.actual.iteration.scope | 1 + .../zig/argument.actual.multiLine.scope | 15 +++++++ .../zig/argument.actual.singleLine.scope | 6 +-- .../zig/argumentList.actual.multiLine.scope | 5 ++- .../zig/type.argument.formal.iteration.scope | 1 + queries/zig.scm | 44 ++++++++++++++++--- 6 files changed, 61 insertions(+), 11 deletions(-) diff --git a/data/fixtures/scopes/zig/argument.actual.iteration.scope b/data/fixtures/scopes/zig/argument.actual.iteration.scope index 131575792b..b7c21c7fb7 100644 --- a/data/fixtures/scopes/zig/argument.actual.iteration.scope +++ b/data/fixtures/scopes/zig/argument.actual.iteration.scope @@ -1,2 +1,3 @@ foo(aaa, bbb); --- + diff --git a/data/fixtures/scopes/zig/argument.actual.multiLine.scope b/data/fixtures/scopes/zig/argument.actual.multiLine.scope index f5787791ec..3f2e90a79d 100644 --- a/data/fixtures/scopes/zig/argument.actual.multiLine.scope +++ b/data/fixtures/scopes/zig/argument.actual.multiLine.scope @@ -3,3 +3,18 @@ foo( bbb ); --- + +[Content] = +[Domain] = 1:4-1:7 + >---< +1| aaa, + +[Removal] = 1:0-1:7 + >-------< +1| aaa, + +[Leading delimiter] = 1:0-1:4 + >----< +1| aaa, + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/zig/argument.actual.singleLine.scope b/data/fixtures/scopes/zig/argument.actual.singleLine.scope index 6568e7a68c..6b8ad74064 100644 --- a/data/fixtures/scopes/zig/argument.actual.singleLine.scope +++ b/data/fixtures/scopes/zig/argument.actual.singleLine.scope @@ -3,8 +3,8 @@ foo(aaa, bbb); [Content] = [Removal] = -[Domain] = 0:4-0:6 - >--< -0| foo(aa); +[Domain] = 0:4-0:7 + >---< +0| foo(aaa, bbb); [Insertion delimiter] = " " diff --git a/data/fixtures/scopes/zig/argumentList.actual.multiLine.scope b/data/fixtures/scopes/zig/argumentList.actual.multiLine.scope index 131575792b..6fbbfc8ef8 100644 --- a/data/fixtures/scopes/zig/argumentList.actual.multiLine.scope +++ b/data/fixtures/scopes/zig/argumentList.actual.multiLine.scope @@ -1,2 +1,5 @@ -foo(aaa, bbb); +foo( + aaa, + bbb +); --- diff --git a/data/fixtures/scopes/zig/type.argument.formal.iteration.scope b/data/fixtures/scopes/zig/type.argument.formal.iteration.scope index 571c7b2966..938fdc26aa 100644 --- a/data/fixtures/scopes/zig/type.argument.formal.iteration.scope +++ b/data/fixtures/scopes/zig/type.argument.formal.iteration.scope @@ -1,2 +1,3 @@ fn foo(aaa: u8, bbb: u8) void {} --- + diff --git a/queries/zig.scm b/queries/zig.scm index dbd2a6bedb..99e4e76a34 100644 --- a/queries/zig.scm +++ b/queries/zig.scm @@ -12,7 +12,7 @@ ;;! ^^ type ;;! ^^^^^^ argumentOrParameter ^domain ;;! ---------------------- ^domain -(function_declaration +(_ (parameters (_)? @_.leading.endOf . @@ -26,7 +26,7 @@ ) @_dummy (#not-type? @argumentOrParameter "comment") (#single-or-multi-line-delimiter! @argumentOrParameter @_dummy ", " ",\n") -) @argumentOrParameter.domain @_.domain +) ;;!! fn foo(aa: u8, bb:u8) void {} ;;! ^^^^^^^^^^^^^ argumentList @@ -36,18 +36,48 @@ (#child-range! @argumentList 1 -2) ) @argumentList.domain -;;!! foo(aa, bb); +;;!! fn foo(aa: u8, bb:u8) void {} +;;! ^^^^^^^^^^^^^ +(_ + (parameters + "(" @argumentList.removal.start.endOf @argumentOrParameter.iteration.start.endOf + ")" @argumentList.removal.end.startOf @argumentOrParameter.iteration.end.startOf + ) @argumentList + (#empty-single-multi-delimiter! @argumentList @argumentList "" ", " ",\n") + (#child-range! @argumentList 1 -2) +) @argumentList.domain @argumentOrParameter.iteration.domain + +;; (parameters +;; "(" @name.iteration.start.endOf @value.iteration.start.endOf @type.iteration.start.endOf +;; ")" @name.iteration.end.startOf @value.iteration.end.startOf @type.iteration.end.startOf +;; ) + +;;!! foo(aaa, bbb); ;;! ^^^ functionCallee -;;! ^^^^^^ argumentList ;;! ^^ ^^ argumentOrParameter -;;! ----------- functionCall ^domain +;;! ^^^^^^ argumentList +;;! ----------- functionCall argumentList.domain (call_expression function: (_) @functionCallee (arguments (_)* @argumentOrParameter - ) @argumentList @_.domain + ) @argumentList (#child-range! @argumentList 1 -2) -) @functionCall @_.domain +) @functionCall @functionCallee.domain @argumentList.domain + +;;!! foo(aaa, bbb); +;;! ^^^ ^^^ +( + (arguments + (_)? @_.leading.endOf + . + (_) @argumentOrParameter + . + (_)? @_.trailing.startOf + ) + (#not-type? @argumentOrParameter "comment") + (#single-or-multi-line-delimiter! @argumentOrParameter @_dummy ", " ",\n") +) (statement) @statement From 35d14426796ce70843d8f8cffb53f7d4245228b8 Mon Sep 17 00:00:00 2001 From: Anthony Manning-Franklin Date: Mon, 22 Dec 2025 17:13:02 +0800 Subject: [PATCH 13/18] wip: function declaration argument iteration working --- queries/zig.scm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/queries/zig.scm b/queries/zig.scm index 99e4e76a34..adea845dce 100644 --- a/queries/zig.scm +++ b/queries/zig.scm @@ -25,7 +25,7 @@ (_)? @_.trailing.startOf ) @_dummy (#not-type? @argumentOrParameter "comment") - (#single-or-multi-line-delimiter! @argumentOrParameter @_dummy ", " ",\n") + (#single-or-multi-line-delimiter! @argumentOrParameter @argumentOrParameter ", " ",\n") ) ;;!! fn foo(aa: u8, bb:u8) void {} @@ -76,7 +76,7 @@ (_)? @_.trailing.startOf ) (#not-type? @argumentOrParameter "comment") - (#single-or-multi-line-delimiter! @argumentOrParameter @_dummy ", " ",\n") + (#single-or-multi-line-delimiter! @argumentOrParameter argumentOrParameter_dummy ", " ",\n") ) (statement) @statement From 07aed70f2e597039ebcbb0021e2210c80956743c Mon Sep 17 00:00:00 2001 From: Anthony Manning-Franklin Date: Mon, 22 Dec 2025 17:23:08 +0800 Subject: [PATCH 14/18] wip: fix variable declaration type removal of leading ":" --- queries/zig.scm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/queries/zig.scm b/queries/zig.scm index adea845dce..723bded6fd 100644 --- a/queries/zig.scm +++ b/queries/zig.scm @@ -76,7 +76,7 @@ (_)? @_.trailing.startOf ) (#not-type? @argumentOrParameter "comment") - (#single-or-multi-line-delimiter! @argumentOrParameter argumentOrParameter_dummy ", " ",\n") + (#single-or-multi-line-delimiter! @argumentOrParameter @argumentOrParameter ", " ",\n") ) (statement) @statement @@ -87,8 +87,8 @@ ;;! ^^^^^ value ;;! -------------------------------- statement ^domain (variable_declaration - (identifier) @name - type: (_)? @type + (identifier) @name @type.leading.endOf + type: (_)? @type @name.leading.endOf "=" (_) @value ";" From 3137256db29fc718eae05feb621119ad14d1373a Mon Sep 17 00:00:00 2001 From: Anthony Manning-Franklin Date: Mon, 22 Dec 2025 19:29:39 +0800 Subject: [PATCH 15/18] Remove unsupported arg iteration scopes --- packages/common/src/scopeSupportFacets/zig.ts | 7 ++++--- queries/zig.scm | 12 ++++++------ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/packages/common/src/scopeSupportFacets/zig.ts b/packages/common/src/scopeSupportFacets/zig.ts index 057a21933d..be488ff8c3 100644 --- a/packages/common/src/scopeSupportFacets/zig.ts +++ b/packages/common/src/scopeSupportFacets/zig.ts @@ -12,12 +12,10 @@ export const zigScopeSupport: LanguageScopeSupportFacetMap = { "argument.formal.iteration": supported, "argument.actual.singleLine": supported, "argument.actual.multiLine": supported, - "argument.actual.iteration": supported, "argumentList.formal.singleLine": supported, "argumentList.formal.multiLine": supported, "argumentList.formal.empty": supported, "argumentList.actual.singleLine": supported, - "argumentList.actual.multiLine": supported, "argumentList.actual.empty": supported, "statement.assignment": supported, "name.assignment": supported, @@ -25,12 +23,15 @@ export const zigScopeSupport: LanguageScopeSupportFacetMap = { "name.argument.formal": supported, "value.assignment": supported, "type.argument.formal": supported, - "type.argument.formal.iteration": supported, "type.return": supported, "type.variable": supported, /* UNSUPPORTED */ + "argument.actual.iteration": unsupported, + "argumentList.actual.multiLine": unsupported, + "type.argument.formal.iteration": unsupported, + list: unsupported, "statement.function": unsupported, diff --git a/queries/zig.scm b/queries/zig.scm index 723bded6fd..fb352f6bf6 100644 --- a/queries/zig.scm +++ b/queries/zig.scm @@ -23,7 +23,7 @@ ) @argumentOrParameter @_.domain . (_)? @_.trailing.startOf - ) @_dummy + ) (#not-type? @argumentOrParameter "comment") (#single-or-multi-line-delimiter! @argumentOrParameter @argumentOrParameter ", " ",\n") ) @@ -67,17 +67,17 @@ ;;!! foo(aaa, bbb); ;;! ^^^ ^^^ -( +(_ (arguments - (_)? @_.leading.endOf + (_)? @_.leading.endOf @argumentList.removal.start.endOf @argumentOrParameter.iteration.start.endOf . (_) @argumentOrParameter . - (_)? @_.trailing.startOf - ) + (_)? @_.trailing.startOf @argumentList.removal.end.startOf @argumentOrParameter.iteration.end.startOf + ) @argumentList (#not-type? @argumentOrParameter "comment") (#single-or-multi-line-delimiter! @argumentOrParameter @argumentOrParameter ", " ",\n") -) +) @argumentList.domain @argumentOrParameter.iteration.domain (statement) @statement From fa4bbcd162ca6aa550a09727d31069545874bfa7 Mon Sep 17 00:00:00 2001 From: Anthony Manning-Franklin Date: Mon, 22 Dec 2025 19:33:50 +0800 Subject: [PATCH 16/18] Remove unsupported scope files --- data/fixtures/scopes/zig/argument.actual.iteration.scope | 3 --- data/fixtures/scopes/zig/argumentList.actual.multiLine.scope | 5 ----- .../fixtures/scopes/zig/type.argument.formal.iteration.scope | 3 --- 3 files changed, 11 deletions(-) delete mode 100644 data/fixtures/scopes/zig/argument.actual.iteration.scope delete mode 100644 data/fixtures/scopes/zig/argumentList.actual.multiLine.scope delete mode 100644 data/fixtures/scopes/zig/type.argument.formal.iteration.scope diff --git a/data/fixtures/scopes/zig/argument.actual.iteration.scope b/data/fixtures/scopes/zig/argument.actual.iteration.scope deleted file mode 100644 index b7c21c7fb7..0000000000 --- a/data/fixtures/scopes/zig/argument.actual.iteration.scope +++ /dev/null @@ -1,3 +0,0 @@ -foo(aaa, bbb); ---- - diff --git a/data/fixtures/scopes/zig/argumentList.actual.multiLine.scope b/data/fixtures/scopes/zig/argumentList.actual.multiLine.scope deleted file mode 100644 index 6fbbfc8ef8..0000000000 --- a/data/fixtures/scopes/zig/argumentList.actual.multiLine.scope +++ /dev/null @@ -1,5 +0,0 @@ -foo( - aaa, - bbb -); ---- diff --git a/data/fixtures/scopes/zig/type.argument.formal.iteration.scope b/data/fixtures/scopes/zig/type.argument.formal.iteration.scope deleted file mode 100644 index 938fdc26aa..0000000000 --- a/data/fixtures/scopes/zig/type.argument.formal.iteration.scope +++ /dev/null @@ -1,3 +0,0 @@ -fn foo(aaa: u8, bbb: u8) void {} ---- - From 86f322e0921826c150e64fe59b0efcef92c88485 Mon Sep 17 00:00:00 2001 From: Anthony Manning-Franklin Date: Mon, 22 Dec 2025 19:44:31 +0800 Subject: [PATCH 17/18] Add zig language page to docs --- packages/cursorless-org-docs/src/docs/user/languages/zig.mdx | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 packages/cursorless-org-docs/src/docs/user/languages/zig.mdx diff --git a/packages/cursorless-org-docs/src/docs/user/languages/zig.mdx b/packages/cursorless-org-docs/src/docs/user/languages/zig.mdx new file mode 100644 index 0000000000..3ba35e47cc --- /dev/null +++ b/packages/cursorless-org-docs/src/docs/user/languages/zig.mdx @@ -0,0 +1,5 @@ +import { Language } from "./components/Language"; + +# Zig + + From 4d093f369cae806a6e93a7d2d75e0678369ca52c Mon Sep 17 00:00:00 2001 From: Anthony Manning-Franklin Date: Mon, 22 Dec 2025 20:06:42 +0800 Subject: [PATCH 18/18] Fix bug with argument actual --- queries/zig.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/queries/zig.scm b/queries/zig.scm index fb352f6bf6..0e8e4a41eb 100644 --- a/queries/zig.scm +++ b/queries/zig.scm @@ -60,7 +60,7 @@ (call_expression function: (_) @functionCallee (arguments - (_)* @argumentOrParameter + (_) @argumentOrParameter ) @argumentList (#child-range! @argumentList 1 -2) ) @functionCall @functionCallee.domain @argumentList.domain