aboutsummaryrefslogtreecommitdiffstats
path: root/queries/v
diff options
context:
space:
mode:
authorAmaan Qureshi <amaanq12@gmail.com>2023-07-04 04:12:21 -0400
committerChristian Clason <c.clason@uni-graz.at>2023-07-04 11:08:07 +0200
commit46b1ad3de2942dcf05f18d124b25fb6ee691c5bf (patch)
treef59852521ecdf8c627ab131c02e7925e3cd81b4a /queries/v
parentUpdate parsers: hoon, matlab, v, wing (diff)
downloadnvim-treesitter-46b1ad3de2942dcf05f18d124b25fb6ee691c5bf.tar
nvim-treesitter-46b1ad3de2942dcf05f18d124b25fb6ee691c5bf.tar.gz
nvim-treesitter-46b1ad3de2942dcf05f18d124b25fb6ee691c5bf.tar.bz2
nvim-treesitter-46b1ad3de2942dcf05f18d124b25fb6ee691c5bf.tar.lz
nvim-treesitter-46b1ad3de2942dcf05f18d124b25fb6ee691c5bf.tar.xz
nvim-treesitter-46b1ad3de2942dcf05f18d124b25fb6ee691c5bf.tar.zst
nvim-treesitter-46b1ad3de2942dcf05f18d124b25fb6ee691c5bf.zip
refactor(v)!: update upstream repository
Diffstat (limited to 'queries/v')
-rw-r--r--queries/v/highlights.scm368
-rw-r--r--queries/v/indents.scm3
-rw-r--r--queries/v/injections.scm6
-rw-r--r--queries/v/locals.scm19
4 files changed, 224 insertions, 172 deletions
diff --git a/queries/v/highlights.scm b/queries/v/highlights.scm
index 379b525e8..0fb3074fa 100644
--- a/queries/v/highlights.scm
+++ b/queries/v/highlights.scm
@@ -1,196 +1,174 @@
-;; reference https://github.com/vlang/vls
-;; rev: c3e9874fa6c3b38beaa50d53aff4967403e251a4
+; Includes
-;; Identifiers -------------------
-(import_path) @namespace
-(module_identifier) @variable.builtin
-(identifier) @variable
-(interpreted_string_literal) @string
-(string_interpolation) @none
+[
+ "import"
+ "module"
+] @include
-; TODO: Have different highlight to make then standout + highlight }{$ as special
-; ((string_interpolation
-; (identifier) @constant
-; "$" @punctuation.special
-; "${" @punctuation.special
-; "}" @punctuation.special))
+; Keywords
-[(type_identifier) (array_type) (pointer_type)] @type
+[
+ "asm"
+ "assert"
+ "const"
+ "defer"
+ "enum"
+ "goto"
+ "interface"
+ "struct"
+ "sql"
+ "type"
+ "union"
+ "unsafe"
+] @keyword
-(field_identifier) @property
+[
+ "as"
+ "in"
+ "!in"
+ "or"
+ "is"
+ "!is"
+] @keyword.operator
-(builtin_type) @type.builtin
+[
+ "match"
+ "if"
+ "$if"
+ "else"
+ "$else"
+ "select"
+] @conditional
-(parameter_declaration
- name: (identifier) @parameter)
+[
+ "for"
+ "$for"
+ "continue"
+ "break"
+] @repeat
-(const_spec
- name: (identifier) @constant)
+"fn" @keyword.function
-((((selector_expression field: (identifier) @property)) @_parent
- (#not-has-parent? @_parent call_expression special_call_expression)))
+"return" @keyword.return
-((identifier) @variable.builtin
- (#any-of? @variable.builtin "err" "macos" "linux" "windows"))
+[
+ "__global"
+ "shared"
+ "static"
+ "const"
+] @storageclass
-(attribute_declaration) @attribute
-;; C: TODO: fixme make `C`.exten highlighted as variable.builtin
-; ((binded_identifier) @content
-; (#offset! @content 0 3 0 -1)
-; (#match? @content "^C$"))
+[
+ "pub"
+ "mut"
+] @type.qualifier
-;; Function calls ----------------
-(call_expression
- function: (identifier) @function.call)
+[
+ "go"
+ "spawn"
+ "lock"
+ "rlock"
+] @keyword.coroutine
-(((_
- function: (selector_expression field: (identifier) @function.call)
- arguments: (_) @_args)
- (#not-has-type? @_args arguments_list)))
+; Variables
-((call_expression
- function: (binded_identifier name: (identifier) @function)
- @function.call))
+(identifier) @variable
+; Namespace
-;; Function definitions ---------
-(function_declaration
- name: (identifier) @function)
+(module_clause
+ (identifier) @namespace)
-(function_declaration
- receiver: (parameter_list)
- name: (identifier) @method)
+(import_path
+ (import_name) @namespace)
-((function_declaration
- (binded_identifier name: (identifier) @function)
- @function))
+(import_alias
+ (import_name) @namespace)
-;; Keywords
+; Literals
-[
- "import"
- "module"
-] @include
+[ (true) (false) ] @boolean
-[
- "match"
- "if"
- "$if"
- "else"
- "$else"
-] @conditional
+(interpreted_string_literal) @string
-[
- "for" @repeat
- "$for"
-] @repeat
+(string_interpolation) @none
-[
- "as"
- "in"
- "!in"
- "or"
- "is"
- "!is"
-] @keyword.operator
+; Types
-[
- "asm"
- "assert"
- "const"
- "defer"
- "enum"
- "go"
- "goto"
- "interface"
- "lock"
- "mut"
- "pub"
- "rlock"
- "struct"
- "type"
- "unsafe"
-]
- ;; Either not supported or will be dropped
- ;"atomic"
- ;"break"
- ; "continue"
- ;"shared"
- ;"static"
- ;"union"
-@keyword
+(struct_declaration
+ name: (identifier) @type)
-"fn" @keyword.function
-"return" @keyword.return
+(enum_declaration
+ name: (identifier) @type)
-; "import" @include ;; note: comment out b/c of import_path @namespace
+(interface_declaration
+ name: (identifier) @type)
-[ (true) (false) ] @boolean
+(type_declaration
+ name: (identifier) @type)
+(type_reference_expression (identifier) @type)
+; Labels
-;; Conditionals ----------------
-[ "else" "if"] @conditional
+(label_reference) @label
-;; Operators ----------------
-[ "." "," ":" ";"] @punctuation.delimiter
+; Fields
-[ "(" ")" "{" "}" "[" "]"] @punctuation.bracket
+(selector_expression field: (reference_expression (identifier) @field))
-(array) @punctuation.bracket
+(field_name) @field
-[
- "++"
- "--"
+(struct_field_declaration
+ name: (identifier) @field)
+
+; Parameters
+
+(parameter_declaration
+ name: (identifier) @parameter)
+
+(receiver
+ name: (identifier) @parameter)
- "+"
- "-"
- "*"
- "/"
- "%"
+; Constants
- "~"
- "&"
- "|"
- "^"
+((identifier) @constant
+ (#has-ancestor? @constant compile_time_if_expression))
- "!"
- "&&"
- "||"
- "!="
+(enum_fetch
+ (reference_expression) @constant)
- "<<"
- ">>"
+(enum_field_definition
+ (identifier) @constant)
- "<"
- ">"
- "<="
- ">="
+(const_definition
+ name: (identifier) @constant)
- "+="
- "-="
- "*="
- "/="
- "&="
- "|="
- "^="
- "<<="
- ">>="
+((identifier) @variable.builtin
+ (#any-of? @variable.builtin "err" "macos" "linux" "windows"))
- "="
- ":="
- "=="
+; Attributes
- "?"
- "<-"
- "$"
- ".."
- "..."]
-@operator
+(attribute) @attribute
+
+; Functions
+
+(function_declaration
+ name: (identifier) @function)
+
+(function_declaration
+ receiver: (receiver)
+ name: (identifier) @method)
+
+(call_expression
+ name: (selector_expression
+ field: (reference_expression) @method.call))
+
+(call_expression
+ name: (reference_expression) @function.call)
-;; Builtin Functions, maybe redundant with (builtin_type)
((identifier) @function.builtin
- (#any-of? @function.builtin
+ (#any-of? @function.builtin
"eprint"
"eprintln"
"error"
@@ -389,25 +367,101 @@
"vstrlen_char"
"winapi_lasterr_str"))
+; Operators
+
+[
+ "++"
+ "--"
+
+ "+"
+ "-"
+ "*"
+ "/"
+ "%"
+
+ "~"
+ "&"
+ "|"
+ "^"
+
+ "!"
+ "&&"
+ "||"
+ "!="
+
+ "<<"
+ ">>"
+
+ "<"
+ ">"
+ "<="
+ ">="
+
+ "+="
+ "-="
+ "*="
+ "/="
+ "&="
+ "|="
+ "^="
+ "<<="
+ ">>="
+
+ "="
+ ":="
+ "=="
+
+ "?"
+ "<-"
+ "$"
+ ".."
+ "..."
+] @operator
+
+; Punctuation
-;; Literals
+[ "." "," ":" ";" ] @punctuation.delimiter
+
+[ "(" ")" "{" "}" "[" "]" ] @punctuation.bracket
+
+; Literals
(int_literal) @number
-(rune_literal) @string
+(float_literal) @float
+
+[
+ (c_string_literal)
+ (raw_string_literal)
+ (interpreted_string_literal)
+ (string_interpolation)
+ (rune_literal)
+] @string
-(raw_string_literal) @string
+(string_interpolation
+ (braced_interpolation_opening) @punctuation.bracket
+ (interpolated_expression) @none
+ (braced_interpolation_closing) @punctuation.bracket)
(escape_sequence) @string.escape
-(float_literal) @float
+[
+ (true)
+ (false)
+] @boolean
-[(true) (false)] @boolean
+(nil) @constant.builtin
-(ERROR) @error
+(none) @variable.builtin
+
+; Comments
(comment) @comment @spell
(_
(comment)+ @comment.documentation
- [(function_declaration) (type_declaration) (const_spec) (enum_declaration)])
+ [(function_declaration) (type_declaration) (enum_declaration)])
+
+; Errors
+
+(ERROR) @error
diff --git a/queries/v/indents.scm b/queries/v/indents.scm
index afcf6d8c6..a806b35ed 100644
--- a/queries/v/indents.scm
+++ b/queries/v/indents.scm
@@ -1,10 +1,9 @@
[(import_declaration)
(const_declaration)
(type_declaration)
- (literal_value)
(type_initializer)
(block)
- (map)
+ (map_init_expression)
(call_expression)
(parameter_list)]
@indent.begin
diff --git a/queries/v/injections.scm b/queries/v/injections.scm
index 11f02639e..b39a5ef44 100644
--- a/queries/v/injections.scm
+++ b/queries/v/injections.scm
@@ -6,8 +6,8 @@
;; regex for the methods defined in `re` module
((call_expression
- function: (selector_expression
- field: (identifier) @_re)
+ name: (selector_expression
+ field: (reference_expression (identifier) @_re))
arguments: (argument_list
- (raw_string_literal) @regex (#offset! @regex 0 2 0 -1)))
+ (argument (literal (raw_string_literal) @regex (#offset! @regex 0 2 0 -1)))))
(#any-of? @_re "regex_base" "regex_opt" "compile_opt"))
diff --git a/queries/v/locals.scm b/queries/v/locals.scm
index 0d1b64c17..f0e08403a 100644
--- a/queries/v/locals.scm
+++ b/queries/v/locals.scm
@@ -1,25 +1,24 @@
((function_declaration
name: (identifier) @definition.function)) ;@function
-(short_var_declaration
- left: (expression_list
- (identifier) @definition.var))
+(var_declaration
+ var_list: (expression_list
+ (reference_expression
+ (identifier) @definition.var)))
((function_declaration
- name: (binded_identifier
- name: (identifier) @definition.function)))
+ name: (identifier) @definition.function))
-(const_declaration (const_spec (identifier) @definition.var))
+(const_declaration (const_definition name: (identifier) @definition.var))
(identifier) @reference
-(type_identifier) @reference
-((call_expression function: (identifier) @reference)
+((call_expression name: (reference_expression (identifier)) @reference)
(#set! reference.kind "call"))
((call_expression
- function: (selector_expression
- field: (identifier) @definition.function))
+ name: (selector_expression
+ field: (reference_expression (identifier) @definition.function)))
(#set! reference.kind "call"))
(source_file) @scope