Add support for R language.

This commit is contained in:
echasnovski 2021-03-09 21:06:07 +02:00 committed by Kiyan
parent df81a91ba9
commit 773ec8eefc
3 changed files with 105 additions and 0 deletions

View file

@ -474,6 +474,14 @@ list.svelte = {
maintainers = { "@elianiva" },
}
list.r = {
install_info = {
url = "https://github.com/r-lib/tree-sitter-r",
files = { "src/parser.c" }
},
maintainers = { "@jimhester" },
}
local M = {
list = list
}

86
queries/r/highlights.scm Executable file
View file

@ -0,0 +1,86 @@
; highlights.scm
(call function: (identifier) @function)
(namespace_get function: (identifier) @function.method)
(namespace_get_internal function: (identifier) @function.method)
; Literals
(integer) @number
(float) @number
(complex) @number
(string) @string
(comment) @comment
(formal_parameters (identifier) @variable.parameter)
(identifier) @variable
; Operators
[
"="
"<-"
"<<-"
"->"
] @operator
(unary operator: [
"-"
"+"
"!"
"~"
] @operator)
(binary operator: [
"-"
"+"
"*"
"/"
"^"
"<"
">"
"<="
">="
"=="
"!="
"||"
"|"
"&&"
"&"
":"
"~"
] @operator)
(special) @operator
[
"("
")"
"["
"]"
"{"
"}"
] @punctuation.bracket
[
"while"
"if"
"else"
"function"
"repeat"
"for"
"in"
(dots)
(true)
(false)
(break)
(next)
(inf)
(nan)
(na)
(null)
] @keyword

11
queries/r/locals.scm Executable file
View file

@ -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