@willbooster/tree-sitter-go 0.0.0-stage → 2.0.0
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/LICENSE +22 -0
- package/README.md +131 -2
- package/grammar.js +983 -0
- package/package.json +73 -4
- package/queries/highlights.scm +123 -0
- package/queries/tags.scm +42 -0
- package/src/node-types.json +3065 -0
- package/tree-sitter-go.wasm +0 -0
- package/tree-sitter.json +39 -0
package/package.json
CHANGED
|
@@ -1,6 +1,75 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@willbooster/tree-sitter-go",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Go grammar for tree-sitter",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"incremental",
|
|
7
|
+
"parsing",
|
|
8
|
+
"tree-sitter",
|
|
9
|
+
"go"
|
|
10
|
+
],
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/WillBooster/tree-sitter-go.git"
|
|
14
|
+
},
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"author": "WillBooster Inc.",
|
|
17
|
+
"files": [
|
|
18
|
+
"grammar.js",
|
|
19
|
+
"queries/*.scm",
|
|
20
|
+
"src/node-types.json",
|
|
21
|
+
"tree-sitter.json",
|
|
22
|
+
"*.wasm"
|
|
23
|
+
],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build-wasm": "script/generate --build-wasm",
|
|
26
|
+
"build/ci": "bun run build-wasm",
|
|
27
|
+
"cleanup": "bun wb lint --fix --format",
|
|
28
|
+
"format": "bun wb lint --format",
|
|
29
|
+
"generate": "script/generate",
|
|
30
|
+
"lint": "bun wb lint",
|
|
31
|
+
"lint-fix": "bun wb lint --fix",
|
|
32
|
+
"prepare": "(bun lefthook install || true) && (test ! -f .lefthook/normalize-bun-lockfile.sh || bash .lefthook/normalize-bun-lockfile.sh)",
|
|
33
|
+
"release": "wb release",
|
|
34
|
+
"prestart": "bun run build-wasm",
|
|
35
|
+
"start": "script/tree-sitter playground",
|
|
36
|
+
"test": "bun wb test",
|
|
37
|
+
"test/ci": "bun wb test-on-ci",
|
|
38
|
+
"test/ci-setup": "playwright install --with-deps chromium",
|
|
39
|
+
"typecheck": "bun wb typecheck",
|
|
40
|
+
"verify": "bun wb verify",
|
|
41
|
+
"verify-full": "bun wb verify --full"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@tsconfig/bun": "1.0.11",
|
|
45
|
+
"@types/bun": "1.4.2",
|
|
46
|
+
"@vitest/browser-playwright": "5.0.3",
|
|
47
|
+
"@willbooster/oxfmt-config": "1.2.2",
|
|
48
|
+
"@willbooster/oxlint-config": "1.4.8",
|
|
49
|
+
"@willbooster/wb": "22.24.0",
|
|
50
|
+
"@willbooster/web-tree-sitter": "2.0.1",
|
|
51
|
+
"conventional-changelog-conventionalcommits": "10.4.0",
|
|
52
|
+
"lefthook": "2.1.16",
|
|
53
|
+
"oxfmt": "0.71.0",
|
|
54
|
+
"oxlint": "1.86.0",
|
|
55
|
+
"oxlint-tsgolint": "7.0.2003",
|
|
56
|
+
"playwright": "1.63.0",
|
|
57
|
+
"semantic-release": "25.0.9",
|
|
58
|
+
"sort-package-json": "4.0.0",
|
|
59
|
+
"typescript": "7.0.2",
|
|
60
|
+
"vitest": "5.0.3",
|
|
61
|
+
"wrangler": "4.147.0"
|
|
62
|
+
},
|
|
63
|
+
"peerDependencies": {
|
|
64
|
+
"@willbooster/web-tree-sitter": "^2.0.0"
|
|
65
|
+
},
|
|
66
|
+
"peerDependenciesMeta": {
|
|
67
|
+
"@willbooster/web-tree-sitter": {
|
|
68
|
+
"optional": true
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
"publishConfig": {
|
|
72
|
+
"access": "public",
|
|
73
|
+
"registry": "https://registry.npmjs.org/"
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
; Function calls
|
|
2
|
+
|
|
3
|
+
(call_expression
|
|
4
|
+
function: (identifier) @function)
|
|
5
|
+
|
|
6
|
+
(call_expression
|
|
7
|
+
function: (identifier) @function.builtin
|
|
8
|
+
(#match? @function.builtin "^(append|cap|close|complex|copy|delete|imag|len|make|new|panic|print|println|real|recover)$"))
|
|
9
|
+
|
|
10
|
+
(call_expression
|
|
11
|
+
function: (selector_expression
|
|
12
|
+
field: (field_identifier) @function.method))
|
|
13
|
+
|
|
14
|
+
; Function definitions
|
|
15
|
+
|
|
16
|
+
(function_declaration
|
|
17
|
+
name: (identifier) @function)
|
|
18
|
+
|
|
19
|
+
(method_declaration
|
|
20
|
+
name: (field_identifier) @function.method)
|
|
21
|
+
|
|
22
|
+
; Identifiers
|
|
23
|
+
|
|
24
|
+
(type_identifier) @type
|
|
25
|
+
(field_identifier) @property
|
|
26
|
+
(identifier) @variable
|
|
27
|
+
|
|
28
|
+
; Operators
|
|
29
|
+
|
|
30
|
+
[
|
|
31
|
+
"--"
|
|
32
|
+
"-"
|
|
33
|
+
"-="
|
|
34
|
+
":="
|
|
35
|
+
"!"
|
|
36
|
+
"!="
|
|
37
|
+
"..."
|
|
38
|
+
"*"
|
|
39
|
+
"*"
|
|
40
|
+
"*="
|
|
41
|
+
"/"
|
|
42
|
+
"/="
|
|
43
|
+
"&"
|
|
44
|
+
"&&"
|
|
45
|
+
"&="
|
|
46
|
+
"%"
|
|
47
|
+
"%="
|
|
48
|
+
"^"
|
|
49
|
+
"^="
|
|
50
|
+
"+"
|
|
51
|
+
"++"
|
|
52
|
+
"+="
|
|
53
|
+
"<-"
|
|
54
|
+
"<"
|
|
55
|
+
"<<"
|
|
56
|
+
"<<="
|
|
57
|
+
"<="
|
|
58
|
+
"="
|
|
59
|
+
"=="
|
|
60
|
+
">"
|
|
61
|
+
">="
|
|
62
|
+
">>"
|
|
63
|
+
">>="
|
|
64
|
+
"|"
|
|
65
|
+
"|="
|
|
66
|
+
"||"
|
|
67
|
+
"~"
|
|
68
|
+
] @operator
|
|
69
|
+
|
|
70
|
+
; Keywords
|
|
71
|
+
|
|
72
|
+
[
|
|
73
|
+
"break"
|
|
74
|
+
"case"
|
|
75
|
+
"chan"
|
|
76
|
+
"const"
|
|
77
|
+
"continue"
|
|
78
|
+
"default"
|
|
79
|
+
"defer"
|
|
80
|
+
"else"
|
|
81
|
+
"fallthrough"
|
|
82
|
+
"for"
|
|
83
|
+
"func"
|
|
84
|
+
"go"
|
|
85
|
+
"goto"
|
|
86
|
+
"if"
|
|
87
|
+
"import"
|
|
88
|
+
"interface"
|
|
89
|
+
"map"
|
|
90
|
+
"package"
|
|
91
|
+
"range"
|
|
92
|
+
"return"
|
|
93
|
+
"select"
|
|
94
|
+
"struct"
|
|
95
|
+
"switch"
|
|
96
|
+
"type"
|
|
97
|
+
"var"
|
|
98
|
+
] @keyword
|
|
99
|
+
|
|
100
|
+
; Literals
|
|
101
|
+
|
|
102
|
+
[
|
|
103
|
+
(interpreted_string_literal)
|
|
104
|
+
(raw_string_literal)
|
|
105
|
+
(rune_literal)
|
|
106
|
+
] @string
|
|
107
|
+
|
|
108
|
+
(escape_sequence) @escape
|
|
109
|
+
|
|
110
|
+
[
|
|
111
|
+
(int_literal)
|
|
112
|
+
(float_literal)
|
|
113
|
+
(imaginary_literal)
|
|
114
|
+
] @number
|
|
115
|
+
|
|
116
|
+
[
|
|
117
|
+
(true)
|
|
118
|
+
(false)
|
|
119
|
+
(nil)
|
|
120
|
+
(iota)
|
|
121
|
+
] @constant.builtin
|
|
122
|
+
|
|
123
|
+
(comment) @comment
|
package/queries/tags.scm
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
(
|
|
2
|
+
(comment)* @doc
|
|
3
|
+
.
|
|
4
|
+
(function_declaration
|
|
5
|
+
name: (identifier) @name) @definition.function
|
|
6
|
+
(#strip! @doc "^//\\s*")
|
|
7
|
+
(#set-adjacent! @doc @definition.function)
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
(
|
|
11
|
+
(comment)* @doc
|
|
12
|
+
.
|
|
13
|
+
(method_declaration
|
|
14
|
+
name: (field_identifier) @name) @definition.method
|
|
15
|
+
(#strip! @doc "^//\\s*")
|
|
16
|
+
(#set-adjacent! @doc @definition.method)
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
(call_expression
|
|
20
|
+
function: [
|
|
21
|
+
(identifier) @name
|
|
22
|
+
(parenthesized_expression (identifier) @name)
|
|
23
|
+
(selector_expression field: (field_identifier) @name)
|
|
24
|
+
(parenthesized_expression (selector_expression field: (field_identifier) @name))
|
|
25
|
+
]) @reference.call
|
|
26
|
+
|
|
27
|
+
(type_spec
|
|
28
|
+
name: (type_identifier) @name) @definition.type
|
|
29
|
+
|
|
30
|
+
(type_identifier) @name @reference.type
|
|
31
|
+
|
|
32
|
+
(package_clause "package" (package_identifier) @name)
|
|
33
|
+
|
|
34
|
+
(type_declaration (type_spec name: (type_identifier) @name type: (interface_type)))
|
|
35
|
+
|
|
36
|
+
(type_declaration (type_spec name: (type_identifier) @name type: (struct_type)))
|
|
37
|
+
|
|
38
|
+
(import_declaration (import_spec) @name)
|
|
39
|
+
|
|
40
|
+
(var_declaration (var_spec name: (identifier) @name))
|
|
41
|
+
|
|
42
|
+
(const_declaration (const_spec name: (identifier) @name))
|