aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPedro Castro <aspeddro@gmail.com>2022-10-29 22:53:01 -0300
committerStephan Seitz <stephan.seitz@fau.de>2022-12-31 13:50:47 +0100
commit58c0d78de8d4fee3742381d77173ea50e828b47b (patch)
treeba51133dc6edccbb58287e171d788edd26f342e6
parentdocs: link to Matrix instead of Zulip (diff)
downloadnvim-treesitter-58c0d78de8d4fee3742381d77173ea50e828b47b.tar
nvim-treesitter-58c0d78de8d4fee3742381d77173ea50e828b47b.tar.gz
nvim-treesitter-58c0d78de8d4fee3742381d77173ea50e828b47b.tar.bz2
nvim-treesitter-58c0d78de8d4fee3742381d77173ea50e828b47b.tar.lz
nvim-treesitter-58c0d78de8d4fee3742381d77173ea50e828b47b.tar.xz
nvim-treesitter-58c0d78de8d4fee3742381d77173ea50e828b47b.tar.zst
nvim-treesitter-58c0d78de8d4fee3742381d77173ea50e828b47b.zip
r: update highlights
-rwxr-xr-xqueries/r/highlights.scm35
-rw-r--r--tests/query/highlights/r/test.r47
2 files changed, 73 insertions, 9 deletions
diff --git a/queries/r/highlights.scm b/queries/r/highlights.scm
index 179200d34..01d089559 100755
--- a/queries/r/highlights.scm
+++ b/queries/r/highlights.scm
@@ -17,10 +17,25 @@
(identifier) @variable
+((dollar (identifier) @variable.builtin)
+ (#eq? @variable.builtin "self"))
+
+((dollar _ (identifier) @field))
+
+; Parameters
+
(formal_parameters (identifier) @parameter)
+
(formal_parameters
(default_parameter name: (identifier) @parameter))
+(default_argument name: (identifier) @parameter)
+
+; Namespace
+
+(namespace_get namespace: (identifier) @namespace)
+(namespace_get_internal namespace: (identifier) @namespace)
+
; Operators
[
"="
@@ -34,6 +49,7 @@
"+"
"!"
"~"
+ "?"
] @operator)
(binary operator: [
@@ -90,7 +106,7 @@
(nan)
(na)
(null)
-] @type.builtin
+] @constant.builtin
[
"if"
@@ -111,17 +127,18 @@
"function" @keyword.function
-(call function: (identifier) @function)
-(default_argument name: (identifier) @parameter)
+; Functions/Methos
+
+(call function: (identifier) @function.call)
-(namespace_get function: (identifier) @method)
-(namespace_get_internal function: (identifier) @method)
+(call
+ (namespace_get function: (identifier) @function.call))
-(namespace_get namespace: (identifier) @namespace
- "::" @operator)
+(call
+ (namespace_get_internal function: (identifier) @function.call))
-(namespace_get_internal namespace: (identifier) @namespace
- ":::" @operator)
+(call
+ function: ((dollar _ (identifier) @method.call)))
; Error
(ERROR) @error
diff --git a/tests/query/highlights/r/test.r b/tests/query/highlights/r/test.r
new file mode 100644
index 000000000..8daf704ea
--- /dev/null
+++ b/tests/query/highlights/r/test.r
@@ -0,0 +1,47 @@
+init <- 1
+# ^ @variable
+# ^ @operator
+# ^ @float
+
+r"{(\1\2)}" -> `%r%`
+# ^ @string
+# ^ @string.escape
+# ^ @operator
+# ^ @variable
+
+
+foo <- c(1L, 2L)
+# ^ @function.call
+# ^ @number
+
+b <- list(TRUE, FALSE, NA, Inf)
+# ^ @boolean
+# ^ @boolean
+# ^ @constant.builtin
+# ^ @constant.builtin
+
+b <- list(name = "r", version = R.version$major)
+# ^ @parameter
+# ^ @string
+# ^ @punctuation.special
+# ^ @field
+
+Lang$new(name = "r")$print()
+# ^ @method.call
+
+for(i in 1:10) {
+# <- @repeat
+# ^ @keyword
+}
+
+add <- function(a, b = 1, ...) {
+# ^ @keyword.function
+# ^ @parameter
+# ^ @parameter
+# ^ @keyword
+ return(a + b)
+}
+
+base::letters
+# ^ @namespace
+# ^ @variable