Skip to content

Commit 706bb4c

Browse files
erasinwes-adams
authored andcommitted
Update highlights for golang (helix-editor#6204)
- update tree-sitter-go - refine keywords - set package as namespace - add label
1 parent 509db80 commit 706bb4c

File tree

2 files changed

+55
-22
lines changed

2 files changed

+55
-22
lines changed

languages.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ args = { mode = "local", processId = "{0}" }
324324

325325
[[grammar]]
326326
name = "go"
327-
source = { git = "https://github.com/tree-sitter/tree-sitter-go", rev = "05900faa3cdb5d2d8c8bd5e77ee698487e0a8611" }
327+
source = { git = "https://github.com/tree-sitter/tree-sitter-go", rev = "64457ea6b73ef5422ed1687178d4545c3e91334a" }
328328

329329
[[language]]
330330
name = "gomod"

runtime/queries/go/highlights.scm

+54-21
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
(method_declaration
2020
name: (field_identifier) @function.method)
2121

22+
(method_spec
23+
name: (field_identifier) @function.method)
24+
2225
; Identifiers
2326

2427
((identifier) @constant (match? @constant "^[A-Z][A-Z\\d_]+$"))
@@ -32,10 +35,19 @@
3235
(match? @type.builtin "^(any|bool|byte|comparable|complex128|complex64|error|float32|float64|int|int16|int32|int64|int8|rune|string|uint|uint16|uint32|uint64|uint8|uintptr)$"))
3336

3437
(type_identifier) @type
38+
(type_spec
39+
name: (type_identifier) @constructor)
3540
(field_identifier) @variable.other.member
3641
(identifier) @variable
37-
(package_identifier) @variable
42+
(package_identifier) @namespace
43+
44+
(parameter_declaration (identifier) @variable.parameter)
45+
(variadic_parameter_declaration (identifier) @variable.parameter)
3846

47+
(label_name) @label
48+
49+
(const_spec
50+
name: (identifier) @constant)
3951

4052
; Operators
4153

@@ -82,36 +94,57 @@
8294
; Keywords
8395

8496
[
85-
"break"
86-
"case"
87-
"chan"
88-
"const"
89-
"continue"
9097
"default"
91-
"defer"
98+
"type"
99+
] @keyword
100+
101+
[
102+
"if"
92103
"else"
93-
"fallthrough"
104+
"switch"
105+
"select"
106+
"case"
107+
] @keyword.control.conditional
108+
109+
[
94110
"for"
95-
"func"
96-
"go"
97-
"goto"
98-
"if"
99-
"interface"
100-
"map"
101111
"range"
102-
"return"
103-
"select"
104-
"struct"
105-
"switch"
106-
"type"
107-
"var"
108-
] @keyword
112+
] @keyword.control.repeat
109113

110114
[
111115
"import"
112116
"package"
113117
] @keyword.control.import
114118

119+
[
120+
"return"
121+
"continue"
122+
"break"
123+
"fallthrough"
124+
] @keyword.control.return
125+
126+
[
127+
"func"
128+
] @keyword.function
129+
130+
[
131+
"var"
132+
"chan"
133+
"interface"
134+
"map"
135+
"struct"
136+
] @keyword.storage.type
137+
138+
[
139+
"const"
140+
] @keyword.storage.modifier
141+
142+
[
143+
"defer"
144+
"goto"
145+
"go"
146+
] @function.macro
147+
115148
; Delimiters
116149

117150
[

0 commit comments

Comments
 (0)