on master help sign in
Update Ruby Highlights (#6587)
3dd715aDanillo Melo
languages.toml+1−1
@@ -606,7 +606,7 @@ indent = { tab-width = 2, unit = " " }
606
606
607[[grammar]]
607[[grammar]]
608name = "ruby"
608name = "ruby"
609−source = { git = "https://github.com/tree-sitter/tree-sitter-ruby", rev = "4c600a463d97e36a0ca5ac57e11f3ac8c297a0fa" }
609+source = { git = "https://github.com/tree-sitter/tree-sitter-ruby", rev = "206c7077164372c596ffa8eaadb9435c28941364" }
610
610
611[[language]]
611[[language]]
612name = "bash"
612name = "bash"
runtime/queries/ruby/highlights.scm+82−38
@@ -1,44 +1,67 @@
1; Keywords
1; Keywords
2
2
3[
3[
4+ "BEGIN"
5+ "END"
4 "alias"
6 "alias"
5− "and"
6 "begin"
7 "begin"
7− "break"
8− "case"
9 "class"
8 "class"
10− "def"
11 "do"
9 "do"
12− "else"
13− "elsif"
14 "end"
10 "end"
15− "ensure"
16− "for"
17− "if"
18− "in"
19 "module"
11 "module"
20− "next"
12+ "in"
21− "or"
22 "rescue"
13 "rescue"
23− "retry"
14+ "ensure"
24− "return"
15+] @keyword
25− "then"
16+
26− "unless"
17+[
27− "until"
18+ "if"
19+ "else"
20+ "elsif"
28 "when"
21 "when"
22+ "case"
23+ "unless"
24+ "then"
25+] @keyword.control.conditional
26+
27+[
28+ "for"
29 "while"
29 "while"
30+ "retry"
31+ "until"
32+ "redo"
33+] @keyword.control.repeat
34+
35+[
30 "yield"
36 "yield"
37+ "return"
38+ "next"
39+ "break"
40+] @keyword.control.return
41+
42+[
43+ "def"
44+ "undef"
45+] @keyword.function
46+
47+((identifier) @keyword.control.import
48+ (#match? @keyword.control.import "^(require|require_relative|load|autoload)$"))
49+
50+[
51+ "or"
52+ "and"
53+ "not"
31−] @keyword
54+] @keyword.operator
32
55
33−((identifier) @keyword
56+((identifier) @keyword.control.exception
34− (#match? @keyword "^(private|protected|public)$"))
57+ (#match? @keyword.control.exception "^(raise|fail)$"))
35
58
36; Function calls
59; Function calls
37
60
38−((identifier) @function.method.builtin
61+((identifier) @function.builtin
39− (#eq? @function.method.builtin "require"))
62+ (#match? @function.builtin "^(attr|attr_accessor|attr_reader|attr_writer|include|prepend|refine|private|protected|public)$"))
40
63
41−"defined?" @function.method.builtin
64+"defined?" @function.builtin
42
65
43(call
66(call
44 method: [(identifier) (constant)] @function.method)
67 method: [(identifier) (constant)] @function.method)
@@ -58,7 +81,10 @@
58] @variable.other.member
81] @variable.other.member
59
82
60((identifier) @constant.builtin
83((identifier) @constant.builtin
61− (#match? @constant.builtin "^__(FILE|LINE|ENCODING)__$"))
84+ (#match? @constant.builtin "^(__FILE__|__LINE__|__ENCODING__)$"))
85+
86+((constant) @constant.builtin
87+ (#match? @constant.builtin "^(ENV|ARGV|ARGF|RUBY_PLATFORM|RUBY_RELEASE_DATE|RUBY_VERSION|STDERR|STDIN|STDOUT|TOPLEVEL_BINDING)$"))
62
88
63((constant) @constant
89((constant) @constant
64 (#match? @constant "^[A-Z\\d_]+$"))
90 (#match? @constant "^[A-Z\\d_]+$"))
@@ -66,22 +92,23 @@
66(constant) @constructor
92(constant) @constructor
67
93
68(self) @variable.builtin
94(self) @variable.builtin
69−(super) @variable.builtin
95+(super) @function.builtin
70
96
97+[(forward_parameter)(forward_argument)] @variable.parameter
98+(keyword_parameter name:((_)":" @variable.parameter) @variable.parameter)
99+(optional_parameter name:((_)"=" @operator) @variable.parameter)
100+(optional_parameter name: (identifier) @variable.parameter)
101+(splat_parameter name: (identifier) @variable.parameter) @variable.parameter
102+(hash_splat_parameter name: (identifier) @variable.parameter) @variable.parameter
103+(method_parameters (identifier) @variable.parameter)
71(block_parameter (identifier) @variable.parameter)
104(block_parameter (identifier) @variable.parameter)
72(block_parameters (identifier) @variable.parameter)
105(block_parameters (identifier) @variable.parameter)
73−(destructured_parameter (identifier) @variable.parameter)
74−(hash_splat_parameter (identifier) @variable.parameter)
75−(lambda_parameters (identifier) @variable.parameter)
76−(method_parameters (identifier) @variable.parameter)
77−(splat_parameter (identifier) @variable.parameter)
78−
79−(keyword_parameter name: (identifier) @variable.parameter)
80−(optional_parameter name: (identifier) @variable.parameter)
81
106
82((identifier) @function.method
107((identifier) @function.method
83 (#is-not? local))
108 (#is-not? local))
109+[
84−(identifier) @variable
110+ (identifier)
111+] @variable
85
112
86; Literals
113; Literals
87
114
@@ -96,10 +123,11 @@
96[
123[
97 (simple_symbol)
124 (simple_symbol)
98 (delimited_symbol)
125 (delimited_symbol)
99− (hash_key_symbol)
100 (bare_symbol)
126 (bare_symbol)
101] @string.special.symbol
127] @string.special.symbol
102
128
129+(pair key: ((_)":" @string.special.symbol) @string.special.symbol)
130+
103(regex) @string.regexp
131(regex) @string.regexp
104(escape_sequence) @constant.character.escape
132(escape_sequence) @constant.character.escape
105
133
@@ -112,7 +140,7 @@
112 (nil)
140 (nil)
113 (true)
141 (true)
114 (false)
142 (false)
115−]@constant.builtin
143+] @constant.builtin
116
144
117(interpolation
145(interpolation
118 "#{" @punctuation.special
146 "#{" @punctuation.special
@@ -121,20 +149,36 @@
121(comment) @comment
149(comment) @comment
122
150
123; Operators
151; Operators
124−
125[
152[
126−"="
153+":"
154+"?"
155+"~"
127"=>"
156"=>"
128"->"
157"->"
158+"!"
129] @operator
159] @operator
130
160
161+(assignment
162+ "=" @operator)
163+
164+(operator_assignment
165+ operator: ["+=" "-=" "*=" "**=" "/=" "||=" "|=" "&&=" "&=" "%=" ">>=" "<<=" "^="] @operator)
166+
167+(binary
168+ operator: ["/" "|" "==" "===" "||" "&&" ">>" "<<" "<" ">" "<=" ">=" "&" "^" "!~" "=~" "<=>" "**" "*" "!=" "%" "-" "+"] @operator)
169+
170+(range
171+ operator: [".." "..."] @operator)
172+
131[
173[
132 ","
174 ","
133 ";"
175 ";"
134 "."
176 "."
177+ "&."
135] @punctuation.delimiter
178] @punctuation.delimiter
136
179
137[
180[
181+ "|"
138 "("
182 "("
139 ")"
183 ")"
140 "["
184 "["
runtime/queries/ruby/injections.scm+6
@@ -1,2 +1,8 @@
1((comment) @injection.content
1((comment) @injection.content
2 (#set! injection.language "comment"))
2 (#set! injection.language "comment"))
3+
4+((heredoc_body
5+ (heredoc_content) @injection.content
6+ (heredoc_end) @name
7+ (#set! injection.language "sql"))
8+ (#eq? @name "SQL"))