mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-12 08:20:05 -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)
|
(case)
|
||||||
(if)
|
(if)
|
||||||
(when)
|
(when)
|
||||||
|
(conditional_declaration)
|
||||||
|
(variant_declaration)
|
||||||
(of_branch)
|
(of_branch)
|
||||||
(elif_branch)
|
(elif_branch)
|
||||||
(else_branch)
|
(else_branch)
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
; @variable capture.
|
; @variable capture.
|
||||||
|
|
||||||
(type_expression) @type
|
(type_expression) @type
|
||||||
; NOTE: has to be after
|
; NOTE: has to be after
|
||||||
; ((identifier) @variable (#set! "priority" 99))
|
; ((identifier) @variable (#set! "priority" 99))
|
||||||
|
|
||||||
; overrule identifiers in pragmas in (proc_type)s and (pragma_expression)s
|
; overrule identifiers in pragmas in (proc_type)s and (pragma_expression)s
|
||||||
|
|
@ -25,10 +25,32 @@
|
||||||
(pragma_expression
|
(pragma_expression
|
||||||
right:
|
right:
|
||||||
(pragma_list) @variable))
|
(pragma_list) @variable))
|
||||||
; NOTE: has to be after
|
; NOTE: has to be after
|
||||||
; (type_expression) @type
|
; (type_expression) @type
|
||||||
; and before @preproc and all literals
|
; 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
|
; @comment ; line and block comments
|
||||||
|
|
||||||
|
|
@ -239,9 +261,9 @@
|
||||||
; function.calls in `varargs[type, routine]`
|
; function.calls in `varargs[type, routine]`
|
||||||
(bracket_expression
|
(bracket_expression
|
||||||
left: (identifier) @_varargs
|
left: (identifier) @_varargs
|
||||||
right:
|
right:
|
||||||
(argument_list
|
(argument_list
|
||||||
.
|
.
|
||||||
(_)
|
(_)
|
||||||
.
|
.
|
||||||
[
|
[
|
||||||
|
|
@ -448,6 +470,7 @@
|
||||||
; when accessing and directly call elements from an array of routines
|
; when accessing and directly call elements from an array of routines
|
||||||
; eg `array_of_routines[index](arguments), but that is an uncommon case
|
; eg `array_of_routines[index](arguments), but that is an uncommon case
|
||||||
|
|
||||||
|
; dot_generic_call `v.call[:type, type]()
|
||||||
(dot_generic_call
|
(dot_generic_call
|
||||||
generic_arguments: (_) @type)
|
generic_arguments: (_) @type)
|
||||||
|
|
||||||
|
|
@ -643,16 +666,6 @@
|
||||||
; =============================================================================
|
; =============================================================================
|
||||||
; @constant ; constant identifiers
|
; @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 declaration
|
||||||
(enum_field_declaration
|
(enum_field_declaration
|
||||||
(symbol_declaration
|
(symbol_declaration
|
||||||
|
|
@ -661,11 +674,6 @@
|
||||||
(accent_quoted (identifier) @constant)
|
(accent_quoted (identifier) @constant)
|
||||||
]))
|
]))
|
||||||
|
|
||||||
; constants/enums in array construction
|
|
||||||
(array_construction
|
|
||||||
(colon_expression
|
|
||||||
left: (_) @constant))
|
|
||||||
|
|
||||||
; constant declaration
|
; constant declaration
|
||||||
(const_section
|
(const_section
|
||||||
(variable_declaration
|
(variable_declaration
|
||||||
|
|
@ -691,10 +699,10 @@
|
||||||
; constants x and y in `array[x..y, type]`
|
; constants x and y in `array[x..y, type]`
|
||||||
(bracket_expression
|
(bracket_expression
|
||||||
left: (identifier) @_array
|
left: (identifier) @_array
|
||||||
right:
|
right:
|
||||||
(argument_list
|
(argument_list
|
||||||
.
|
.
|
||||||
(infix_expression
|
(infix_expression
|
||||||
right: [
|
right: [
|
||||||
(identifier) @constant
|
(identifier) @constant
|
||||||
(accent_quoted (identifier) @constant)
|
(accent_quoted (identifier) @constant)
|
||||||
|
|
@ -704,10 +712,10 @@
|
||||||
(#any-of? @_array "array" "range"))
|
(#any-of? @_array "array" "range"))
|
||||||
(bracket_expression
|
(bracket_expression
|
||||||
left: (identifier) @_array
|
left: (identifier) @_array
|
||||||
right:
|
right:
|
||||||
(argument_list
|
(argument_list
|
||||||
.
|
.
|
||||||
(infix_expression
|
(infix_expression
|
||||||
left: [
|
left: [
|
||||||
(identifier) @constant
|
(identifier) @constant
|
||||||
(accent_quoted (identifier) @constant)
|
(accent_quoted (identifier) @constant)
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@
|
||||||
type: (type_expression)? @definition.associated)
|
type: (type_expression)? @definition.associated)
|
||||||
|
|
||||||
(concept_declaration
|
(concept_declaration
|
||||||
parameters:
|
parameters:
|
||||||
(parameter_list [
|
(parameter_list [
|
||||||
(identifier) @definition.parameter
|
(identifier) @definition.parameter
|
||||||
(accent_quoted (identifier) @definition.parameter)
|
(accent_quoted (identifier) @definition.parameter)
|
||||||
|
|
@ -193,28 +193,21 @@
|
||||||
; ==============================================================================
|
; ==============================================================================
|
||||||
; @definition.field ; fields or properties
|
; @definition.field ; fields or properties
|
||||||
|
|
||||||
(object_declaration
|
; object_declaration
|
||||||
(field_declaration_list
|
; variant_declaration
|
||||||
(field_declaration
|
; conditional_declaration
|
||||||
(symbol_declaration_list
|
; tuple_type inline
|
||||||
(symbol_declaration
|
; tuple_type multiline
|
||||||
name: [
|
(field_declaration
|
||||||
(identifier) @definition.field
|
(symbol_declaration_list
|
||||||
(accent_quoted) @definition.field
|
(symbol_declaration
|
||||||
(exported_symbol (identifier) @definition.field)
|
name: [
|
||||||
(exported_symbol (accent_quoted) @definition.field)
|
(identifier) @definition.field
|
||||||
]))
|
(accent_quoted) @definition.field
|
||||||
type: (type_expression)? @definition.associated)))
|
(exported_symbol (identifier) @definition.field)
|
||||||
|
(exported_symbol (accent_quoted) @definition.field)
|
||||||
(tuple_type
|
]))
|
||||||
(field_declaration
|
type: (type_expression)? @definition.associated)
|
||||||
(symbol_declaration_list
|
|
||||||
(symbol_declaration
|
|
||||||
name: [
|
|
||||||
(identifier) @definition.field
|
|
||||||
(accent_quoted) @definition.field
|
|
||||||
]))
|
|
||||||
type: (type_expression)? @definition.associated))
|
|
||||||
|
|
||||||
; ==============================================================================
|
; ==============================================================================
|
||||||
; @definition.enum ; enumerations
|
; @definition.enum ; enumerations
|
||||||
|
|
@ -273,9 +266,9 @@
|
||||||
alternative: (else_branch)? @scope)
|
alternative: (else_branch)? @scope)
|
||||||
|
|
||||||
(case
|
(case
|
||||||
(of_branch)* @scope
|
alternative: (of_branch)* @scope
|
||||||
(elif_branch)* @scope
|
alternative: (elif_branch)* @scope
|
||||||
(else_branch)? @scope)
|
alternative: (else_branch)? @scope)
|
||||||
|
|
||||||
(try
|
(try
|
||||||
body: (statement_list) @scope
|
body: (statement_list) @scope
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue