mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-17 19:00:02 -04:00
r: update highlights
This commit is contained in:
parent
ae5ab287bb
commit
58c0d78de8
2 changed files with 73 additions and 9 deletions
|
|
@ -17,10 +17,25 @@
|
||||||
|
|
||||||
(identifier) @variable
|
(identifier) @variable
|
||||||
|
|
||||||
|
((dollar (identifier) @variable.builtin)
|
||||||
|
(#eq? @variable.builtin "self"))
|
||||||
|
|
||||||
|
((dollar _ (identifier) @field))
|
||||||
|
|
||||||
|
; Parameters
|
||||||
|
|
||||||
(formal_parameters (identifier) @parameter)
|
(formal_parameters (identifier) @parameter)
|
||||||
|
|
||||||
(formal_parameters
|
(formal_parameters
|
||||||
(default_parameter name: (identifier) @parameter))
|
(default_parameter name: (identifier) @parameter))
|
||||||
|
|
||||||
|
(default_argument name: (identifier) @parameter)
|
||||||
|
|
||||||
|
; Namespace
|
||||||
|
|
||||||
|
(namespace_get namespace: (identifier) @namespace)
|
||||||
|
(namespace_get_internal namespace: (identifier) @namespace)
|
||||||
|
|
||||||
; Operators
|
; Operators
|
||||||
[
|
[
|
||||||
"="
|
"="
|
||||||
|
|
@ -34,6 +49,7 @@
|
||||||
"+"
|
"+"
|
||||||
"!"
|
"!"
|
||||||
"~"
|
"~"
|
||||||
|
"?"
|
||||||
] @operator)
|
] @operator)
|
||||||
|
|
||||||
(binary operator: [
|
(binary operator: [
|
||||||
|
|
@ -90,7 +106,7 @@
|
||||||
(nan)
|
(nan)
|
||||||
(na)
|
(na)
|
||||||
(null)
|
(null)
|
||||||
] @type.builtin
|
] @constant.builtin
|
||||||
|
|
||||||
[
|
[
|
||||||
"if"
|
"if"
|
||||||
|
|
@ -111,17 +127,18 @@
|
||||||
|
|
||||||
"function" @keyword.function
|
"function" @keyword.function
|
||||||
|
|
||||||
(call function: (identifier) @function)
|
; Functions/Methos
|
||||||
(default_argument name: (identifier) @parameter)
|
|
||||||
|
|
||||||
(namespace_get function: (identifier) @method)
|
(call function: (identifier) @function.call)
|
||||||
(namespace_get_internal function: (identifier) @method)
|
|
||||||
|
|
||||||
(namespace_get namespace: (identifier) @namespace
|
(call
|
||||||
"::" @operator)
|
(namespace_get function: (identifier) @function.call))
|
||||||
|
|
||||||
(namespace_get_internal namespace: (identifier) @namespace
|
(call
|
||||||
":::" @operator)
|
(namespace_get_internal function: (identifier) @function.call))
|
||||||
|
|
||||||
|
(call
|
||||||
|
function: ((dollar _ (identifier) @method.call)))
|
||||||
|
|
||||||
; Error
|
; Error
|
||||||
(ERROR) @error
|
(ERROR) @error
|
||||||
|
|
|
||||||
47
tests/query/highlights/r/test.r
Normal file
47
tests/query/highlights/r/test.r
Normal file
|
|
@ -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
|
||||||
Loading…
Add table
Add a link
Reference in a new issue