Created
July 26, 2008 05:16
-
-
Save foca/2599 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ scopeName = 'source.ruby'; | |
comment = ' | |
TODO: unresolved issues | |
text: | |
"p << end | |
print me! | |
end" | |
symptoms: | |
not recognized as a heredoc | |
solution: | |
there is no way to distinguish perfectly between the << operator and the start | |
of a heredoc. Currently, we require assignment to recognize a heredoc. More | |
refinement is possible. | |
• Heredocs with indented terminators (<<-) are always distinguishable, however. | |
• Nested heredocs are not really supportable at present | |
text: | |
print <<-''THERE'' | |
This is single quoted. | |
The above used #{Time.now} | |
THERE | |
symtoms: | |
From Programming Ruby p306; should be a non-interpolated heredoc. | |
text: | |
"a\332a" | |
symptoms: | |
''\332'' is not recognized as slash3.. which should be octal 332. | |
solution: | |
plain regexp.. should be easy. | |
text: | |
val?(a):p(b) | |
val?''a'':''b'' | |
symptoms: | |
'':p'' is recognized as a symbol.. its 2 things '':'' and ''p''. | |
:''b'' has same problem. | |
solution: | |
ternary operator rule, precedence stuff, symbol rule. | |
but also consider ''a.b?(:c)'' ?? | |
'; | |
firstLineMatch = '^#!/.*\bruby\b'; | |
fileTypes = ( 'rbx', 'rjs', 'Rakefile', 'rake', 'cgi', 'fcgi', 'gemspec', 'irbrc', 'capfile', 'Capfile', 'autotest' ); | |
foldingStartMarker = '(?x)^ | |
(\s*+ | |
(module|class|def(?!.*\bend\s*$) | |
|unless|if | |
|case | |
|begin | |
|for|while|until | |
|^=begin | |
|( "(\\.|[^"])*+" # eat a double quoted string | |
| ''(\\.|[^''])*+'' # eat a single quoted string | |
| [^#"''] # eat all but comments and strings | |
)* | |
( \s (do|begin|case) | |
| (?<!\$)[-+=&|*/~%^<>~] \s*+ (if|unless) | |
) | |
)\b | |
(?! [^;]*+ ; .*? \bend\b ) | |
|( "(\\.|[^"])*+" # eat a double quoted string | |
| ''(\\.|[^''])*+'' # eat a single quoted string | |
| [^#"''] # eat all but comments and strings | |
)* | |
( \{ (?! [^}]*+ \} ) | |
| \[ (?! [^\]]*+ \] ) | |
) | |
).*$ | |
| [#] .*? \(fold\) \s*+ $ # Sune’s special marker | |
'; | |
foldingStopMarker = '(?x) | |
( (^|;) \s*+ end \s*+ ([#].*)? $ | |
| (^|;) \s*+ end \. .* $ | |
| ^ \s*+ [}\]] ,? \s*+ ([#].*)? $ | |
| [#] .*? \(end\) \s*+ $ # Sune’s special marker | |
| ^=end | |
)'; | |
patterns = ( | |
{ name = 'meta.class.ruby'; | |
match = '^\s*(class)\s+(([.a-zA-Z0-9_:]+(\s*(<)\s*[.a-zA-Z0-9_:]+)?)|((<<)\s*[.a-zA-Z0-9_:]+))'; | |
captures = { | |
1 = { name = 'keyword.control.class.ruby'; }; | |
2 = { name = 'entity.name.type.class.ruby'; }; | |
4 = { name = 'entity.other.inherited-class.ruby'; }; | |
5 = { name = 'punctuation.separator.inheritance.ruby'; }; | |
6 = { name = 'variable.other.object.ruby'; }; | |
7 = { name = 'punctuation.definition.variable.ruby'; }; | |
}; | |
}, | |
{ name = 'meta.module.ruby'; | |
match = '^\s*(module)\s+(([A-Z]\w*(::))?([A-Z]\w*(::))?([A-Z]\w*(::))*[A-Z]\w*)'; | |
captures = { | |
1 = { name = 'keyword.control.module.ruby'; }; | |
2 = { name = 'entity.name.type.module.ruby'; }; | |
3 = { name = 'entity.other.inherited-class.module.first.ruby'; }; | |
4 = { name = 'punctuation.separator.inheritance.ruby'; }; | |
5 = { name = 'entity.other.inherited-class.module.second.ruby'; }; | |
6 = { name = 'punctuation.separator.inheritance.ruby'; }; | |
7 = { name = 'entity.other.inherited-class.module.third.ruby'; }; | |
8 = { name = 'punctuation.separator.inheritance.ruby'; }; | |
}; | |
}, | |
{ name = 'invalid.deprecated.ruby'; | |
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.'; | |
match = '(?<!\.)\belse(\s)+if\b'; | |
}, | |
{ name = 'keyword.control.ruby'; | |
comment = "everything being a reserved word, not a value and needing a 'end' is a.."; | |
match = '(?<!\.)\b(BEGIN|begin|case|class|else|elsif|END|end|ensure|for|if|in|module|rescue|then|unless|until|when|while)\b(?![?!])'; | |
}, | |
{ name = 'keyword.control.start-block.ruby'; | |
comment = 'contextual smart pair support for block parameters'; | |
match = '(?<!\.)\bdo\b\s*'; | |
}, | |
{ name = 'meta.syntax.ruby.start-block'; | |
comment = 'contextual smart pair support'; | |
match = '(?<=\{)(\s+)'; | |
}, | |
{ name = 'keyword.operator.logical.ruby'; | |
comment = " as above, just doesn't need a 'end' and does a logic operation"; | |
match = '(?<!\.)\b(and|not|or)\b'; | |
}, | |
{ name = 'keyword.control.pseudo-method.ruby'; | |
comment = ' just as above but being not a logical operation'; | |
match = '(?<!\.)\b(alias|alias_method|break|next|redo|retry|return|super|undef|yield)\b(?![?!])|\bdefined\?|\bblock_given\?'; | |
}, | |
{ name = 'constant.language.ruby'; | |
match = '\b(nil|true|false)\b(?![?!])'; | |
}, | |
{ name = 'variable.language.ruby'; | |
match = '\b(__(FILE|LINE)__|self)\b(?![?!])'; | |
}, | |
{ name = 'keyword.other.special-method.ruby'; | |
comment = ' everything being a method but having a special function is a..'; | |
match = '\b(initialize|new|loop|include|extend|raise|attr_reader|attr_writer|attr_accessor|attr|catch|throw|private|module_function|public|protected)\b(?![?!])'; | |
}, | |
{ name = 'meta.require.ruby'; | |
begin = '\b(require)\b'; | |
end = '$|(?=#)'; | |
captures = { 1 = { name = 'keyword.other.special-method.ruby'; }; }; | |
patterns = ( { include = '$self'; } ); | |
}, | |
{ name = 'variable.other.readwrite.instance.ruby'; | |
match = '(@)[a-zA-Z_]\w*'; | |
captures = { 1 = { name = 'punctuation.definition.variable.ruby'; }; }; | |
}, | |
{ name = 'variable.other.readwrite.class.ruby'; | |
match = '(@@)[a-zA-Z_]\w*'; | |
captures = { 1 = { name = 'punctuation.definition.variable.ruby'; }; }; | |
}, | |
{ name = 'variable.other.readwrite.global.ruby'; | |
match = '(\$)[a-zA-Z_]\w*'; | |
captures = { 1 = { name = 'punctuation.definition.variable.ruby'; }; }; | |
}, | |
{ name = 'variable.other.readwrite.global.pre-defined.ruby'; | |
match = '(\$)(!|@|&|`|''|\+|\d+|~|=|/|\\|,|;|\.|<|>|_|\*|\$|\?|:|"|-[0adFiIlpv])'; | |
captures = { 1 = { name = 'punctuation.definition.variable.ruby'; }; }; | |
}, | |
{ name = 'meta.environment-variable.ruby'; | |
begin = '\b(ENV)\['; | |
end = '\]'; | |
beginCaptures = { 1 = { name = 'variable.other.constant.ruby'; }; }; | |
patterns = ( { include = '$self'; } ); | |
}, | |
{ name = 'support.class.ruby'; | |
match = '\b[A-Z]\w*(?=((\.|::)[A-Za-z]|\[))'; | |
}, | |
{ name = 'variable.other.constant.ruby'; | |
match = '\b[A-Z]\w*\b'; | |
}, | |
{ name = 'meta.function.method.with-arguments.ruby'; | |
contentName = 'variable.parameter.function.ruby'; | |
comment = ' the method pattern comes from the symbol pattern, see there for a explaination'; | |
begin = '(?<=^|\s)\b(def)\b\s+((?>[a-zA-Z_]\w*(?>\.|::))?(?>[a-zA-Z_]\w*(?>[?!]|=(?!>))?|===?|>[>=]?|<=>|<[<=]?|[%&`/\|]|\*\*?|=?~|[-+]@?|\[\]=?))\s*(\()'; | |
end = '\)'; | |
beginCaptures = { | |
1 = { name = 'keyword.control.def.ruby'; }; | |
2 = { name = 'entity.name.function.ruby'; }; | |
3 = { name = 'punctuation.definition.parameters.ruby'; }; | |
}; | |
endCaptures = { 0 = { name = 'punctuation.definition.parameters.ruby'; }; }; | |
patterns = ( { include = '$self'; } ); | |
}, | |
{ name = 'meta.function.method.without-arguments.ruby'; | |
comment = ' the optional name is just to catch the def also without a method-name'; | |
match = '(?<=^|\s)(def)\b(\s+((?>[a-zA-Z_]\w*(?>\.|::))?(?>[a-zA-Z_]\w*(?>[?!]|=(?!>))?|===?|>[>=]?|<=>|<[<=]?|[%&`/\|]|\*\*?|=?~|[-+]@?|\[\]=?)))?'; | |
captures = { | |
1 = { name = 'keyword.control.def.ruby'; }; | |
3 = { name = 'entity.name.function.ruby'; }; | |
}; | |
}, | |
{ name = 'constant.numeric.ruby'; | |
match = '\b(0[xX]\h(?>_?\h)*|\d(?>_?\d)*(\.(?![^[:space:][:digit:]])(?>_?\d)*)?([eE][-+]?\d(?>_?\d)*)?|0[bB][01]+)\b'; | |
}, | |
{ name = 'constant.other.symbol.single-quoted.ruby'; | |
begin = ":'"; | |
end = "'"; | |
captures = { 0 = { name = 'punctuation.definition.constant.ruby'; }; }; | |
patterns = ( | |
{ name = 'constant.character.escape.ruby'; | |
match = '\\[''\\]'; | |
}, | |
); | |
}, | |
{ name = 'constant.other.symbol.double-quoted.ruby'; | |
begin = ':"'; | |
end = '"'; | |
captures = { 0 = { name = 'punctuation.definition.constant.ruby'; }; }; | |
patterns = ( | |
{ include = '#interpolated_ruby'; }, | |
{ include = '#escaped_char'; }, | |
); | |
}, | |
{ name = 'string.quoted.single.ruby'; | |
comment = 'single quoted string (does not allow interpolation)'; | |
begin = "'"; | |
end = "'"; | |
beginCaptures = { 0 = { name = 'punctuation.definition.string.begin.ruby'; }; }; | |
endCaptures = { 0 = { name = 'punctuation.definition.string.end.ruby'; }; }; | |
patterns = ( | |
{ name = 'constant.character.escape.ruby'; | |
match = '\\''|\\\\'; | |
}, | |
); | |
}, | |
{ name = 'string.quoted.double.ruby'; | |
comment = 'double quoted string (allows for interpolation)'; | |
begin = '"'; | |
end = '"'; | |
beginCaptures = { 0 = { name = 'punctuation.definition.string.begin.ruby'; }; }; | |
endCaptures = { 0 = { name = 'punctuation.definition.string.end.ruby'; }; }; | |
patterns = ( | |
{ include = '#interpolated_ruby'; }, | |
{ include = '#escaped_char'; }, | |
); | |
}, | |
{ name = 'string.interpolated.ruby'; | |
comment = 'execute string (allows for interpolation)'; | |
begin = '`'; | |
end = '`'; | |
beginCaptures = { 0 = { name = 'punctuation.definition.string.begin.ruby'; }; }; | |
endCaptures = { 0 = { name = 'punctuation.definition.string.end.ruby'; }; }; | |
patterns = ( | |
{ include = '#interpolated_ruby'; }, | |
{ include = '#escaped_char'; }, | |
); | |
}, | |
{ name = 'string.interpolated.ruby'; | |
comment = 'execute string (allow for interpolation)'; | |
begin = '%x\{'; | |
end = '\}'; | |
beginCaptures = { 0 = { name = 'punctuation.definition.string.begin.ruby'; }; }; | |
endCaptures = { 0 = { name = 'punctuation.definition.string.end.ruby'; }; }; | |
patterns = ( | |
{ include = '#interpolated_ruby'; }, | |
{ include = '#escaped_char'; }, | |
{ include = '#nest_curly_i'; }, | |
); | |
}, | |
{ name = 'string.interpolated.ruby'; | |
comment = 'execute string (allow for interpolation)'; | |
begin = '%x\['; | |
end = '\]'; | |
beginCaptures = { 0 = { name = 'punctuation.definition.string.begin.ruby'; }; }; | |
endCaptures = { 0 = { name = 'punctuation.definition.string.end.ruby'; }; }; | |
patterns = ( | |
{ include = '#interpolated_ruby'; }, | |
{ include = '#escaped_char'; }, | |
{ include = '#nest_brackets_i'; }, | |
); | |
}, | |
{ name = 'string.interpolated.ruby'; | |
comment = 'execute string (allow for interpolation)'; | |
begin = '%x\<'; | |
end = '\>'; | |
beginCaptures = { 0 = { name = 'punctuation.definition.string.begin.ruby'; }; }; | |
endCaptures = { 0 = { name = 'punctuation.definition.string.end.ruby'; }; }; | |
patterns = ( | |
{ include = '#interpolated_ruby'; }, | |
{ include = '#escaped_char'; }, | |
{ include = '#nest_ltgt_i'; }, | |
); | |
}, | |
{ name = 'string.interpolated.ruby'; | |
comment = 'execute string (allow for interpolation)'; | |
begin = '%x\('; | |
end = '\)'; | |
beginCaptures = { 0 = { name = 'punctuation.definition.string.begin.ruby'; }; }; | |
endCaptures = { 0 = { name = 'punctuation.definition.string.end.ruby'; }; }; | |
patterns = ( | |
{ include = '#interpolated_ruby'; }, | |
{ include = '#escaped_char'; }, | |
{ include = '#nest_parens_i'; }, | |
); | |
}, | |
{ name = 'string.interpolated.ruby'; | |
comment = 'execute string (allow for interpolation)'; | |
begin = '%x([^\w])'; | |
end = '\1'; | |
beginCaptures = { 0 = { name = 'punctuation.definition.string.begin.ruby'; }; }; | |
endCaptures = { 0 = { name = 'punctuation.definition.string.end.ruby'; }; }; | |
patterns = ( | |
{ include = '#interpolated_ruby'; }, | |
{ include = '#escaped_char'; }, | |
); | |
}, | |
{ contentName = 'string.regexp.classic.ruby'; | |
comment = 'regular expressions (normal) | |
we only start a regexp if the character before it (excluding whitespace) | |
is what we think is before a regexp | |
'; | |
begin = '(?x) | |
(?: | |
^ # beginning of line | |
| (?<= # or look-behind on: | |
[=>~(?:\[,|&;] | |
| (?:\s|;)when\s | |
| (?:\s|;)or\s | |
| (?:\s|;)and\s | |
| (?:\s|;)not\s | |
| (?:\s|;|\.)index\s | |
| (?:\s|;|\.)scan\s | |
| (?:\s|;|\.)sub\s | |
| (?:\s|l|\.)sub!\s | |
| (?:\s|;|\.)gsub\s | |
| (?:\s|;|\.)gsub!\s | |
| (?:\s|;|\.)match\s | |
| (?:\s|;)if\s | |
| (?:\s|;)elsif\s | |
| (?:\s|;)while\s | |
| (?:\s|;)unless\s | |
) | |
| (?<= # or a look-behind with line anchor: | |
^when\s # duplication necessary due to limits of regex | |
| ^index\s | |
| ^scan\s | |
| ^sub\s | |
| ^gsub\s | |
| ^sub!\s | |
| ^gsub!\s | |
| ^match\s | |
| ^if\s | |
| ^elsif\s | |
| ^while\s | |
| ^unless\s | |
) | |
) | |
\s*((/))(?![*+{}?]) | |
'; | |
end = '((/[eimnosux]*))'; | |
captures = { | |
1 = { name = 'string.regexp.classic.ruby'; }; | |
2 = { name = 'punctuation.definition.string.ruby'; }; | |
}; | |
patterns = ( { include = '#regex_sub'; } ); | |
}, | |
{ name = 'string.regexp.mod-r.ruby'; | |
comment = 'regular expressions (literal)'; | |
begin = '%r\{'; | |
end = '\}[eimnosux]*'; | |
beginCaptures = { 0 = { name = 'punctuation.definition.string.begin.ruby'; }; }; | |
endCaptures = { 0 = { name = 'punctuation.definition.string.end.ruby'; }; }; | |
patterns = ( | |
{ include = '#regex_sub'; }, | |
{ include = '#nest_curly_r'; }, | |
); | |
}, | |
{ name = 'string.regexp.mod-r.ruby'; | |
comment = 'regular expressions (literal)'; | |
begin = '%r\['; | |
end = '\][eimnosux]*'; | |
beginCaptures = { 0 = { name = 'punctuation.definition.string.begin.ruby'; }; }; | |
endCaptures = { 0 = { name = 'punctuation.definition.string.end.ruby'; }; }; | |
patterns = ( | |
{ include = '#regex_sub'; }, | |
{ include = '#nest_brackets_r'; }, | |
); | |
}, | |
{ name = 'string.regexp.mod-r.ruby'; | |
comment = 'regular expressions (literal)'; | |
begin = '%r\('; | |
end = '\)[eimnosux]*'; | |
beginCaptures = { 0 = { name = 'punctuation.definition.string.begin.ruby'; }; }; | |
endCaptures = { 0 = { name = 'punctuation.definition.string.end.ruby'; }; }; | |
patterns = ( | |
{ include = '#regex_sub'; }, | |
{ include = '#nest_parens_r'; }, | |
); | |
}, | |
{ name = 'string.regexp.mod-r.ruby'; | |
comment = 'regular expressions (literal)'; | |
begin = '%r\<'; | |
end = '\>[eimnosux]*'; | |
beginCaptures = { 0 = { name = 'punctuation.definition.string.begin.ruby'; }; }; | |
endCaptures = { 0 = { name = 'punctuation.definition.string.end.ruby'; }; }; | |
patterns = ( | |
{ include = '#regex_sub'; }, | |
{ include = '#nest_ltgt_r'; }, | |
); | |
}, | |
{ name = 'string.regexp.mod-r.ruby'; | |
comment = 'regular expressions (literal)'; | |
begin = '%r([^\w])'; | |
end = '\1[eimnosux]*'; | |
beginCaptures = { 0 = { name = 'punctuation.definition.string.begin.ruby'; }; }; | |
endCaptures = { 0 = { name = 'punctuation.definition.string.end.ruby'; }; }; | |
patterns = ( { include = '#regex_sub'; } ); | |
}, | |
{ name = 'string.quoted.other.literal.upper.ruby'; | |
comment = 'literal capable of interpolation ()'; | |
begin = '%[QWSR]?\('; | |
end = '\)'; | |
beginCaptures = { 0 = { name = 'punctuation.definition.string.begin.ruby'; }; }; | |
endCaptures = { 0 = { name = 'punctuation.definition.string.end.ruby'; }; }; | |
patterns = ( | |
{ include = '#interpolated_ruby'; }, | |
{ include = '#escaped_char'; }, | |
{ include = '#nest_parens_i'; }, | |
); | |
}, | |
{ name = 'string.quoted.other.literal.upper.ruby'; | |
comment = 'literal capable of interpolation []'; | |
begin = '%[QWSR]?\['; | |
end = '\]'; | |
beginCaptures = { 0 = { name = 'punctuation.definition.string.begin.ruby'; }; }; | |
endCaptures = { 0 = { name = 'punctuation.definition.string.end.ruby'; }; }; | |
patterns = ( | |
{ include = '#interpolated_ruby'; }, | |
{ include = '#escaped_char'; }, | |
{ include = '#nest_brackets_i'; }, | |
); | |
}, | |
{ name = 'string.quoted.other.literal.upper.ruby'; | |
comment = 'literal capable of interpolation <>'; | |
begin = '%[QWSR]?\<'; | |
end = '\>'; | |
beginCaptures = { 0 = { name = 'punctuation.definition.string.begin.ruby'; }; }; | |
endCaptures = { 0 = { name = 'punctuation.definition.string.end.ruby'; }; }; | |
patterns = ( | |
{ include = '#interpolated_ruby'; }, | |
{ include = '#escaped_char'; }, | |
{ include = '#nest_ltgt_i'; }, | |
); | |
}, | |
{ name = 'string.quoted.double.ruby.mod'; | |
comment = 'literal capable of interpolation -- {}'; | |
begin = '%[QWSR]?\{'; | |
end = '\}'; | |
beginCaptures = { 0 = { name = 'punctuation.definition.string.begin.ruby'; }; }; | |
endCaptures = { 0 = { name = 'punctuation.definition.string.end.ruby'; }; }; | |
patterns = ( | |
{ include = '#interpolated_ruby'; }, | |
{ include = '#escaped_char'; }, | |
{ include = '#nest_curly_i'; }, | |
); | |
}, | |
{ name = 'string.quoted.other.literal.upper.ruby'; | |
comment = 'literal capable of interpolation -- wildcard'; | |
begin = '%[QWSR]([^\w])'; | |
end = '\1'; | |
beginCaptures = { 0 = { name = 'punctuation.definition.string.begin.ruby'; }; }; | |
endCaptures = { 0 = { name = 'punctuation.definition.string.end.ruby'; }; }; | |
patterns = ( | |
{ include = '#interpolated_ruby'; }, | |
{ include = '#escaped_char'; }, | |
); | |
}, | |
{ name = 'string.quoted.other.literal.other.ruby'; | |
comment = 'literal capable of interpolation -- wildcard'; | |
begin = '%([^\w\s=])'; | |
end = '\1'; | |
beginCaptures = { 0 = { name = 'punctuation.definition.string.begin.ruby'; }; }; | |
endCaptures = { 0 = { name = 'punctuation.definition.string.end.ruby'; }; }; | |
patterns = ( | |
{ include = '#interpolated_ruby'; }, | |
{ include = '#escaped_char'; }, | |
); | |
}, | |
{ name = 'string.quoted.other.literal.lower.ruby'; | |
comment = 'literal incapable of interpolation -- ()'; | |
begin = '%[qws]\('; | |
end = '\)'; | |
beginCaptures = { 0 = { name = 'punctuation.definition.string.begin.ruby'; }; }; | |
endCaptures = { 0 = { name = 'punctuation.definition.string.end.ruby'; }; }; | |
patterns = ( | |
{ name = 'constant.character.escape.ruby'; | |
match = '\\\)|\\\\'; | |
}, | |
{ include = '#nest_parens'; }, | |
); | |
}, | |
{ name = 'string.quoted.other.literal.lower.ruby'; | |
comment = 'literal incapable of interpolation -- <>'; | |
begin = '%[qws]\<'; | |
end = '\>'; | |
beginCaptures = { 0 = { name = 'punctuation.definition.string.begin.ruby'; }; }; | |
endCaptures = { 0 = { name = 'punctuation.definition.string.end.ruby'; }; }; | |
patterns = ( | |
{ name = 'constant.character.escape.ruby'; | |
match = '\\\>|\\\\'; | |
}, | |
{ include = '#nest_ltgt'; }, | |
); | |
}, | |
{ name = 'string.quoted.other.literal.lower.ruby'; | |
comment = 'literal incapable of interpolation -- []'; | |
begin = '%[qws]\['; | |
end = '\]'; | |
beginCaptures = { 0 = { name = 'punctuation.definition.string.begin.ruby'; }; }; | |
endCaptures = { 0 = { name = 'punctuation.definition.string.end.ruby'; }; }; | |
patterns = ( | |
{ name = 'constant.character.escape.ruby'; | |
match = '\\\]|\\\\'; | |
}, | |
{ include = '#nest_brackets'; }, | |
); | |
}, | |
{ name = 'string.quoted.other.literal.lower.ruby'; | |
comment = 'literal incapable of interpolation -- {}'; | |
begin = '%[qws]\{'; | |
end = '\}'; | |
beginCaptures = { 0 = { name = 'punctuation.definition.string.begin.ruby'; }; }; | |
endCaptures = { 0 = { name = 'punctuation.definition.string.end.ruby'; }; }; | |
patterns = ( | |
{ name = 'constant.character.escape.ruby'; | |
match = '\\\}|\\\\'; | |
}, | |
{ include = '#nest_curly'; }, | |
); | |
}, | |
{ name = 'string.quoted.other.literal.lower.ruby'; | |
comment = 'literal incapable of interpolation -- wildcard'; | |
begin = '%[qws]([^\w])'; | |
end = '\1'; | |
beginCaptures = { 0 = { name = 'punctuation.definition.string.begin.ruby'; }; }; | |
endCaptures = { 0 = { name = 'punctuation.definition.string.end.ruby'; }; }; | |
patterns = ( | |
{ comment = 'Cant be named because its not neccesarily an escape.'; | |
match = '\\.'; | |
}, | |
); | |
}, | |
{ name = 'constant.other.symbol.ruby'; | |
comment = 'symbols'; | |
match = '(?<!:)(:)(?>[a-zA-Z_]\w*(?>[?!]|=(?![>=]))?|===?|>[>=]?|<[<=]?|<=>|[%&`/\|]|\*\*?|=?~|[-+]@?|\[\]=?|@@?[a-zA-Z_]\w*)'; | |
captures = { 1 = { name = 'punctuation.definition.constant.ruby'; }; }; | |
}, | |
{ name = 'comment.block.documentation.ruby'; | |
comment = 'multiline comments'; | |
begin = '^=begin'; | |
end = '^=end'; | |
captures = { 0 = { name = 'punctuation.definition.comment.ruby'; }; }; | |
}, | |
{ name = 'comment.line.number-sign.ruby'; | |
match = '(?:^[ \t]+)?(#).*$\n?'; | |
captures = { 1 = { name = 'punctuation.definition.comment.ruby'; }; }; | |
}, | |
{ name = 'constant.numeric.ruby'; | |
comment = ' | |
matches questionmark-letters. | |
examples (1st alternation = hex): | |
?\x1 ?\x61 | |
examples (2nd alternation = octal): | |
?\0 ?\07 ?\017 | |
examples (3rd alternation = escaped): | |
?\n ?\b | |
examples (4th alternation = meta-ctrl): | |
?\C-a ?\M-a ?\C-\M-\C-\M-a | |
examples (4th alternation = normal): | |
?a ?A ?0 | |
?* ?" ?( | |
?. ?# | |
the negative lookbehind prevents against matching | |
p(42.tainted?) | |
'; | |
match = '(?<!\w)\?(\\(x\h{1,2}(?!\h)\b|0[0-7]{0,2}(?![0-7])\b|[^x0MC])|(\\[MC]-)+\w|[^\s\\])'; | |
}, | |
{ contentName = 'text.plain'; | |
comment = '__END__ marker'; | |
begin = '^__END__\n'; | |
end = '(?=not)impossible'; | |
captures = { 0 = { name = 'string.unquoted.program-block.ruby'; }; }; | |
patterns = ( | |
{ name = 'text.html.embedded.ruby'; | |
begin = '(?=<?xml|<(?i:html\b)|!DOCTYPE (?i:html\b))'; | |
end = '(?=not)impossible'; | |
patterns = ( { include = 'text.html.basic'; } ); | |
}, | |
); | |
}, | |
{ name = 'string.unquoted.heredoc.ruby'; | |
begin = '(?>\=\s*<<(\w+))(?!\s+#\s*([Cc]|sh|[Jj]ava))'; | |
end = '^\1$'; | |
beginCaptures = { 0 = { name = 'punctuation.definition.string.begin.ruby'; }; }; | |
endCaptures = { 0 = { name = 'punctuation.definition.string.end.ruby'; }; }; | |
patterns = ( | |
{ include = '#heredoc'; }, | |
{ include = '#interpolated_ruby'; }, | |
{ include = '#escaped_char'; }, | |
); | |
}, | |
{ name = 'string.unquoted.embedded.html.ruby'; | |
contentName = 'text.html.embedded.ruby'; | |
comment = 'heredoc with embedded HTML and indented terminator'; | |
begin = '(?><<-HTML\b)'; | |
end = '\s*HTML$'; | |
beginCaptures = { 0 = { name = 'punctuation.definition.string.begin.ruby'; }; }; | |
endCaptures = { 0 = { name = 'punctuation.definition.string.end.ruby'; }; }; | |
patterns = ( | |
{ include = '#heredoc'; }, | |
{ include = 'text.html.basic'; }, | |
{ include = '#interpolated_ruby'; }, | |
{ include = '#escaped_char'; }, | |
); | |
}, | |
{ name = 'string.unquoted.embedded.ruby.ruby'; | |
comment = 'ruby code in heredoc, interpolated'; | |
begin = '(?><<-(["\\'']?)(\w+_(?i:eval))\1)'; | |
end = '\s*\2$'; | |
beginCaptures = { 0 = { name = 'punctuation.definition.string.begin.ruby'; }; }; | |
endCaptures = { 0 = { name = 'punctuation.definition.string.end.ruby'; }; }; | |
patterns = ( | |
{ include = '#heredoc'; }, | |
{ include = '#interpolated_ruby'; }, | |
{ include = 'source.ruby'; }, | |
{ include = '#escaped_char'; }, | |
); | |
}, | |
{ name = 'string.unquoted.heredoc.ruby'; | |
comment = 'heredoc with indented terminator'; | |
begin = '(?><<-(\w+))'; | |
end = '\s*\1$'; | |
beginCaptures = { 0 = { name = 'punctuation.definition.string.begin.ruby'; }; }; | |
endCaptures = { 0 = { name = 'punctuation.definition.string.end.ruby'; }; }; | |
patterns = ( | |
{ include = '#heredoc'; }, | |
{ include = '#interpolated_ruby'; }, | |
{ include = '#escaped_char'; }, | |
); | |
}, | |
{ name = 'string.unquoted.embedded.c.ruby'; | |
begin = '(?>\=\s*<<(\w+))(?=\s+#\s*[Cc](?!(\+\+|[Ss][Ss])))'; | |
end = '^\1$'; | |
beginCaptures = { 0 = { name = 'punctuation.definition.string.begin.ruby'; }; }; | |
endCaptures = { 0 = { name = 'punctuation.definition.string.end.ruby'; }; }; | |
patterns = ( | |
{ include = '#heredoc'; }, | |
{ include = 'source.c'; }, | |
{ include = '#interpolated_ruby'; }, | |
{ include = '#escaped_char'; }, | |
); | |
}, | |
{ name = 'string.unquoted.embedded.cplusplus.ruby'; | |
begin = '(?>\=\s*<<(\w+))(?=\s+#\s*[Cc]\+\+)'; | |
end = '^\1$'; | |
beginCaptures = { 0 = { name = 'punctuation.definition.string.begin.ruby'; }; }; | |
endCaptures = { 0 = { name = 'punctuation.definition.string.end.ruby'; }; }; | |
patterns = ( | |
{ include = '#heredoc'; }, | |
{ include = 'source.c++'; }, | |
{ include = '#interpolated_ruby'; }, | |
{ include = '#escaped_char'; }, | |
); | |
}, | |
{ name = 'string.unquoted.embedded.css.ruby'; | |
begin = '(?>\=\s*<<(\w+))(?=\s+#\s*[Cc][Ss][Ss])'; | |
end = '^\1$'; | |
beginCaptures = { 0 = { name = 'punctuation.definition.string.begin.ruby'; }; }; | |
endCaptures = { 0 = { name = 'punctuation.definition.string.end.ruby'; }; }; | |
patterns = ( | |
{ include = '#heredoc'; }, | |
{ include = 'source.css'; }, | |
{ include = '#interpolated_ruby'; }, | |
{ include = '#escaped_char'; }, | |
); | |
}, | |
{ name = 'string.unquoted.embedded.js.ruby'; | |
begin = '(?>\=\s*<<(\w+))(?=\s+#\s*[Jj]ava[Ss]cript)'; | |
end = '^\1$'; | |
beginCaptures = { 0 = { name = 'punctuation.definition.string.begin.ruby'; }; }; | |
endCaptures = { 0 = { name = 'punctuation.definition.string.end.ruby'; }; }; | |
patterns = ( | |
{ include = '#heredoc'; }, | |
{ include = 'source.js'; }, | |
{ include = '#interpolated_ruby'; }, | |
{ include = '#escaped_char'; }, | |
); | |
}, | |
{ name = 'string.unquoted.embedded.shell.ruby'; | |
begin = '(?>\=\s*<<(\w+))(?=\s+#\s*sh)'; | |
end = '^\1$'; | |
beginCaptures = { 0 = { name = 'punctuation.definition.string.begin.ruby'; }; }; | |
endCaptures = { 0 = { name = 'punctuation.definition.string.end.ruby'; }; }; | |
patterns = ( | |
{ include = '#heredoc'; }, | |
{ include = 'source.shell'; }, | |
{ include = '#interpolated_ruby'; }, | |
{ include = '#escaped_char'; }, | |
); | |
}, | |
{ begin = '(?<=\{|do|\{\s|do\s)(\|)'; | |
end = '(\|)'; | |
captures = { 1 = { name = 'punctuation.separator.variable.ruby'; }; }; | |
patterns = ( | |
{ name = 'variable.other.block.ruby'; | |
match = '[_a-zA-Z][_a-zA-Z0-9]*'; | |
}, | |
{ name = 'punctuation.separator.variable.ruby'; | |
match = ','; | |
}, | |
); | |
}, | |
{ name = 'punctuation.separator.key-value'; | |
match = '=>'; | |
}, | |
{ name = 'keyword.operator.unary.ruby'; | |
match = '\+@|-@'; | |
}, | |
{ name = 'keyword.operator.assignment.augmented.ruby'; | |
match = '<<=|%=|&=|\*=|\*\*=|\+=|\-=|\^=|\|{1,2}=|/=|<<'; | |
}, | |
{ name = 'keyword.operator.comparison.ruby'; | |
match = '<=>|<(?!<|=)|>(?!<|=|>)|<=|>=|===|==|=~|!=|!~|(?<=[ \t])\?'; | |
}, | |
{ name = 'keyword.operator.logical.ruby'; | |
match = '(?<=[ \t])!+|\bnot\b|&&|\band\b|\|\||\bor\b|\^'; | |
}, | |
{ name = 'keyword.operator.arithmetic.ruby'; | |
match = '(%|&|\*\*|\*|\+|\-|/)'; | |
}, | |
{ name = 'keyword.operator.assignment.ruby'; | |
match = '='; | |
}, | |
{ name = 'keyword.operator.other.ruby'; | |
match = '\||~|>>'; | |
}, | |
{ name = 'punctuation.separator.other.ruby'; | |
match = ':'; | |
}, | |
{ name = 'punctuation.separator.statement.ruby'; | |
match = '\;'; | |
}, | |
{ name = 'punctuation.separator.object.ruby'; | |
match = ','; | |
}, | |
{ name = 'punctuation.separator.method.ruby'; | |
match = '\.|::'; | |
}, | |
{ name = 'punctuation.section.scope.ruby'; | |
match = '\{|\}'; | |
}, | |
{ name = 'punctuation.section.array.ruby'; | |
match = '\[|\]'; | |
}, | |
{ name = 'punctuation.section.function.ruby'; | |
match = '\(|\)'; | |
}, | |
); | |
repository = { | |
escaped_char = { | |
name = 'constant.character.escape.ruby'; | |
match = '\\(?:0\d{1,2}|x[\da-fA-F]{1,2}|.)'; | |
}; | |
heredoc = { | |
begin = '^<<-?\w+'; | |
end = '$'; | |
patterns = ( { include = '$self'; } ); | |
}; | |
interpolated_ruby = { | |
patterns = ( | |
{ name = 'source.ruby.embedded.source'; | |
match = '#\{(\})'; | |
captures = { | |
0 = { name = 'punctuation.section.embedded.ruby'; }; | |
1 = { name = 'source.ruby.embedded.source.empty'; }; | |
}; | |
}, | |
{ name = 'source.ruby.embedded.source'; | |
begin = '#\{'; | |
end = '\}'; | |
captures = { 0 = { name = 'punctuation.section.embedded.ruby'; }; }; | |
patterns = ( | |
{ include = '#nest_curly_and_self'; }, | |
{ include = '$self'; }, | |
); | |
}, | |
{ name = 'variable.other.readwrite.instance.ruby'; | |
match = '(#@)[a-zA-Z_]\w*'; | |
captures = { 1 = { name = 'punctuation.definition.variable.ruby'; }; }; | |
}, | |
{ name = 'variable.other.readwrite.class.ruby'; | |
match = '(#@@)[a-zA-Z_]\w*'; | |
captures = { 1 = { name = 'punctuation.definition.variable.ruby'; }; }; | |
}, | |
{ name = 'variable.other.readwrite.global.ruby'; | |
match = '(#\$)[a-zA-Z_]\w*'; | |
captures = { 1 = { name = 'punctuation.definition.variable.ruby'; }; }; | |
}, | |
); | |
}; | |
nest_brackets = { | |
begin = '\['; | |
end = '\]'; | |
captures = { 0 = { name = 'punctuation.section.scope.ruby'; }; }; | |
patterns = ( { include = '#nest_brackets'; } ); | |
}; | |
nest_brackets_i = { | |
begin = '\['; | |
end = '\]'; | |
captures = { 0 = { name = 'punctuation.section.scope.ruby'; }; }; | |
patterns = ( | |
{ include = '#interpolated_ruby'; }, | |
{ include = '#escaped_char'; }, | |
{ include = '#nest_brackets_i'; }, | |
); | |
}; | |
nest_brackets_r = { | |
begin = '\['; | |
end = '\]'; | |
captures = { 0 = { name = 'punctuation.section.scope.ruby'; }; }; | |
patterns = ( | |
{ include = '#regex_sub'; }, | |
{ include = '#nest_brackets_r'; }, | |
); | |
}; | |
nest_curly = { | |
begin = '\{'; | |
end = '\}'; | |
captures = { 0 = { name = 'punctuation.section.scope.ruby'; }; }; | |
patterns = ( { include = '#nest_curly'; } ); | |
}; | |
nest_curly_and_self = { | |
patterns = ( | |
{ begin = '\{'; | |
end = '\}'; | |
captures = { 0 = { name = 'punctuation.section.scope.ruby'; }; }; | |
patterns = ( { include = '#nest_curly_and_self'; } ); | |
}, | |
{ include = '$self'; }, | |
); | |
}; | |
nest_curly_i = { | |
begin = '\{'; | |
end = '\}'; | |
captures = { 0 = { name = 'punctuation.section.scope.ruby'; }; }; | |
patterns = ( | |
{ include = '#interpolated_ruby'; }, | |
{ include = '#escaped_char'; }, | |
{ include = '#nest_curly_i'; }, | |
); | |
}; | |
nest_curly_r = { | |
begin = '\{'; | |
end = '\}'; | |
captures = { 0 = { name = 'punctuation.section.scope.ruby'; }; }; | |
patterns = ( | |
{ include = '#regex_sub'; }, | |
{ include = '#nest_curly_r'; }, | |
); | |
}; | |
nest_ltgt = { | |
begin = '\<'; | |
end = '\>'; | |
captures = { 0 = { name = 'punctuation.section.scope.ruby'; }; }; | |
patterns = ( { include = '#nest_ltgt'; } ); | |
}; | |
nest_ltgt_i = { | |
begin = '\<'; | |
end = '\>'; | |
captures = { 0 = { name = 'punctuation.section.scope.ruby'; }; }; | |
patterns = ( | |
{ include = '#interpolated_ruby'; }, | |
{ include = '#escaped_char'; }, | |
{ include = '#nest_ltgt_i'; }, | |
); | |
}; | |
nest_ltgt_r = { | |
begin = '\<'; | |
end = '\>'; | |
captures = { 0 = { name = 'punctuation.section.scope.ruby'; }; }; | |
patterns = ( | |
{ include = '#regex_sub'; }, | |
{ include = '#nest_ltgt_r'; }, | |
); | |
}; | |
nest_parens = { | |
begin = '\('; | |
end = '\)'; | |
captures = { 0 = { name = 'punctuation.section.scope.ruby'; }; }; | |
patterns = ( { include = '#nest_parens'; } ); | |
}; | |
nest_parens_i = { | |
begin = '\('; | |
end = '\)'; | |
captures = { 0 = { name = 'punctuation.section.scope.ruby'; }; }; | |
patterns = ( | |
{ include = '#interpolated_ruby'; }, | |
{ include = '#escaped_char'; }, | |
{ include = '#nest_parens_i'; }, | |
); | |
}; | |
nest_parens_r = { | |
begin = '\('; | |
end = '\)'; | |
captures = { 0 = { name = 'punctuation.section.scope.ruby'; }; }; | |
patterns = ( | |
{ include = '#regex_sub'; }, | |
{ include = '#nest_parens_r'; }, | |
); | |
}; | |
regex_sub = { | |
patterns = ( | |
{ include = '#interpolated_ruby'; }, | |
{ include = '#escaped_char'; }, | |
{ name = 'string.regexp.arbitrary-repitition.ruby'; | |
match = '(\{)\d+(,\d+)?(\})'; | |
captures = { | |
1 = { name = 'punctuation.definition.arbitrary-repitition.ruby'; }; | |
3 = { name = 'punctuation.definition.arbitrary-repitition.ruby'; }; | |
}; | |
}, | |
{ name = 'string.regexp.character-class.ruby'; | |
begin = '\[(?:\^?\])?'; | |
end = '\]'; | |
captures = { 0 = { name = 'punctuation.definition.character-class.ruby'; }; }; | |
patterns = ( { include = '#escaped_char'; } ); | |
}, | |
{ name = 'string.regexp.group.ruby'; | |
begin = '\('; | |
end = '\)'; | |
captures = { 0 = { name = 'punctuation.definition.group.ruby'; }; }; | |
patterns = ( { include = '#regex_sub'; } ); | |
}, | |
{ name = 'comment.line.number-sign.ruby'; | |
comment = 'We are restrictive in what we allow to go after the comment character to avoid false positives, since the availability of comments depend on regexp flags.'; | |
match = '(?<=^|\s)(#)\s[[a-zA-Z0-9,. \t?!-][^\x{00}-\x{7F}]]*$'; | |
captures = { 1 = { name = 'punctuation.definition.comment.ruby'; }; }; | |
}, | |
); | |
}; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment