|
60 | 60 | ''' |
61 | 61 | 'patterns': [ |
62 | 62 | { |
63 | | - 'captures': |
64 | | - '1': |
| 63 | + 'begin': '\\bclass\\b' |
| 64 | + 'beginCaptures': |
| 65 | + '0': |
65 | 66 | 'name': 'keyword.control.class.ruby' |
66 | | - '2': |
67 | | - 'name': 'entity.name.type.class.ruby' |
68 | | - '4': |
69 | | - 'name': 'entity.other.inherited-class.ruby' |
70 | | - '5': |
71 | | - 'name': 'punctuation.separator.inheritance.ruby' |
72 | | - '6': |
73 | | - 'name': 'variable.other.object.ruby' |
74 | | - '7': |
75 | | - 'name': 'punctuation.definition.variable.ruby' |
76 | | - 'match': '''(?x) |
77 | | - ^\\s*(class)\\s+ |
78 | | - ( |
79 | | - ( |
80 | | - [.a-zA-Z0-9_:]+ |
81 | | - (\\s*(<)\\s*[.a-zA-Z0-9_:]+)? # class A < B |
82 | | - ) |
83 | | - | |
84 | | - ((<<)\\s*[.a-zA-Z0-9_:]+) # class << C |
85 | | - ) |
86 | | - ''' |
| 67 | + 'end': '\\s*$|(?![\\s\\w.:<])' |
87 | 68 | 'name': 'meta.class.ruby' |
| 69 | + 'patterns': [ |
| 70 | + { |
| 71 | + 'match': '[A-Z]\\w*' |
| 72 | + 'name': 'entity.name.type.class.ruby' |
| 73 | + } |
| 74 | + { |
| 75 | + 'include': '#separators' |
| 76 | + } |
| 77 | + { |
| 78 | + 'begin': '(<<)\\s*' |
| 79 | + 'beginCaptures': |
| 80 | + '1': |
| 81 | + 'name': 'punctuation.definition.variable.ruby' |
| 82 | + 'contentName': 'variable.other.object.ruby' |
| 83 | + 'end': '(?=$)|(?![\\s\\w.:])' |
| 84 | + 'patterns': [ |
| 85 | + { |
| 86 | + 'match': '[A-Z]\\w*' |
| 87 | + 'name': 'entity.name.type.class.ruby' |
| 88 | + } |
| 89 | + { |
| 90 | + 'include': '#separators' |
| 91 | + } |
| 92 | + ] |
| 93 | + } |
| 94 | + { |
| 95 | + 'begin': '(<)\\s*' |
| 96 | + 'beginCaptures': |
| 97 | + '1': |
| 98 | + 'name': 'punctuation.separator.inheritance.ruby' |
| 99 | + 'contentName': 'entity.other.inherited-class.ruby' |
| 100 | + 'end': '(?=$)|(?![\\s\\w.:])' |
| 101 | + 'patterns': [ |
| 102 | + { |
| 103 | + 'match': '[A-Z]\\w*' |
| 104 | + 'name': 'entity.name.type.class.ruby' |
| 105 | + } |
| 106 | + { |
| 107 | + 'include': '#separators' |
| 108 | + } |
| 109 | + ] |
| 110 | + } |
| 111 | + ] |
88 | 112 | } |
89 | 113 | { |
90 | | - 'captures': |
91 | | - '1': |
| 114 | + 'begin': '\\bmodule\\b' |
| 115 | + 'beginCaptures': |
| 116 | + '0': |
92 | 117 | 'name': 'keyword.control.module.ruby' |
93 | | - '2': |
94 | | - 'name': 'entity.name.type.module.ruby' |
95 | | - '3': |
96 | | - 'name': 'entity.other.inherited-class.module.first.ruby' |
97 | | - '4': |
98 | | - 'name': 'punctuation.separator.inheritance.ruby' |
99 | | - '5': |
100 | | - 'name': 'entity.other.inherited-class.module.second.ruby' |
101 | | - '6': |
102 | | - 'name': 'punctuation.separator.inheritance.ruby' |
103 | | - '7': |
104 | | - 'name': 'entity.other.inherited-class.module.third.ruby' |
105 | | - '8': |
106 | | - 'name': 'punctuation.separator.inheritance.ruby' |
107 | | - 'match': '''(?x) |
108 | | - ^\\s*(module)\\s+ |
109 | | - ( |
110 | | - ([A-Z]\\w*(::))? |
111 | | - ([A-Z]\\w*(::))? |
112 | | - ([A-Z]\\w*(::))* |
113 | | - [A-Z]\\w* |
114 | | - ) |
115 | | - ''' |
| 118 | + 'end': '\\s*$|(?![\\s\\w.:])' |
116 | 119 | 'name': 'meta.module.ruby' |
| 120 | + 'patterns': [ |
| 121 | + { |
| 122 | + 'match': '[A-Z]\\w*(?=::)' |
| 123 | + 'name': 'entity.other.inherited-class.module.ruby' |
| 124 | + } |
| 125 | + { |
| 126 | + 'match': '[A-Z]\\w*' |
| 127 | + 'name': 'entity.name.type.module.ruby' |
| 128 | + } |
| 129 | + { |
| 130 | + 'include': '#separators' |
| 131 | + } |
| 132 | + ] |
117 | 133 | } |
118 | 134 | { |
119 | 135 | 'comment': 'else if is a common mistake carried over from other languages. it works if you put in a second end, but it’s never what you want.' |
|
247 | 263 | (?=def\\b) # optimization to help Oniguruma fail fast |
248 | 264 | (?<=^|\\s)(def)\\s+ |
249 | 265 | ( |
250 | | - (?>[a-zA-Z_]\\w*(?>\\.|::))? # method prefix |
| 266 | + (?:(self)(\\.|::))? |
| 267 | + (?>[a-zA-Z_]\\w*(?>(\\.|::)))* # method prefix |
251 | 268 | (?> # method name |
252 | 269 | [a-zA-Z_]\\w*(?>[?!]|=(?!>))? |
253 | 270 | | |
|
262 | 279 | '2': |
263 | 280 | 'name': 'entity.name.function.ruby' |
264 | 281 | '3': |
| 282 | + 'name': 'variable.language.self.ruby' |
| 283 | + '4': |
| 284 | + 'name': 'punctuation.separator.method.ruby' |
| 285 | + '5': |
| 286 | + 'comment': 'Unfortunately, the repeated pattern (\\.|::)* only captures the last occurring separator' |
| 287 | + 'name': 'punctuation.separator.method.ruby' |
| 288 | + '6': |
265 | 289 | 'name': 'punctuation.definition.parameters.ruby' |
266 | 290 | 'comment': 'The method pattern comes from the symbol pattern. See there for an explanation.' |
267 | 291 | 'end': '\\)' |
|
291 | 315 | } |
292 | 316 | ] |
293 | 317 | } |
| 318 | + { |
| 319 | + 'match': ',' |
| 320 | + 'name': 'punctuation.separator.delimiter.ruby' |
| 321 | + } |
294 | 322 | ] |
295 | 323 | } |
296 | 324 | { |
297 | 325 | 'begin': '''(?x) |
298 | 326 | (?=def\\b) # optimization to help Oniguruma fail fast |
299 | 327 | (?<=^|\\s)(def)\\s+ |
300 | 328 | ( |
301 | | - (?>[a-zA-Z_]\\w*(?>\\.|::))? # method prefix |
| 329 | + (?:(self)(\\.|::))? |
| 330 | + (?>[a-zA-Z_]\\w*(?>(\\.|::)))* # method prefix |
302 | 331 | (?> # method name |
303 | 332 | [a-zA-Z_]\\w*(?>[?!]|=(?!>))? |
304 | 333 | | |
|
313 | 342 | 'name': 'keyword.control.def.ruby' |
314 | 343 | '2': |
315 | 344 | 'name': 'entity.name.function.ruby' |
| 345 | + '3': |
| 346 | + 'name': 'variable.language.self.ruby' |
| 347 | + '4': |
| 348 | + 'name': 'punctuation.separator.method.ruby' |
| 349 | + '5': |
| 350 | + 'comment': 'Unfortunately, the repeated pattern (\\.|::)* only captures the last occurring separator' |
| 351 | + 'name': 'punctuation.separator.method.ruby' |
316 | 352 | 'comment': 'same as the previous rule, but without parentheses around the arguments' |
317 | 353 | 'end': '$' |
318 | 354 | 'name': 'meta.function.method.with-arguments.ruby' |
|
338 | 374 | } |
339 | 375 | ] |
340 | 376 | } |
| 377 | + { |
| 378 | + 'match': ',' |
| 379 | + 'name': 'punctuation.separator.delimiter.ruby' |
| 380 | + } |
341 | 381 | ] |
342 | 382 | } |
343 | 383 | { |
|
346 | 386 | 'name': 'keyword.control.def.ruby' |
347 | 387 | '3': |
348 | 388 | 'name': 'entity.name.function.ruby' |
| 389 | + '4': |
| 390 | + 'name': 'variable.language.self.ruby' |
| 391 | + '5': |
| 392 | + 'name': 'punctuation.separator.method.ruby' |
| 393 | + '6': |
| 394 | + 'comment': 'Unfortunately, the repeated pattern (\\.|::)* only captures the last occurring separator' |
| 395 | + 'name': 'punctuation.separator.method.ruby' |
349 | 396 | 'comment': ' the optional name is just to catch the def also without a method-name' |
350 | 397 | 'match': '''(?x) |
351 | 398 | (?=def\\b) # optimization to help Oniguruma fail fast |
352 | 399 | (?<=^|\\s)(def)\\b |
353 | 400 | ( |
354 | 401 | \\s+ |
355 | 402 | ( |
356 | | - (?>[a-zA-Z_]\\w*(?>\\.|::))? # method prefix |
| 403 | + (?:(self)(\\.|::))? |
| 404 | + (?>[a-zA-Z_]\\w*(?>(\\.|::)))* # method prefix |
357 | 405 | (?> # method name |
358 | 406 | [a-zA-Z_]\\w*(?>[?!]|=(?!>))? |
359 | 407 | | |
|
1878 | 1926 | ] |
1879 | 1927 | } |
1880 | 1928 | { |
1881 | | - 'match': '=>' |
1882 | | - 'name': 'punctuation.separator.key-value' |
| 1929 | + 'include': '#separators' |
1883 | 1930 | } |
1884 | 1931 | { |
1885 | 1932 | 'match': '->' |
1886 | | - 'name': 'support.function.kernel.ruby' |
| 1933 | + 'name': 'support.function.kernel.arrow.ruby' |
1887 | 1934 | } |
1888 | 1935 | { |
1889 | 1936 | 'match': '<<=|%=|&{1,2}=|\\*=|\\*\\*=|\\+=|-=|\\^=|\\|{1,2}=|<<' |
|
1902 | 1949 | 'match': '(?<=^|[ \\t])!|&&|\\|\\||\\^' |
1903 | 1950 | 'name': 'keyword.operator.logical.ruby' |
1904 | 1951 | } |
1905 | | - { |
1906 | | - 'comment': 'Safe navigation operator' |
1907 | | - 'match': '(&\\.)\\s*(?![A-Z])' |
1908 | | - 'captures': |
1909 | | - '1': |
1910 | | - 'name': 'punctuation.separator.method.ruby' |
1911 | | - } |
1912 | 1952 | { |
1913 | 1953 | 'match': '(%|&|\\*\\*|\\*|\\+|-|/)' |
1914 | 1954 | 'name': 'keyword.operator.arithmetic.ruby' |
|
1921 | 1961 | 'match': '\\||~|>>' |
1922 | 1962 | 'name': 'keyword.operator.other.ruby' |
1923 | 1963 | } |
1924 | | - { |
1925 | | - 'match': ';' |
1926 | | - 'name': 'punctuation.separator.statement.ruby' |
1927 | | - } |
1928 | | - { |
1929 | | - 'match': ',' |
1930 | | - 'name': 'punctuation.separator.object.ruby' |
1931 | | - } |
1932 | | - { |
1933 | | - 'comment': 'Mark as namespace separator if double colons followed by capital letter' |
1934 | | - 'match': '(::)\\s*(?=[A-Z])' |
1935 | | - 'captures': |
1936 | | - '1': |
1937 | | - 'name': 'punctuation.separator.namespace.ruby' |
1938 | | - } |
1939 | | - { |
1940 | | - 'comment': 'Mark as method separator if double colons not followed by capital letter' |
1941 | | - 'match': '(\\.|::)\\s*(?![A-Z])' |
1942 | | - 'captures': |
1943 | | - '1': |
1944 | | - 'name': 'punctuation.separator.method.ruby' |
1945 | | - } |
1946 | | - { |
1947 | | - 'comment': 'Must come after method and constant separators to prefer double colons' |
1948 | | - 'match': ':' |
1949 | | - 'name': 'punctuation.separator.other.ruby' |
1950 | | - } |
1951 | 1964 | { |
1952 | 1965 | 'match': '{' |
1953 | 1966 | 'name': 'punctuation.section.scope.begin.ruby' |
|
2283 | 2296 | 'name': 'comment.line.number-sign.ruby' |
2284 | 2297 | } |
2285 | 2298 | ] |
| 2299 | + 'separators': |
| 2300 | + 'patterns': [ |
| 2301 | + { |
| 2302 | + 'match': '=>' |
| 2303 | + 'name': 'punctuation.separator.key-value.ruby' |
| 2304 | + } |
| 2305 | + { |
| 2306 | + 'match': ';' |
| 2307 | + 'name': 'punctuation.terminator.statement.ruby' |
| 2308 | + } |
| 2309 | + { |
| 2310 | + 'match': ',' |
| 2311 | + 'name': 'punctuation.separator.delimiter.ruby' |
| 2312 | + } |
| 2313 | + { |
| 2314 | + 'match': '(::)(?=\\s*[A-Z])' |
| 2315 | + 'captures': |
| 2316 | + '1': |
| 2317 | + 'name': 'punctuation.separator.namespace.ruby' |
| 2318 | + } |
| 2319 | + { |
| 2320 | + 'match': '&?\\.|::' |
| 2321 | + 'name': 'punctuation.separator.method.ruby' |
| 2322 | + } |
| 2323 | + { |
| 2324 | + 'match': ':' |
| 2325 | + 'name': 'punctuation.separator.other.ruby' |
| 2326 | + } |
| 2327 | + ] |
2286 | 2328 | 'yard': |
2287 | 2329 | 'patterns': [ |
2288 | 2330 | { |
|
0 commit comments