mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-01 19:17:02 -04:00
fix(nim): minor improvements to queries and parser (#5784)
* fix(nim): bump parser again to include minor fix * fix(nim): shifting around for precedence * fix(nim): added new fields from recent parser version, improved support for (conditional_declaration) and (variant_declaration)
This commit is contained in:
parent
25ddfde8d7
commit
edacfa2eed
3 changed files with 54 additions and 51 deletions
|
|
@ -12,6 +12,8 @@
|
|||
(case)
|
||||
(if)
|
||||
(when)
|
||||
(conditional_declaration)
|
||||
(variant_declaration)
|
||||
(of_branch)
|
||||
(elif_branch)
|
||||
(else_branch)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
; @variable capture.
|
||||
|
||||
(type_expression) @type
|
||||
; NOTE: has to be after
|
||||
; NOTE: has to be after
|
||||
; ((identifier) @variable (#set! "priority" 99))
|
||||
|
||||
; overrule identifiers in pragmas in (proc_type)s and (pragma_expression)s
|
||||
|
|
@ -25,10 +25,32 @@
|
|||
(pragma_expression
|
||||
right:
|
||||
(pragma_list) @variable))
|
||||
; NOTE: has to be after
|
||||
; NOTE: has to be after
|
||||
; (type_expression) @type
|
||||
; and before @preproc and all literals
|
||||
|
||||
; constants/enums in array construction
|
||||
(array_construction
|
||||
(colon_expression
|
||||
left: (_) @constant))
|
||||
; NOTE: has to be before literals and punctuation etc.
|
||||
|
||||
; identifiers in "case" "of" branches have to be enums
|
||||
(case
|
||||
alternative:
|
||||
(of_branch
|
||||
values:
|
||||
(expression_list (_) @constant)))
|
||||
; NOTE: has to be before literals and punctuation etc.
|
||||
|
||||
; in variant objects with "case" "of"
|
||||
(variant_declaration
|
||||
alternative:
|
||||
(of_branch
|
||||
values:
|
||||
(expression_list (_) @constant)))
|
||||
; NOTE: has to be before literals and punctuation etc.
|
||||
|
||||
; =============================================================================
|
||||
; @comment ; line and block comments
|
||||
|
||||
|
|
@ -239,9 +261,9 @@
|
|||
; function.calls in `varargs[type, routine]`
|
||||
(bracket_expression
|
||||
left: (identifier) @_varargs
|
||||
right:
|
||||
right:
|
||||
(argument_list
|
||||
.
|
||||
.
|
||||
(_)
|
||||
.
|
||||
[
|
||||
|
|
@ -448,6 +470,7 @@
|
|||
; when accessing and directly call elements from an array of routines
|
||||
; eg `array_of_routines[index](arguments), but that is an uncommon case
|
||||
|
||||
; dot_generic_call `v.call[:type, type]()
|
||||
(dot_generic_call
|
||||
generic_arguments: (_) @type)
|
||||
|
||||
|
|
@ -643,16 +666,6 @@
|
|||
; =============================================================================
|
||||
; @constant ; constant identifiers
|
||||
|
||||
; identifiers in "case" "of" branches have to be enums
|
||||
(case
|
||||
(of_branch values:
|
||||
(expression_list (_) @constant)))
|
||||
|
||||
; in variant objects with "case" "of"
|
||||
(variant_declaration
|
||||
(of_branch values:
|
||||
(expression_list (_) @constant)))
|
||||
|
||||
; enum declaration
|
||||
(enum_field_declaration
|
||||
(symbol_declaration
|
||||
|
|
@ -661,11 +674,6 @@
|
|||
(accent_quoted (identifier) @constant)
|
||||
]))
|
||||
|
||||
; constants/enums in array construction
|
||||
(array_construction
|
||||
(colon_expression
|
||||
left: (_) @constant))
|
||||
|
||||
; constant declaration
|
||||
(const_section
|
||||
(variable_declaration
|
||||
|
|
@ -691,10 +699,10 @@
|
|||
; constants x and y in `array[x..y, type]`
|
||||
(bracket_expression
|
||||
left: (identifier) @_array
|
||||
right:
|
||||
right:
|
||||
(argument_list
|
||||
.
|
||||
(infix_expression
|
||||
.
|
||||
(infix_expression
|
||||
right: [
|
||||
(identifier) @constant
|
||||
(accent_quoted (identifier) @constant)
|
||||
|
|
@ -704,10 +712,10 @@
|
|||
(#any-of? @_array "array" "range"))
|
||||
(bracket_expression
|
||||
left: (identifier) @_array
|
||||
right:
|
||||
right:
|
||||
(argument_list
|
||||
.
|
||||
(infix_expression
|
||||
.
|
||||
(infix_expression
|
||||
left: [
|
||||
(identifier) @constant
|
||||
(accent_quoted (identifier) @constant)
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@
|
|||
type: (type_expression)? @definition.associated)
|
||||
|
||||
(concept_declaration
|
||||
parameters:
|
||||
parameters:
|
||||
(parameter_list [
|
||||
(identifier) @definition.parameter
|
||||
(accent_quoted (identifier) @definition.parameter)
|
||||
|
|
@ -193,28 +193,21 @@
|
|||
; ==============================================================================
|
||||
; @definition.field ; fields or properties
|
||||
|
||||
(object_declaration
|
||||
(field_declaration_list
|
||||
(field_declaration
|
||||
(symbol_declaration_list
|
||||
(symbol_declaration
|
||||
name: [
|
||||
(identifier) @definition.field
|
||||
(accent_quoted) @definition.field
|
||||
(exported_symbol (identifier) @definition.field)
|
||||
(exported_symbol (accent_quoted) @definition.field)
|
||||
]))
|
||||
type: (type_expression)? @definition.associated)))
|
||||
|
||||
(tuple_type
|
||||
(field_declaration
|
||||
(symbol_declaration_list
|
||||
(symbol_declaration
|
||||
name: [
|
||||
(identifier) @definition.field
|
||||
(accent_quoted) @definition.field
|
||||
]))
|
||||
type: (type_expression)? @definition.associated))
|
||||
; object_declaration
|
||||
; variant_declaration
|
||||
; conditional_declaration
|
||||
; tuple_type inline
|
||||
; tuple_type multiline
|
||||
(field_declaration
|
||||
(symbol_declaration_list
|
||||
(symbol_declaration
|
||||
name: [
|
||||
(identifier) @definition.field
|
||||
(accent_quoted) @definition.field
|
||||
(exported_symbol (identifier) @definition.field)
|
||||
(exported_symbol (accent_quoted) @definition.field)
|
||||
]))
|
||||
type: (type_expression)? @definition.associated)
|
||||
|
||||
; ==============================================================================
|
||||
; @definition.enum ; enumerations
|
||||
|
|
@ -273,9 +266,9 @@
|
|||
alternative: (else_branch)? @scope)
|
||||
|
||||
(case
|
||||
(of_branch)* @scope
|
||||
(elif_branch)* @scope
|
||||
(else_branch)? @scope)
|
||||
alternative: (of_branch)* @scope
|
||||
alternative: (elif_branch)* @scope
|
||||
alternative: (else_branch)? @scope)
|
||||
|
||||
(try
|
||||
body: (statement_list) @scope
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue