From 04040c61c7c0c6da77dd87426c68f0afb8344b97 Mon Sep 17 00:00:00 2001 From: Stephan Seitz Date: Sun, 31 May 2020 23:32:08 +0200 Subject: [PATCH] Add highlights.scm for Go --- README.md | 2 +- queries/go/highlights.scm | 136 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 queries/go/highlights.scm diff --git a/README.md b/README.md index 970eee60a..6379273ac 100644 --- a/README.md +++ b/README.md @@ -155,7 +155,7 @@ List of currently supported languages: - [x] lua (maintained by @vigoux) - [x] ruby (maintained by @TravonteD) - [x] c (maintained by @vigoux) -- [ ] go +- [x] go (maintained by @theHamsta) - [ ] cpp - [ ] rust - [x] python (maintained by @theHamsta) diff --git a/queries/go/highlights.scm b/queries/go/highlights.scm new file mode 100644 index 000000000..ed046e6d0 --- /dev/null +++ b/queries/go/highlights.scm @@ -0,0 +1,136 @@ +;; Forked from tree-sitter-go +;; Copyright (c) 2014 Max Brunsfeld (The MIT License) + +;; +; Function calls + +(call_expression + function: (identifier) @function) + +(call_expression + function: (selector_expression + field: (field_identifier) @method)) + +; Function definitions + +(function_declaration + name: (identifier) @function) + +(method_declaration + name: (field_identifier) @method) + +; Identifiers + +(type_identifier) @type +(field_identifier) @property +(identifier) @variable + +(parameter_declaration (identifier) @parameter) +(variadic_parameter_declaration (identifier) @parameter) + +((identifier) @constant + (#eq? @constant "_")) + +((identifier) @constant + (#match? @constant "^[A-Z][A-Z\\d_]+$")) + +; Operators + +"--" @operator +"-" @operator +"-=" @operator +":=" @operator +"!" @operator +"!=" @operator +"..." @operator +"*" @operator +"*" @operator +"*=" @operator +"/" @operator +"/=" @operator +"&" @operator +"&&" @operator +"&=" @operator +"%" @operator +"%=" @operator +"^" @operator +"^=" @operator +"+" @operator +"++" @operator +"+=" @operator +"<-" @operator +"<" @operator +"<<" @operator +"<<=" @operator +"<=" @operator +"=" @operator +"==" @operator +">" @operator +">=" @operator +">>" @operator +">>=" @operator +"|" @operator +"|=" @operator +"||" @operator + +; Keywords + +"break" @keyword +"case" @conditional +"chan" @keyword +"const" @keyword +"continue" @keyword +"default" @keyword +"defer" @keyword +"else" @conditional +"fallthrough" @keyword +"for" @repeat +"func" @keyword +"go" @keyword +"goto" @keyword +"if" @conditional +"import" @include +"interface" @keyword +"map" @keyword +"package" @include +"range" @keyword +"return" @keyword +"select" @keyword +"struct" @keyword +"switch" @conditional +"type" @keyword +"var" @keyword + +; 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) @escape + +(int_literal) @number +(float_literal) @float +(imaginary_literal) @number + +(true) @boolean +(false) @boolean +(nil) @constant.builtin + +(comment) @comment + +(ERROR) @error