diff options
author | Matthew Toohey | 2022-04-08 00:30:44 +0000 |
---|---|---|
committer | GitHub | 2022-04-08 00:30:44 +0000 |
commit | 31c468ab95fe775dc65bef0674ca3c3ec219259f (patch) | |
tree | 2a093aa93528966ae8ad999f14a3dfa3b413a593 /runtime | |
parent | d37369c1e056e41d405bc95b13efd550c57fa933 (diff) |
add languages `r` and `rmarkdown` (#1998)
* add languages `r` and `rmarkdown`
* r: fix highlights
* rmarkdown: add eof in queries
* rmarkdown: update lang-support.md
* r: fix highlight query precedence
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/queries/r/highlights.scm | 128 | ||||
-rw-r--r-- | runtime/queries/r/locals.scm | 11 | ||||
-rw-r--r-- | runtime/queries/rmarkdown/highlights.scm | 1 | ||||
-rw-r--r-- | runtime/queries/rmarkdown/indents.scm | 1 | ||||
-rw-r--r-- | runtime/queries/rmarkdown/injections.scm | 1 |
5 files changed, 142 insertions, 0 deletions
diff --git a/runtime/queries/r/highlights.scm b/runtime/queries/r/highlights.scm new file mode 100644 index 00000000..4b931a05 --- /dev/null +++ b/runtime/queries/r/highlights.scm @@ -0,0 +1,128 @@ +; highlights.scm + + +; Literals + +(integer) @constant.numeric.integer + +(float) @constant.numeric.float + +(complex) @constant.numeric.integer + +(string) @string +(string (escape_sequence) @constant.character.escape) + +(comment) @comment + +(formal_parameters (identifier) @variable.parameter) +(formal_parameters (default_parameter (identifier) @variable.parameter)) + +; Operators +[ + "=" + "<-" + "<<-" + "->>" + "->" +] @operator + +(unary operator: [ + "-" + "+" + "!" + "~" +] @operator) + +(binary operator: [ + "-" + "+" + "*" + "/" + "^" + "<" + ">" + "<=" + ">=" + "==" + "!=" + "||" + "|" + "&&" + "&" + ":" + "~" +] @operator) + +[ + "|>" + (special) +] @operator + +(lambda_function "\\" @operator) + +[ + "(" + ")" + "[" + "]" + "{" + "}" +] @punctuation.bracket + +(dollar "$" @operator) + +(subset2 + [ + "[[" + "]]" + ] @punctuation.bracket) + +[ + "in" + (dots) + (break) + (next) + (inf) +] @keyword + +[ + (nan) + (na) + (null) +] @type.builtin + +[ + "if" + "else" + "switch" +] @keyword.control.conditional + +[ + "while" + "repeat" + "for" +] @keyword.control.repeat + +[ + (true) + (false) +] @constant.builtin.boolean + +"function" @keyword.function + +(call function: (identifier) @function) +(default_argument name: (identifier) @variable.parameter) + + +(namespace_get namespace: (identifier) @namespace + "::" @operator) +(namespace_get_internal namespace: (identifier) @namespace + ":::" @operator) + +(namespace_get function: (identifier) @function.method) +(namespace_get_internal function: (identifier) @function.method) + +(identifier) @variable + +; Error +(ERROR) @error diff --git a/runtime/queries/r/locals.scm b/runtime/queries/r/locals.scm new file mode 100644 index 00000000..be6cc637 --- /dev/null +++ b/runtime/queries/r/locals.scm @@ -0,0 +1,11 @@ +; locals.scm + +(function_definition) @local.scope + +(formal_parameters (identifier) @local.definition) + +(left_assignment name: (identifier) @local.definition) +(equals_assignment name: (identifier) @local.definition) +(right_assignment name: (identifier) @local.definition) + +(identifier) @local.reference diff --git a/runtime/queries/rmarkdown/highlights.scm b/runtime/queries/rmarkdown/highlights.scm new file mode 100644 index 00000000..a3a30e34 --- /dev/null +++ b/runtime/queries/rmarkdown/highlights.scm @@ -0,0 +1 @@ +; inherits: markdown diff --git a/runtime/queries/rmarkdown/indents.scm b/runtime/queries/rmarkdown/indents.scm new file mode 100644 index 00000000..a3a30e34 --- /dev/null +++ b/runtime/queries/rmarkdown/indents.scm @@ -0,0 +1 @@ +; inherits: markdown diff --git a/runtime/queries/rmarkdown/injections.scm b/runtime/queries/rmarkdown/injections.scm new file mode 100644 index 00000000..a3a30e34 --- /dev/null +++ b/runtime/queries/rmarkdown/injections.scm @@ -0,0 +1 @@ +; inherits: markdown |