on master help sign in
Update Ruby Highlights (#6587)

* update ruby highlights * Updated SQL injection.scm * Move private, public, protected to builtin methods

commit3dd715a115880831e3a0f75a3c00f0b6e1a8364f authorDanillo Melo <danillos@gmail.com> dateThu 6 Apr 2023, 13:37 (4 years ago) parent4b32b54
3 files changed+89−39
languages.toml+1−1 runtime/queries/ruby/highlights.scm+82−38 runtime/queries/ruby/injections.scm+6
languages.toml+1−1
@@ -606,7 +606,7 @@ indent = { tab-width = 2, unit = " " }
606606
607607[[grammar]]
608608name = "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" }
610610
611611[[language]]
612612name = "bash"
runtime/queries/ruby/highlights.scm+82−38
@@ -1,44 +1,67 @@
11; Keywords
22
33[
4+ "BEGIN"
5+ "END"
46 "alias"
5− "and"
67 "begin"
7− "break"
8− "case"
98 "class"
10− "def"
119 "do"
12− "else"
13− "elsif"
1410 "end"
15− "ensure"
16− "for"
17− "if"
18− "in"
1911 "module"
20− "next"
21− "or"
12+ "in"
2213 "rescue"
23− "retry"
24− "return"
25− "then"
26− "unless"
27− "until"
14+ "ensure"
15+] @keyword
16+
17+[
18+ "if"
19+ "else"
20+ "elsif"
2821 "when"
22+ "case"
23+ "unless"
24+ "then"
25+] @keyword.control.conditional
26+
27+[
28+ "for"
2929 "while"
30+ "retry"
31+ "until"
32+ "redo"
33+] @keyword.control.repeat
34+
35+[
3036 "yield"
31−] @keyword
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"
54+] @keyword.operator
3255
33−((identifier) @keyword
34− (#match? @keyword "^(private|protected|public)$"))
56+((identifier) @keyword.control.exception
57+ (#match? @keyword.control.exception "^(raise|fail)$"))
3558
3659; Function calls
3760
38−((identifier) @function.method.builtin
39− (#eq? @function.method.builtin "require"))
61+((identifier) @function.builtin
62+ (#match? @function.builtin "^(attr|attr_accessor|attr_reader|attr_writer|include|prepend|refine|private|protected|public)$"))
4063
41−"defined?" @function.method.builtin
64+"defined?" @function.builtin
4265
4366(call
4467 method: [(identifier) (constant)] @function.method)
@@ -58,7 +81,10 @@
5881] @variable.other.member
5982
6083((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)$"))
6288
6389((constant) @constant
6490 (#match? @constant "^[A-Z\\d_]+$"))
@@ -66,22 +92,23 @@
6692(constant) @constructor
6793
6894(self) @variable.builtin
69−(super) @variable.builtin
95+(super) @function.builtin
7096
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)
71104(block_parameter (identifier) @variable.parameter)
72105(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)
81106
82107((identifier) @function.method
83108 (#is-not? local))
84−(identifier) @variable
109+[
110+ (identifier)
111+] @variable
85112
86113; Literals
87114
@@ -96,10 +123,11 @@
96123[
97124 (simple_symbol)
98125 (delimited_symbol)
99− (hash_key_symbol)
100126 (bare_symbol)
101127] @string.special.symbol
102128
129+(pair key: ((_)":" @string.special.symbol) @string.special.symbol)
130+
103131(regex) @string.regexp
104132(escape_sequence) @constant.character.escape
105133
@@ -112,7 +140,7 @@
112140 (nil)
113141 (true)
114142 (false)
115−]@constant.builtin
143+] @constant.builtin
116144
117145(interpolation
118146 "#{" @punctuation.special
@@ -121,20 +149,36 @@
121149(comment) @comment
122150
123151; Operators
124−
125152[
126−"="
153+":"
154+"?"
155+"~"
127156"=>"
128157"->"
158+"!"
129159] @operator
130160
161+(assignment
162+ "=" @operator)
163+
164+(operator_assignment
165+ operator: ["+=" "-=" "*=" "**=" "/=" "||=" "|=" "&&=" "&=" "%=" ">>=" "<<=" "^="] @operator)
166+
167+(binary
168+ operator: ["/" "|" "==" "===" "||" "&&" ">>" "<<" "<" ">" "<=" ">=" "&" "^" "!~" "=~" "<=>" "**" "*" "!=" "%" "-" "+"] @operator)
169+
170+(range
171+ operator: [".." "..."] @operator)
172+
131173[
132174 ","
133175 ";"
134176 "."
177+ "&."
135178] @punctuation.delimiter
136179
137180[
181+ "|"
138182 "("
139183 ")"
140184 "["
runtime/queries/ruby/injections.scm+6
@@ -1,2 +1,8 @@
11((comment) @injection.content
22 (#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"))