Skip to content

Commit 5074001

Browse files
authored
fix: update r queries (#736)
1 parent 7007cbc commit 5074001

File tree

4 files changed

+101
-93
lines changed

4 files changed

+101
-93
lines changed

queries/r/highlights.scm

Lines changed: 68 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,106 +1,90 @@
11
; highlights.scm
22

3-
43
; Literals
54

65
(integer) @number
7-
8-
(float) @float
9-
6+
(float) @number
107
(complex) @number
118

129
(string) @string
13-
(string (escape_sequence) @string.escape)
14-
15-
(comment) @comment
10+
(string (string_content (escape_sequence) @string.escape))
1611

17-
;; tune for tree-sitter-langs as it make all as variable
18-
;; (identifier) @variable
19-
(left_assignment name: (identifier) @variable)
20-
(equals_assignment name: (identifier) @variable)
21-
(right_assignment name: (identifier) @variable)
12+
; Comments
2213

23-
(formal_parameters (identifier) @parameter)
24-
(formal_parameters (default_parameter (identifier) @parameter))
14+
(comment) @comment
2515

2616
; Operators
27-
[
28-
"="
29-
"<-"
30-
"<<-"
31-
"->>"
32-
"->"
33-
] @operator
34-
35-
(unary operator: [
36-
"-"
37-
"+"
38-
"!"
39-
"~"
40-
] @operator)
41-
42-
(binary operator: [
43-
"-"
44-
"+"
45-
"*"
46-
"/"
47-
"^"
48-
"<"
49-
">"
50-
"<="
51-
">="
52-
"=="
53-
"!="
54-
"||"
55-
"|"
56-
"&&"
57-
"&"
58-
":"
59-
"~"
60-
] @operator)
6117

6218
[
63-
"|>"
64-
(special)
19+
"?" ":=" "=" "<-" "<<-" "->" "->>"
20+
"~" "|>" "||" "|" "&&" "&"
21+
"<" "<=" ">" ">=" "==" "!="
22+
"+" "-" "*" "/" "::" ":::"
23+
"**" "^" "$" "@" ":"
24+
"special"
6525
] @operator
6626

67-
(lambda_function "\\" @operator)
27+
; Punctuation
6828

6929
[
70-
"("
71-
")"
72-
"["
73-
"]"
74-
"{"
75-
"}"
30+
"(" ")"
31+
"{" "}"
32+
"[" "]"
33+
"[[" "]]"
7634
] @punctuation.bracket
7735

78-
(dollar "$" @operator)
36+
(comma) @punctuation.delimiter
7937

80-
(subset2
81-
[
82-
"[["
83-
"]]"
84-
] @punctuation.bracket)
38+
; Variables
8539

86-
[
87-
"in"
88-
(dots)
89-
(break)
90-
(next)
91-
(inf)
92-
] @keyword
40+
(identifier) @variable
41+
42+
; Functions
43+
44+
(binary_operator
45+
lhs: (identifier) @function
46+
operator: "<-"
47+
rhs: (function_definition)
48+
)
49+
50+
(binary_operator
51+
lhs: (identifier) @function
52+
operator: "="
53+
rhs: (function_definition)
54+
)
55+
56+
; Calls
57+
58+
(call function: (identifier) @function)
59+
60+
; Parameters
61+
62+
(parameters (parameter name: (identifier) @variable.parameter))
63+
(arguments (argument name: (identifier) @variable.parameter))
64+
65+
; Namespace
66+
67+
(namespace_operator lhs: (identifier) @namespace)
68+
69+
(call
70+
function: (namespace_operator rhs: (identifier) @function)
71+
)
72+
73+
; Keywords
74+
75+
(function_definition name: "function" @keyword.function)
76+
(function_definition name: "\\" @operator)
9377

9478
[
95-
(nan)
96-
(na)
97-
(null)
98-
] @type.builtin
79+
"in"
80+
(return)
81+
(next)
82+
(break)
83+
] @keyword
9984

10085
[
10186
"if"
10287
"else"
103-
"switch"
10488
] @conditional
10589

10690
[
@@ -114,19 +98,15 @@
11498
(false)
11599
] @boolean
116100

117-
"function" @keyword.function
118-
119-
(call function: (identifier) @function)
120-
(default_argument name: (identifier) @parameter)
121-
122-
123-
(namespace_get function: (identifier) @method)
124-
(namespace_get_internal function: (identifier) @method)
125-
126-
(namespace_get namespace: (identifier) @namespace
127-
"::" @operator)
128-
(namespace_get_internal namespace: (identifier) @namespace
129-
":::" @operator)
101+
[
102+
(null)
103+
(inf)
104+
(nan)
105+
(na)
106+
(dots)
107+
(dot_dot_i)
108+
] @constant.builtin
130109

131110
; Error
111+
132112
(ERROR) @error

queries/r/locals.scm

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,17 @@
22

33
(function_definition) @local.scope
44

5-
(formal_parameters (identifier) @local.definition)
5+
(argument name: (identifier) @local.definition)
6+
(parameter name: (identifier) @local.definition)
67

7-
(left_assignment name: (identifier) @local.definition)
8-
(equals_assignment name: (identifier) @local.definition)
9-
(right_assignment name: (identifier) @local.definition)
8+
(binary_operator
9+
lhs: (identifier) @local.definition
10+
operator: "<-")
11+
(binary_operator
12+
lhs: (identifier) @local.definition
13+
operator: "=")
14+
(binary_operator
15+
operator: "->"
16+
rhs: (identifier) @local.definition)
1017

1118
(identifier) @local.reference

queries/r/tags.scm

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
(binary_operator
2+
lhs: (identifier) @name
3+
operator: "<-"
4+
rhs: (function_definition)
5+
) @definition.function
6+
7+
(binary_operator
8+
lhs: (identifier) @name
9+
operator: "="
10+
rhs: (function_definition)
11+
) @definition.function
12+
13+
(call
14+
function: (identifier) @name
15+
) @reference.call
16+
17+
(call
18+
function: (namespace_operator
19+
rhs: (identifier) @name
20+
)
21+
) @reference.call

repos/r

Submodule r updated 139 files

0 commit comments

Comments
 (0)