diff options
| author | Thomas Vigouroux <39092278+vigoux@users.noreply.github.com> | 2020-06-07 13:58:38 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-07 13:58:38 +0200 |
| commit | 85645f5720ec357a1eac9521dba71605e01de961 (patch) | |
| tree | 158bed5ff72a5189f85539a9817fe41497988eb0 | |
| parent | Merge pull request #75 from theHamsta/html-quoted_attribute_value (diff) | |
| parent | Update CONTRIBUTING.md for @doc (diff) | |
| download | nvim-treesitter-85645f5720ec357a1eac9521dba71605e01de961.tar nvim-treesitter-85645f5720ec357a1eac9521dba71605e01de961.tar.gz nvim-treesitter-85645f5720ec357a1eac9521dba71605e01de961.tar.bz2 nvim-treesitter-85645f5720ec357a1eac9521dba71605e01de961.tar.lz nvim-treesitter-85645f5720ec357a1eac9521dba71605e01de961.tar.xz nvim-treesitter-85645f5720ec357a1eac9521dba71605e01de961.tar.zst nvim-treesitter-85645f5720ec357a1eac9521dba71605e01de961.zip | |
Merge pull request #69 from theHamsta/go-highlights
Go highlights
| -rw-r--r-- | CONTRIBUTING.md | 7 | ||||
| -rw-r--r-- | README.md | 2 | ||||
| -rw-r--r-- | queries/go/highlights.scm | 136 | ||||
| -rw-r--r-- | queries/go/locals.scm | 60 |
4 files changed, 204 insertions, 1 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ea31f573e..5a8c74ee6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -94,6 +94,13 @@ are optional and will not have any effect for now. `macro` `type` `field` + `doc` for documentation adjecent to a definition. E.g. + +```scheme + (comment)* @definition.doc + (method_declaration + name: (field_identifier) @definition.method) +``` `@scope` @@ -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 diff --git a/queries/go/locals.scm b/queries/go/locals.scm new file mode 100644 index 000000000..f9d0af3b1 --- /dev/null +++ b/queries/go/locals.scm @@ -0,0 +1,60 @@ +( + (comment)* @definition.doc + (function_declaration + name: (identifier) @definition.function) ;@function + (#strip! @definition.doc "^//\\s*") ; <- does nothing at the moment +) + +( + (comment)* @definition.doc + (method_declaration + name: (field_identifier) @definition.method); @method + (#strip! @definition.doc "^//\\s*") ; <- does nothing at the moment +) + + +(short_var_declaration + left: (expression_list + (identifier) @definition.var)) + +(var_spec + name: (identifier) @definition.var) + +(parameter_declaration (identifier) @definition.var) +(variadic_parameter_declaration (identifier) @definition.var) + +(type_declaration + (type_spec + name: (type_identifier) @definition.type)) + +;; reference +(identifier) @reference +(type_identifier) @reference +(field_identifier) @reference + +;; Call references +(call_expression + function: (identifier) @reference.call) @call + +(call_expression + function: (selector_expression + field: (field_identifier) @reference.call)) @call + +(call_expression + function: (parenthesized_expression + (identifier) @reference.call)) @call + +(call_expression + function: (parenthesized_expression + (selector_expression + field: (field_identifier) @reference.call))) @call + +;; Scopes + +(source_file) @scope +(function_declaration) @scope +(if_statement) @scope +(block) @scope +(expression_switch_statement) @scope +(for_statement) @scope +(method_declaration) @scope |
