Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'runtime/queries/go/highlights.scm')
| -rw-r--r-- | runtime/queries/go/highlights.scm | 159 |
1 files changed, 41 insertions, 118 deletions
diff --git a/runtime/queries/go/highlights.scm b/runtime/queries/go/highlights.scm index be9efeac..927bd95b 100644 --- a/runtime/queries/go/highlights.scm +++ b/runtime/queries/go/highlights.scm @@ -1,54 +1,16 @@ - -; Identifiers - -(field_identifier) @variable.other.member - -(identifier) @variable - -(package_identifier) @namespace - -(const_spec - name: (identifier) @constant) - -(type_spec - name: (type_identifier) @constructor) - -(keyed_element . (literal_element (identifier) @variable.other.member)) -(field_declaration - name: (field_identifier) @variable.other.member) - -(parameter_declaration (identifier) @variable.parameter) -(variadic_parameter_declaration (identifier) @variable.parameter) - -(label_name) @label - -(const_spec - name: (identifier) @constant) - ; Function calls (call_expression + function: (identifier) @function.builtin + (match? @function.builtin "^(append|cap|close|complex|copy|delete|imag|len|make|new|panic|print|println|real|recover)$")) + +(call_expression function: (identifier) @function) (call_expression function: (selector_expression field: (field_identifier) @function.method)) -(call_expression - function: (identifier) @function.builtin - (#match? @function.builtin "^(append|cap|close|complex|copy|delete|imag|len|make|new|panic|print|println|real|recover|min|max|clear)$")) - -; Types - -(type_identifier) @type - -(type_parameter_list - (type_parameter_declaration - name: (identifier) @type.parameter)) - -((type_identifier) @type.builtin - (#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)$")) - ; Function definitions (function_declaration @@ -57,8 +19,23 @@ (method_declaration name: (field_identifier) @function.method) -(method_elem - name: (field_identifier) @function.method) +; Identifiers + +((identifier) @constant (match? @constant "^[A-Z][A-Z\\d_]+$")) +(const_spec + name: (identifier) @constant) + +(parameter_declaration (identifier) @variable.parameter) +(variadic_parameter_declaration (identifier) @variable.parameter) + +((type_identifier) @type.builtin + (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)$")) + +(type_identifier) @type +(field_identifier) @variable.other.member +(identifier) @variable +(package_identifier) @variable + ; Operators @@ -99,65 +76,42 @@ "|" "|=" "||" - "&^" - "&^=" "~" ] @operator ; Keywords [ + "break" + "case" + "chan" + "const" + "continue" "default" - "type" -] @keyword - -[ "defer" + "else" + "fallthrough" + "for" + "func" "go" "goto" -] @keyword.control - -[ "if" - "else" - "switch" - "select" - "case" -] @keyword.control.conditional - -[ - "for" + "interface" + "map" "range" -] @keyword.control.repeat + "return" + "select" + "struct" + "switch" + "type" + "var" +] @keyword [ "import" "package" ] @keyword.control.import -[ - "return" - "continue" - "break" - "fallthrough" -] @keyword.control.return - -[ - "func" -] @keyword.function - -[ - "var" - "chan" - "interface" - "map" - "struct" -] @keyword.storage.type - -[ - "const" -] @keyword.storage.modifier - ; Delimiters [ @@ -181,20 +135,16 @@ [ (interpreted_string_literal) (raw_string_literal) + (rune_literal) ] @string -(rune_literal) @constant.character - (escape_sequence) @constant.character.escape [ (int_literal) -] @constant.numeric.integer - -[ (float_literal) (imaginary_literal) -] @constant.numeric.float +] @constant.numeric.integer [ (true) @@ -206,31 +156,4 @@ (iota) ] @constant.builtin -; Comments - (comment) @comment - -; 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)) |