highlights.scm

  1; Keywords
  2
  3[
  4  "alias"
  5  "and"
  6  "begin"
  7  "break"
  8  "case"
  9  "class"
 10  "def"
 11  "do"
 12  "else"
 13  "elsif"
 14  "end"
 15  "ensure"
 16  "for"
 17  "if"
 18  "in"
 19  "module"
 20  "next"
 21  "or"
 22  "rescue"
 23  "retry"
 24  "return"
 25  "then"
 26  "unless"
 27  "until"
 28  "when"
 29  "while"
 30  "yield"
 31] @keyword
 32
 33((identifier) @keyword
 34 (#match? @keyword "^(private|protected|public)$"))
 35
 36; Function calls
 37
 38((identifier) @function.method.builtin
 39 (#eq? @function.method.builtin "require"))
 40
 41"defined?" @function.method.builtin
 42
 43(call
 44  method: [(identifier) (constant)] @function.method)
 45
 46; Function definitions
 47
 48(alias (identifier) @function.method)
 49(setter (identifier) @function.method)
 50(method name: [(identifier) (constant)] @function.method)
 51(singleton_method name: [(identifier) (constant)] @function.method)
 52(method_parameters [
 53  (identifier) @variable.parameter
 54  (optional_parameter name: (identifier) @variable.parameter)
 55  (keyword_parameter [name: (identifier) (":")] @variable.parameter)
 56  ])
 57
 58; Identifiers
 59
 60((identifier) @constant.builtin
 61 (#match? @constant.builtin "^__(FILE|LINE|ENCODING)__$"))
 62
 63(file) @constant.builtin
 64(line) @constant.builtin
 65(encoding) @constant.builtin
 66
 67(hash_splat_nil
 68  "**" @operator
 69) @constant.builtin
 70
 71((constant) @constant
 72 (#match? @constant "^[A-Z\\d_]+$"))
 73
 74(global_variable) @constant
 75
 76(constant) @type
 77
 78(superclass
 79  (constant) @type.super)
 80
 81(superclass
 82  (scope_resolution
 83    (constant) @type.super))
 84
 85(superclass
 86  (scope_resolution
 87    (scope_resolution
 88      (constant) @type.super)))
 89
 90(self) @variable.special
 91(super) @variable.special
 92
 93[
 94  (class_variable)
 95  (instance_variable)
 96] @variable.member
 97
 98
 99; Literals
100
101[
102  (string)
103  (bare_string)
104  (subshell)
105  (heredoc_body)
106  (heredoc_beginning)
107] @string
108
109[
110  (simple_symbol)
111  (delimited_symbol)
112  (hash_key_symbol)
113  (bare_symbol)
114] @string.special.symbol
115
116(regex) @string.regex
117(escape_sequence) @escape
118
119[
120  (integer)
121  (float)
122] @number
123
124[
125  (nil)
126  (true)
127  (false)
128] @constant.builtin
129
130(comment) @comment
131
132; Operators
133
134[
135  "!"
136  "~"
137  "+"
138  "-"
139  "**"
140  "*"
141  "/"
142  "%"
143  "<<"
144  ">>"
145  "&"
146  "|"
147  "^"
148  ">"
149  "<"
150  "<="
151  ">="
152  "=="
153  "!="
154  "=~"
155  "!~"
156  "<=>"
157  "||"
158  "&&"
159  ".."
160  "..."
161  "="
162  "**="
163  "*="
164  "/="
165  "%="
166  "+="
167  "-="
168  "<<="
169  ">>="
170  "&&="
171  "&="
172  "||="
173  "|="
174  "^="
175  "=>"
176  "->"
177  (operator)
178] @operator
179
180[
181  ","
182  ";"
183  "."
184  "::"
185] @punctuation.delimiter
186
187[
188  "("
189  ")"
190  "["
191  "]"
192  "{"
193  "}"
194  "%w("
195  "%i("
196] @punctuation.bracket
197
198(interpolation
199  "#{" @punctuation.special
200  "}" @punctuation.special) @embedded