mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-05 21:10:15 -04:00
feat!: drop modules, general refactor and cleanup
This commit is contained in:
parent
c13e28f894
commit
2c8f2f2fad
829 changed files with 4905 additions and 8010 deletions
20
runtime/queries/go/folds.scm
Normal file
20
runtime/queries/go/folds.scm
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
[
|
||||
(const_declaration)
|
||||
(expression_switch_statement)
|
||||
(expression_case)
|
||||
(default_case)
|
||||
(type_switch_statement)
|
||||
(type_case)
|
||||
(for_statement)
|
||||
(func_literal)
|
||||
(function_declaration)
|
||||
(if_statement)
|
||||
(import_declaration)
|
||||
(method_declaration)
|
||||
(type_declaration)
|
||||
(var_declaration)
|
||||
(composite_literal)
|
||||
(literal_element)
|
||||
(block)
|
||||
] @fold
|
||||
|
||||
255
runtime/queries/go/highlights.scm
Normal file
255
runtime/queries/go/highlights.scm
Normal file
|
|
@ -0,0 +1,255 @@
|
|||
;; 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) @namespace
|
||||
|
||||
(parameter_declaration (identifier) @parameter)
|
||||
(variadic_parameter_declaration (identifier) @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) @method.call))
|
||||
|
||||
; Function definitions
|
||||
|
||||
(function_declaration
|
||||
name: (identifier) @function)
|
||||
|
||||
(method_declaration
|
||||
name: (field_identifier) @method)
|
||||
|
||||
(method_spec
|
||||
name: (field_identifier) @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"
|
||||
"interface"
|
||||
"range"
|
||||
"select"
|
||||
"struct"
|
||||
"type"
|
||||
"var"
|
||||
"fallthrough"
|
||||
] @keyword
|
||||
|
||||
"func" @keyword.function
|
||||
"return" @keyword.return
|
||||
"go" @keyword.coroutine
|
||||
|
||||
"for" @repeat
|
||||
|
||||
[
|
||||
"import"
|
||||
"package"
|
||||
] @include
|
||||
|
||||
[
|
||||
"else"
|
||||
"case"
|
||||
"switch"
|
||||
"if"
|
||||
] @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) @float
|
||||
(imaginary_literal) @number
|
||||
|
||||
[
|
||||
(true)
|
||||
(false)
|
||||
] @boolean
|
||||
|
||||
[
|
||||
(nil)
|
||||
(iota)
|
||||
] @constant.builtin
|
||||
|
||||
(keyed_element
|
||||
. (literal_element (identifier) @field))
|
||||
(field_declaration name: (field_identifier) @field)
|
||||
|
||||
; 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))
|
||||
|
||||
; Errors
|
||||
|
||||
(ERROR) @error
|
||||
|
||||
; Spell
|
||||
|
||||
((interpreted_string_literal) @spell
|
||||
(#not-has-parent? @spell import_spec))
|
||||
33
runtime/queries/go/indents.scm
Normal file
33
runtime/queries/go/indents.scm
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
[
|
||||
(import_declaration)
|
||||
(const_declaration)
|
||||
(var_declaration)
|
||||
(type_declaration)
|
||||
(func_literal)
|
||||
(literal_value)
|
||||
(expression_case)
|
||||
(communication_case)
|
||||
(type_case)
|
||||
(default_case)
|
||||
(block)
|
||||
(call_expression)
|
||||
(parameter_list)
|
||||
(struct_type)
|
||||
] @indent.begin
|
||||
|
||||
[
|
||||
"}"
|
||||
] @indent.branch
|
||||
|
||||
(const_declaration ")" @indent.branch)
|
||||
(import_spec_list ")" @indent.branch)
|
||||
(var_declaration ")" @indent.branch)
|
||||
|
||||
[
|
||||
"}"
|
||||
")"
|
||||
] @indent.end
|
||||
|
||||
(parameter_list ")" @indent.branch)
|
||||
|
||||
(comment) @indent.ignore
|
||||
24
runtime/queries/go/injections.scm
Normal file
24
runtime/queries/go/injections.scm
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
||||
|
||||
(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)
|
||||
(interpreted_string_literal)
|
||||
] @injection.content
|
||||
(#offset! @injection.content 0 1 0 -1)
|
||||
(#set! injection.language "regex")))
|
||||
|
||||
((comment) @injection.content
|
||||
(#match? @injection.content "/\\*!([a-zA-Z]+:)?re2c")
|
||||
(#set! injection.language "re2c"))
|
||||
79
runtime/queries/go/locals.scm
Normal file
79
runtime/queries/go/locals.scm
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
(
|
||||
(function_declaration
|
||||
name: (identifier) @definition.function) ;@function
|
||||
)
|
||||
|
||||
(
|
||||
(method_declaration
|
||||
name: (field_identifier) @definition.method); @method
|
||||
)
|
||||
|
||||
(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)
|
||||
|
||||
(for_statement
|
||||
(range_clause
|
||||
left: (expression_list
|
||||
(identifier) @definition.var)))
|
||||
|
||||
(const_declaration
|
||||
(const_spec
|
||||
name: (identifier) @definition.var))
|
||||
|
||||
(type_declaration
|
||||
(type_spec
|
||||
name: (type_identifier) @definition.type))
|
||||
|
||||
;; reference
|
||||
(identifier) @reference
|
||||
(type_identifier) @reference
|
||||
(field_identifier) @reference
|
||||
((package_identifier) @reference
|
||||
(#set! reference.kind "namespace"))
|
||||
|
||||
(package_clause
|
||||
(package_identifier) @definition.namespace)
|
||||
|
||||
(import_spec_list
|
||||
(import_spec
|
||||
name: (package_identifier) @definition.namespace))
|
||||
|
||||
;; Call references
|
||||
((call_expression
|
||||
function: (identifier) @reference)
|
||||
(#set! reference.kind "call" ))
|
||||
|
||||
((call_expression
|
||||
function: (selector_expression
|
||||
field: (field_identifier) @reference))
|
||||
(#set! reference.kind "call" ))
|
||||
|
||||
|
||||
((call_expression
|
||||
function: (parenthesized_expression
|
||||
(identifier) @reference))
|
||||
(#set! reference.kind "call" ))
|
||||
|
||||
((call_expression
|
||||
function: (parenthesized_expression
|
||||
(selector_expression
|
||||
field: (field_identifier) @reference)))
|
||||
(#set! reference.kind "call" ))
|
||||
|
||||
;; Scopes
|
||||
|
||||
(func_literal) @scope
|
||||
(source_file) @scope
|
||||
(function_declaration) @scope
|
||||
(if_statement) @scope
|
||||
(block) @scope
|
||||
(expression_switch_statement) @scope
|
||||
(for_statement) @scope
|
||||
(method_declaration) @scope
|
||||
Loading…
Add table
Add a link
Reference in a new issue