aboutsummaryrefslogtreecommitdiffstats
path: root/runtime/queries/go/highlights.scm
diff options
context:
space:
mode:
authorChristian Clason <c.clason@uni-graz.at>2023-06-12 09:54:30 -0600
committerChristian Clason <c.clason@uni-graz.at>2025-05-12 18:43:40 +0200
commit692b051b09935653befdb8f7ba8afdb640adf17b (patch)
tree167162b6b129ae04f68c5735078521a72917c742 /runtime/queries/go/highlights.scm
parentfeat(c-family): inherit injections (diff)
downloadnvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar
nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.gz
nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.bz2
nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.lz
nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.xz
nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.tar.zst
nvim-treesitter-692b051b09935653befdb8f7ba8afdb640adf17b.zip
feat!: drop modules, general refactor and cleanup
Diffstat (limited to 'runtime/queries/go/highlights.scm')
-rw-r--r--runtime/queries/go/highlights.scm254
1 files changed, 254 insertions, 0 deletions
diff --git a/runtime/queries/go/highlights.scm b/runtime/queries/go/highlights.scm
new file mode 100644
index 000000000..7675cb790
--- /dev/null
+++ b/runtime/queries/go/highlights.scm
@@ -0,0 +1,254 @@
+; Forked from tree-sitter-go
+; Copyright (c) 2014 Max Brunsfeld (The MIT License)
+;
+; Identifiers
+(type_identifier) @type
+
+(type_spec
+ name: (type_identifier) @type.definition)
+
+(field_identifier) @property
+
+(identifier) @variable
+
+(package_identifier) @module
+
+(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.call)
+
+(call_expression
+ function: (selector_expression
+ field: (field_identifier) @function.method.call))
+
+; Function definitions
+(function_declaration
+ name: (identifier) @function)
+
+(method_declaration
+ name: (field_identifier) @function.method)
+
+(method_elem
+ name: (field_identifier) @function.method)
+
+; Constructors
+((call_expression
+ (identifier) @constructor)
+ (#lua-match? @constructor "^[nN]ew.+$"))
+
+((call_expression
+ (identifier) @constructor)
+ (#lua-match? @constructor "^[mM]ake.+$"))
+
+; Operators
+[
+ "--"
+ "-"
+ "-="
+ ":="
+ "!"
+ "!="
+ "..."
+ "*"
+ "*"
+ "*="
+ "/"
+ "/="
+ "&"
+ "&&"
+ "&="
+ "&^"
+ "&^="
+ "%"
+ "%="
+ "^"
+ "^="
+ "+"
+ "++"
+ "+="
+ "<-"
+ "<"
+ "<<"
+ "<<="
+ "<="
+ "="
+ "=="
+ ">"
+ ">="
+ ">>"
+ ">>="
+ "|"
+ "|="
+ "||"
+ "~"
+] @operator
+
+; Keywords
+[
+ "break"
+ "const"
+ "continue"
+ "default"
+ "defer"
+ "goto"
+ "range"
+ "select"
+ "var"
+ "fallthrough"
+] @keyword
+
+[
+ "type"
+ "struct"
+ "interface"
+] @keyword.type
+
+"func" @keyword.function
+
+"return" @keyword.return
+
+"go" @keyword.coroutine
+
+"for" @keyword.repeat
+
+[
+ "import"
+ "package"
+] @keyword.import
+
+[
+ "else"
+ "case"
+ "switch"
+ "if"
+] @keyword.conditional
+
+; Builtin types
+[
+ "chan"
+ "map"
+] @type.builtin
+
+((type_identifier) @type.builtin
+ (#any-of? @type.builtin
+ "any" "bool" "byte" "comparable" "complex128" "complex64" "error" "float32" "float64" "int"
+ "int16" "int32" "int64" "int8" "rune" "string" "uint" "uint16" "uint32" "uint64" "uint8"
+ "uintptr"))
+
+; Builtin functions
+((identifier) @function.builtin
+ (#any-of? @function.builtin
+ "append" "cap" "clear" "close" "complex" "copy" "delete" "imag" "len" "make" "max" "min" "new"
+ "panic" "print" "println" "real" "recover"))
+
+; Delimiters
+"." @punctuation.delimiter
+
+"," @punctuation.delimiter
+
+":" @punctuation.delimiter
+
+";" @punctuation.delimiter
+
+"(" @punctuation.bracket
+
+")" @punctuation.bracket
+
+"{" @punctuation.bracket
+
+"}" @punctuation.bracket
+
+"[" @punctuation.bracket
+
+"]" @punctuation.bracket
+
+; Literals
+(interpreted_string_literal) @string
+
+(raw_string_literal) @string
+
+(rune_literal) @string
+
+(escape_sequence) @string.escape
+
+(int_literal) @number
+
+(float_literal) @number.float
+
+(imaginary_literal) @number
+
+[
+ (true)
+ (false)
+] @boolean
+
+[
+ (nil)
+ (iota)
+] @constant.builtin
+
+(keyed_element
+ .
+ (literal_element
+ (identifier) @variable.member))
+
+(field_declaration
+ name: (field_identifier) @variable.member)
+
+; Comments
+(comment) @comment @spell
+
+; Doc Comments
+(source_file
+ .
+ (comment)+ @comment.documentation)
+
+(source_file
+ (comment)+ @comment.documentation
+ .
+ (const_declaration))
+
+(source_file
+ (comment)+ @comment.documentation
+ .
+ (function_declaration))
+
+(source_file
+ (comment)+ @comment.documentation
+ .
+ (type_declaration))
+
+(source_file
+ (comment)+ @comment.documentation
+ .
+ (var_declaration))
+
+; Spell
+((interpreted_string_literal) @spell
+ (#not-has-parent? @spell import_spec))
+
+; Regex
+(call_expression
+ (selector_expression) @_function
+ (#any-of? @_function
+ "regexp.Match" "regexp.MatchReader" "regexp.MatchString" "regexp.Compile" "regexp.CompilePOSIX"
+ "regexp.MustCompile" "regexp.MustCompilePOSIX")
+ (argument_list
+ .
+ [
+ (raw_string_literal
+ (raw_string_literal_content) @string.regexp)
+ (interpreted_string_literal
+ (interpreted_string_literal_content) @string.regexp)
+ ]))