summaryrefslogtreecommitdiffstats
path: root/queries
diff options
context:
space:
mode:
authoraMOPel <36712072+aMOPel@users.noreply.github.com>2023-12-18 17:32:06 +0100
committerGitHub <noreply@github.com>2023-12-19 01:32:06 +0900
commitedacfa2eedd1d6099cd45e28ffe2892066b0b3ba (patch)
treec6ea26371fa7068c0f8bb521f05cf5645d4c4111 /queries
parentUpdate parsers: elm, haskell, templ, wing (diff)
downloadnvim-treesitter-edacfa2eedd1d6099cd45e28ffe2892066b0b3ba.tar
nvim-treesitter-edacfa2eedd1d6099cd45e28ffe2892066b0b3ba.tar.gz
nvim-treesitter-edacfa2eedd1d6099cd45e28ffe2892066b0b3ba.tar.bz2
nvim-treesitter-edacfa2eedd1d6099cd45e28ffe2892066b0b3ba.tar.lz
nvim-treesitter-edacfa2eedd1d6099cd45e28ffe2892066b0b3ba.tar.xz
nvim-treesitter-edacfa2eedd1d6099cd45e28ffe2892066b0b3ba.tar.zst
nvim-treesitter-edacfa2eedd1d6099cd45e28ffe2892066b0b3ba.zip
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)
Diffstat (limited to 'queries')
-rw-r--r--queries/nim/folds.scm2
-rw-r--r--queries/nim/highlights.scm58
-rw-r--r--queries/nim/locals.scm45
3 files changed, 54 insertions, 51 deletions
diff --git a/queries/nim/folds.scm b/queries/nim/folds.scm
index 27c8d4669..466bcf5ae 100644
--- a/queries/nim/folds.scm
+++ b/queries/nim/folds.scm
@@ -12,6 +12,8 @@
(case)
(if)
(when)
+ (conditional_declaration)
+ (variant_declaration)
(of_branch)
(elif_branch)
(else_branch)
diff --git a/queries/nim/highlights.scm b/queries/nim/highlights.scm
index a743c544b..a6e28038e 100644
--- a/queries/nim/highlights.scm
+++ b/queries/nim/highlights.scm
@@ -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)
diff --git a/queries/nim/locals.scm b/queries/nim/locals.scm
index dd80b315b..5b70bac10 100644
--- a/queries/nim/locals.scm
+++ b/queries/nim/locals.scm
@@ -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