diff options
| author | Christian Clason <c.clason@uni-graz.at> | 2024-06-15 14:39:06 +0200 |
|---|---|---|
| committer | Christian Clason <c.clason@uni-graz.at> | 2024-06-27 15:31:41 +0200 |
| commit | 5373c90c55a33408604d17713edaa9560306b83d (patch) | |
| tree | baef9637cf6203e0ed7e354e976bd1e2f2c8c7c0 /queries | |
| parent | feat(gitcommit): remove overflow rule (diff) | |
| download | nvim-treesitter-5373c90c55a33408604d17713edaa9560306b83d.tar nvim-treesitter-5373c90c55a33408604d17713edaa9560306b83d.tar.gz nvim-treesitter-5373c90c55a33408604d17713edaa9560306b83d.tar.bz2 nvim-treesitter-5373c90c55a33408604d17713edaa9560306b83d.tar.lz nvim-treesitter-5373c90c55a33408604d17713edaa9560306b83d.tar.xz nvim-treesitter-5373c90c55a33408604d17713edaa9560306b83d.tar.zst nvim-treesitter-5373c90c55a33408604d17713edaa9560306b83d.zip | |
feat(r)!: update parser and queries
Diffstat (limited to 'queries')
| -rw-r--r-- | queries/r/highlights.scm | 191 | ||||
| -rw-r--r-- | queries/r/indents.scm | 16 | ||||
| -rwxr-xr-x | queries/r/locals.scm | 20 |
3 files changed, 107 insertions, 120 deletions
diff --git a/queries/r/highlights.scm b/queries/r/highlights.scm index cedd25909..d6d1da0e4 100644 --- a/queries/r/highlights.scm +++ b/queries/r/highlights.scm @@ -1,4 +1,3 @@ -; highlights.scm ; Literals (integer) @number @@ -9,8 +8,10 @@ (string) @string (string - (escape_sequence) @string.escape) + (string_content + (escape_sequence) @string.escape)) +; Comments (comment) @comment @spell ((program @@ -18,123 +19,113 @@ (comment) @keyword.directive @nospell) (#lua-match? @keyword.directive "^#!/")) -(identifier) @variable - -((dollar - (identifier) @variable.builtin) - (#eq? @variable.builtin "self")) - -(dollar - _ - (identifier) @variable.member) - -; Parameters -(formal_parameters - (identifier) @variable.parameter) - -(formal_parameters - (default_parameter - name: (identifier) @variable.parameter)) - -(default_argument - name: (identifier) @variable.parameter) - -; Namespace -(namespace_get - namespace: (identifier) @module) - -(namespace_get_internal - namespace: (identifier) @module) - ; Operators [ + "?" + ":=" "=" "<-" "<<-" "->" -] @operator - -(unary - operator: [ - "-" - "+" - "!" - "~" - "?" - ] @operator) - -(binary - operator: [ - "-" - "+" - "*" - "/" - "^" - "<" - ">" - "<=" - ">=" - "==" - "!=" - "||" - "|" - "&&" - "&" - ":" - "~" - ] @operator) - -[ + "->>" + "~" "|>" - (special) + "||" + "|" + "&&" + "&" + "<" + "<=" + ">" + ">=" + "==" + "!=" + "+" + "-" + "*" + "/" + "::" + ":::" + "**" + "^" + "$" + "@" + ":" + "special" ] @operator -(lambda_function - "\\" @operator) - +; Punctuation [ "(" ")" - "[" - "]" "{" "}" + "[" + "]" + "[[" + "]]" ] @punctuation.bracket -"," @punctuation.delimiter +(comma) @punctuation.delimiter + +; Variables +(identifier) @variable + +; Functions +(binary_operator + lhs: (identifier) @function + operator: "<-" + rhs: (function_definition)) + +(binary_operator + lhs: (identifier) @function + operator: "=" + rhs: (function_definition)) + +; Calls +(call + function: (identifier) @function.call) + +; Parameters +(parameters + (parameter + name: (identifier) @variable.parameter)) + +(arguments + (argument + name: (identifier) @variable.parameter)) + +; Namespace +(namespace_operator + lhs: (identifier) @module) + +(call + function: (namespace_operator + rhs: (identifier) @function)) -(dollar - _ - "$" @operator) +; Keywords +(function_definition + name: "function" @keyword.function) -(subset2 - "[[" @punctuation.bracket - "]]" @punctuation.bracket) +(function_definition + name: "\\" @operator) [ - (dots) - (break) + "in" + (return) (next) + (break) ] @keyword [ - (nan) - (na) - (null) - (inf) -] @constant.builtin - -[ "if" "else" - "switch" ] @keyword.conditional [ "while" "repeat" "for" - "in" ] @keyword.repeat [ @@ -142,21 +133,11 @@ (false) ] @boolean -"function" @keyword.function - -; Functions/Methods -(call - function: (identifier) @function.call) - -(call - (namespace_get - function: (identifier) @function.call)) - -(call - (namespace_get_internal - function: (identifier) @function.call)) - -(call - function: (dollar - _ - (identifier) @function.method.call)) +[ + (null) + (inf) + (nan) + (na) + (dots) + (dot_dot_i) +] @constant.builtin diff --git a/queries/r/indents.scm b/queries/r/indents.scm index ec76272aa..86acddc5f 100644 --- a/queries/r/indents.scm +++ b/queries/r/indents.scm @@ -1,9 +1,8 @@ [ - (brace_list) - (paren_list) - (special) - (pipe) + (braced_expression) + (parenthesized_expression) (call) + "special" "|>" "if" "else" @@ -12,16 +11,17 @@ "for" ] @indent.begin -(binary - operator: (special)) @indent.begin +(binary_operator + operator: (_)) @indent.begin [ "}" ")" ] @indent.branch -((formal_parameters - (identifier)) @indent.align +((parameters + (parameter + name: (identifier))) @indent.align (#set! indent.open_delimiter "(") (#set! indent.close_delimiter ")")) diff --git a/queries/r/locals.scm b/queries/r/locals.scm index e98f773f5..3377552c8 100755 --- a/queries/r/locals.scm +++ b/queries/r/locals.scm @@ -1,16 +1,22 @@ ; locals.scm (function_definition) @local.scope -(formal_parameters - (identifier) @local.definition.parameter) - -(left_assignment +(argument name: (identifier) @local.definition) -(equals_assignment +(parameter name: (identifier) @local.definition) -(right_assignment - name: (identifier) @local.definition) +(binary_operator + lhs: (identifier) @local.definition + operator: "<-") + +(binary_operator + lhs: (identifier) @local.definition + operator: "=") + +(binary_operator + operator: "->" + rhs: (identifier) @local.definition) (identifier) @local.reference |
