2021-04-09 12:42:49 +04:00
|
|
|
; Function calls
|
|
|
|
|
2022-12-05 19:16:25 +04:00
|
|
|
(call_expression
|
|
|
|
function: (identifier) @function.builtin
|
2024-03-17 19:43:35 +04:00
|
|
|
(#match? @function.builtin "^(append|cap|close|complex|copy|delete|imag|len|make|new|panic|print|println|real|recover)$"))
|
2022-12-05 19:16:25 +04:00
|
|
|
|
2021-04-09 12:42:49 +04:00
|
|
|
(call_expression
|
|
|
|
function: (identifier) @function)
|
|
|
|
|
|
|
|
(call_expression
|
|
|
|
function: (selector_expression
|
|
|
|
field: (field_identifier) @function.method))
|
|
|
|
|
2023-11-06 05:54:25 +04:00
|
|
|
|
|
|
|
; Types
|
|
|
|
|
|
|
|
(type_parameter_list
|
|
|
|
(parameter_declaration
|
|
|
|
name: (identifier) @type.parameter))
|
|
|
|
|
|
|
|
((type_identifier) @type.builtin
|
2024-03-17 19:43:35 +04:00
|
|
|
(#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)$"))
|
2023-11-06 05:54:25 +04:00
|
|
|
|
|
|
|
(type_identifier) @type
|
|
|
|
|
2021-04-09 12:42:49 +04:00
|
|
|
; Function definitions
|
|
|
|
|
|
|
|
(function_declaration
|
|
|
|
name: (identifier) @function)
|
|
|
|
|
|
|
|
(method_declaration
|
|
|
|
name: (field_identifier) @function.method)
|
|
|
|
|
2023-03-08 04:33:13 +04:00
|
|
|
(method_spec
|
|
|
|
name: (field_identifier) @function.method)
|
|
|
|
|
2021-04-09 12:42:49 +04:00
|
|
|
; Identifiers
|
|
|
|
|
2021-09-02 10:11:45 +04:00
|
|
|
(const_spec
|
|
|
|
name: (identifier) @constant)
|
|
|
|
|
2021-09-06 13:13:52 +04:00
|
|
|
(parameter_declaration (identifier) @variable.parameter)
|
|
|
|
(variadic_parameter_declaration (identifier) @variable.parameter)
|
|
|
|
|
2023-03-08 04:33:13 +04:00
|
|
|
(type_spec
|
|
|
|
name: (type_identifier) @constructor)
|
2021-11-03 07:00:52 +04:00
|
|
|
(field_identifier) @variable.other.member
|
2023-09-26 20:05:42 +04:00
|
|
|
(keyed_element (literal_element (identifier) @variable.other.member))
|
2021-04-09 12:42:49 +04:00
|
|
|
(identifier) @variable
|
2023-03-08 04:33:13 +04:00
|
|
|
(package_identifier) @namespace
|
|
|
|
|
|
|
|
(parameter_declaration (identifier) @variable.parameter)
|
|
|
|
(variadic_parameter_declaration (identifier) @variable.parameter)
|
2021-09-02 10:11:45 +04:00
|
|
|
|
2023-03-08 04:33:13 +04:00
|
|
|
(label_name) @label
|
|
|
|
|
|
|
|
(const_spec
|
|
|
|
name: (identifier) @constant)
|
2021-04-09 12:42:49 +04:00
|
|
|
|
|
|
|
; Operators
|
|
|
|
|
|
|
|
[
|
|
|
|
"--"
|
|
|
|
"-"
|
|
|
|
"-="
|
|
|
|
":="
|
|
|
|
"!"
|
|
|
|
"!="
|
|
|
|
"..."
|
|
|
|
"*"
|
|
|
|
"*"
|
|
|
|
"*="
|
|
|
|
"/"
|
|
|
|
"/="
|
|
|
|
"&"
|
|
|
|
"&&"
|
|
|
|
"&="
|
|
|
|
"%"
|
|
|
|
"%="
|
|
|
|
"^"
|
|
|
|
"^="
|
|
|
|
"+"
|
|
|
|
"++"
|
|
|
|
"+="
|
|
|
|
"<-"
|
|
|
|
"<"
|
|
|
|
"<<"
|
|
|
|
"<<="
|
|
|
|
"<="
|
|
|
|
"="
|
|
|
|
"=="
|
|
|
|
">"
|
|
|
|
">="
|
|
|
|
">>"
|
|
|
|
">>="
|
|
|
|
"|"
|
|
|
|
"|="
|
|
|
|
"||"
|
2022-01-11 14:10:02 +04:00
|
|
|
"~"
|
2021-04-09 12:42:49 +04:00
|
|
|
] @operator
|
|
|
|
|
|
|
|
; Keywords
|
|
|
|
|
|
|
|
[
|
|
|
|
"default"
|
2023-03-08 04:33:13 +04:00
|
|
|
"type"
|
|
|
|
] @keyword
|
|
|
|
|
|
|
|
[
|
|
|
|
"if"
|
2021-04-09 12:42:49 +04:00
|
|
|
"else"
|
2023-03-08 04:33:13 +04:00
|
|
|
"switch"
|
|
|
|
"select"
|
|
|
|
"case"
|
|
|
|
] @keyword.control.conditional
|
|
|
|
|
|
|
|
[
|
2021-04-09 12:42:49 +04:00
|
|
|
"for"
|
|
|
|
"range"
|
2023-03-08 04:33:13 +04:00
|
|
|
] @keyword.control.repeat
|
2021-04-09 12:42:49 +04:00
|
|
|
|
2021-09-02 10:11:45 +04:00
|
|
|
[
|
|
|
|
"import"
|
|
|
|
"package"
|
|
|
|
] @keyword.control.import
|
|
|
|
|
2023-03-08 04:33:13 +04:00
|
|
|
[
|
|
|
|
"return"
|
|
|
|
"continue"
|
|
|
|
"break"
|
|
|
|
"fallthrough"
|
|
|
|
] @keyword.control.return
|
|
|
|
|
|
|
|
[
|
|
|
|
"func"
|
|
|
|
] @keyword.function
|
|
|
|
|
|
|
|
[
|
|
|
|
"var"
|
|
|
|
"chan"
|
|
|
|
"interface"
|
|
|
|
"map"
|
|
|
|
"struct"
|
|
|
|
] @keyword.storage.type
|
|
|
|
|
|
|
|
[
|
|
|
|
"const"
|
|
|
|
] @keyword.storage.modifier
|
|
|
|
|
|
|
|
[
|
|
|
|
"defer"
|
|
|
|
"goto"
|
|
|
|
"go"
|
|
|
|
] @function.macro
|
|
|
|
|
2021-09-02 10:11:45 +04:00
|
|
|
; Delimiters
|
|
|
|
|
|
|
|
[
|
|
|
|
":"
|
|
|
|
"."
|
|
|
|
","
|
|
|
|
";"
|
|
|
|
] @punctuation.delimiter
|
|
|
|
|
|
|
|
[
|
|
|
|
"("
|
|
|
|
")"
|
|
|
|
"["
|
|
|
|
"]"
|
|
|
|
"{"
|
|
|
|
"}"
|
|
|
|
] @punctuation.bracket
|
|
|
|
|
2021-04-09 12:42:49 +04:00
|
|
|
; Literals
|
|
|
|
|
|
|
|
[
|
|
|
|
(interpreted_string_literal)
|
|
|
|
(raw_string_literal)
|
|
|
|
(rune_literal)
|
|
|
|
] @string
|
|
|
|
|
2021-11-03 07:00:52 +04:00
|
|
|
(escape_sequence) @constant.character.escape
|
2021-04-09 12:42:49 +04:00
|
|
|
|
|
|
|
[
|
|
|
|
(int_literal)
|
2024-02-06 04:55:56 +04:00
|
|
|
] @constant.numeric.integer
|
|
|
|
|
|
|
|
[
|
2021-04-09 12:42:49 +04:00
|
|
|
(float_literal)
|
|
|
|
(imaginary_literal)
|
2024-02-06 04:55:56 +04:00
|
|
|
] @constant.numeric.float
|
2021-04-09 12:42:49 +04:00
|
|
|
|
|
|
|
[
|
|
|
|
(true)
|
|
|
|
(false)
|
2021-09-02 10:11:45 +04:00
|
|
|
] @constant.builtin.boolean
|
|
|
|
|
2022-01-11 14:10:02 +04:00
|
|
|
[
|
|
|
|
(nil)
|
|
|
|
(iota)
|
|
|
|
] @constant.builtin
|
2021-04-09 12:42:49 +04:00
|
|
|
|
2024-02-06 04:55:56 +04:00
|
|
|
; Comments
|
|
|
|
|
2021-04-09 12:42:49 +04:00
|
|
|
(comment) @comment
|
2024-02-06 04:55:56 +04:00
|
|
|
|
|
|
|
; Doc Comments
|
|
|
|
(source_file
|
|
|
|
.
|
|
|
|
(comment)+ @comment.block.documentation)
|
|
|
|
|
|
|
|
(source_file
|
|
|
|
(comment)+ @comment.block.documentation
|
|
|
|
.
|
|
|
|
(const_declaration))
|
|
|
|
|
|
|
|
(source_file
|
|
|
|
(comment)+ @comment.block.documentation
|
|
|
|
.
|
|
|
|
(function_declaration))
|
|
|
|
|
|
|
|
(source_file
|
|
|
|
(comment)+ @comment.block.documentation
|
|
|
|
.
|
|
|
|
(type_declaration))
|
|
|
|
|
|
|
|
(source_file
|
|
|
|
(comment)+ @comment.block.documentation
|
|
|
|
.
|
|
|
|
(var_declaration))
|