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
 53; Identifiers
 54
 55((identifier) @constant.builtin
 56 (#match? @constant.builtin "^__(FILE|LINE|ENCODING)__$"))
 57
 58(file) @constant.builtin
 59(line) @constant.builtin
 60(encoding) @constant.builtin
 61
 62(hash_splat_nil
 63  "**" @operator
 64) @constant.builtin
 65
 66((constant) @constant
 67 (#match? @constant "^[A-Z\\d_]+$"))
 68
 69(global_variable) @constant
 70
 71(constant) @type
 72
 73(self) @variable.special
 74(super) @variable.special
 75
 76[
 77  (class_variable)
 78  (instance_variable)
 79] @variable.member
 80
 81
 82; Literals
 83
 84[
 85  (string)
 86  (bare_string)
 87  (subshell)
 88  (heredoc_body)
 89  (heredoc_beginning)
 90] @string
 91
 92[
 93  (simple_symbol)
 94  (delimited_symbol)
 95  (hash_key_symbol)
 96  (bare_symbol)
 97] @string.special.symbol
 98
 99(regex) @string.regex
100(escape_sequence) @escape
101
102[
103  (integer)
104  (float)
105] @number
106
107[
108  (nil)
109  (true)
110  (false)
111] @constant.builtin
112
113(comment) @comment
114
115; Operators
116
117[
118  "!"
119  "~"
120  "+"
121  "-"
122  "**"
123  "*"
124  "/"
125  "%"
126  "<<"
127  ">>"
128  "&"
129  "|"
130  "^"
131  ">"
132  "<"
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  (operator)
161] @operator
162
163[
164  ","
165  ";"
166  "."
167] @punctuation.delimiter
168
169[
170  "("
171  ")"
172  "["
173  "]"
174  "{"
175  "}"
176  "%w("
177  "%i("
178] @punctuation.bracket
179
180(interpolation
181  "#{" @punctuation.special
182  "}" @punctuation.special) @embedded