name: Ruby fileTypes:

firstLineMatch: ^#!/.*brubyb scopeName: source.ruby repository:

nest_brackets: 
  captures: 
    "0": 
      name: punctuation.section.scope.ruby
  begin: \[
  end: \]
  patterns: 
  - include: "#nest_brackets"
interpolated_ruby: 
  patterns: 
  - name: source.ruby.embedded.source
    captures: 
      "0": 
        name: punctuation.section.embedded.ruby
      "1": 
        name: source.ruby.embedded.source.empty
    match: "#\\{(\\})"
  - name: source.ruby.embedded.source
    captures: 
      "0": 
        name: punctuation.section.embedded.ruby
    begin: "#\\{"
    end: \}
    patterns: 
    - include: "#nest_curly_and_self"
    - include: $self
  - name: variable.other.readwrite.instance.ruby
    captures: 
      "1": 
        name: punctuation.definition.variable.ruby
    match: (#@)[a-zA-Z_]\w*
  - name: variable.other.readwrite.class.ruby
    captures: 
      "1": 
        name: punctuation.definition.variable.ruby
    match: (#@@)[a-zA-Z_]\w*
  - name: variable.other.readwrite.global.ruby
    captures: 
      "1": 
        name: punctuation.definition.variable.ruby
    match: (#\$)[a-zA-Z_]\w*
escaped_char: 
  name: constant.character.escape.ruby
  match: \\(?:0\d{1,2}|x[\da-fA-F]{1,2}|.)
regex_sub: 
  patterns: 
  - include: "#interpolated_ruby"
  - include: "#escaped_char"
  - name: string.regexp.arbitrary-repitition.ruby
    captures: 
      "1": 
        name: punctuation.definition.arbitrary-repitition.ruby
      "3": 
        name: punctuation.definition.arbitrary-repitition.ruby
    match: (\{)\d+(,\d+)?(\})
  - name: string.regexp.character-class.ruby
    captures: 
      "0": 
        name: punctuation.definition.character-class.ruby
    begin: \[(?:\^?\])?
    end: \]
    patterns: 
    - include: "#escaped_char"
  - name: string.regexp.group.ruby
    captures: 
      "0": 
        name: punctuation.definition.group.ruby
    begin: \(
    end: \)
    patterns: 
    - include: "#regex_sub"
  - name: comment.line.number-sign.ruby
    captures: 
      "1": 
        name: punctuation.definition.comment.ruby
    match: (?<=^|\s)(#)\s[[a-zA-Z0-9,. \t?!-][^\x00-\x7F]]*$
    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.
heredoc: 
  begin: ^<<-?\w+
  end: $
  patterns: 
  - include: $base
nest_parens_r: 
  captures: 
    "0": 
      name: punctuation.section.scope.ruby
  begin: \(
  end: \)
  patterns: 
  - include: "#regex_sub"
  - include: "#nest_parens_r"
nest_curly_r: 
  captures: 
    "0": 
      name: punctuation.section.scope.ruby
  begin: \{
  end: \}
  patterns: 
  - include: "#regex_sub"
  - include: "#nest_curly_r"
nest_parens_i: 
  captures: 
    "0": 
      name: punctuation.section.scope.ruby
  begin: \(
  end: \)
  patterns: 
  - include: "#interpolated_ruby"
  - include: "#escaped_char"
  - include: "#nest_parens_i"
nest_ltgt_r: 
  captures: 
    "0": 
      name: punctuation.section.scope.ruby
  begin: \<
  end: \>
  patterns: 
  - include: "#regex_sub"
  - include: "#nest_ltgt_r"
nest_curly_i: 
  captures: 
    "0": 
      name: punctuation.section.scope.ruby
  begin: \{
  end: \}
  patterns: 
  - include: "#interpolated_ruby"
  - include: "#escaped_char"
  - include: "#nest_curly_i"
nest_ltgt_i: 
  captures: 
    "0": 
      name: punctuation.section.scope.ruby
  begin: \<
  end: \>
  patterns: 
  - include: "#interpolated_ruby"
  - include: "#escaped_char"
  - include: "#nest_ltgt_i"
nest_ltgt: 
  captures: 
    "0": 
      name: punctuation.section.scope.ruby
  begin: \<
  end: \>
  patterns: 
  - include: "#nest_ltgt"
nest_curly_and_self: 
  patterns: 
  - captures: 
      "0": 
        name: punctuation.section.scope.ruby
    begin: \{
    end: \}
    patterns: 
    - include: "#nest_curly_and_self"
  - include: $self
nest_parens: 
  captures: 
    "0": 
      name: punctuation.section.scope.ruby
  begin: \(
  end: \)
  patterns: 
  - include: "#nest_parens"
nest_brackets_r: 
  captures: 
    "0": 
      name: punctuation.section.scope.ruby
  begin: \[
  end: \]
  patterns: 
  - include: "#regex_sub"
  - include: "#nest_brackets_r"
nest_curly: 
  captures: 
    "0": 
      name: punctuation.section.scope.ruby
  begin: \{
  end: \}
  patterns: 
  - include: "#nest_curly"
nest_brackets_i: 
  captures: 
    "0": 
      name: punctuation.section.scope.ruby
  begin: \[
  end: \]
  patterns: 
  - include: "#interpolated_ruby"
  - include: "#escaped_char"
  - include: "#nest_brackets_i"

uuid: E00B62AC-6B1C-11D9-9B1F-000D93589AF6 foldingStartMarker: “(?x)^n\

\t    (\\s*+\n\
\t        (module|class|def\n\
\t        |unless|if\n\
\t        |case\n\
\t        |begin\n\
\t        |for|while|until\n\
\t\t\t |^=begin\n\
\t        |(  \"(\\\\.|[^\"])*+\"          # eat a double quoted string\n\
\t         | '(\\\\.|[^'])*+'        # eat a single quoted string\n\
\t         |   [^#\"']                # eat all but comments and strings\n\
\t         )*\n\
\t         (                        \\s   (do|begin|case)\n\
\t         | (?<!\\$)[-+=&|*/~%^<>~] \\s*+ (if|unless)\n\
\t         )\n\
\t        )\\b\n\
\t        (?! [^;]*+ ; .*? \\bend\\b )\n\
\t    |(  \"(\\\\.|[^\"])*+\"              # eat a double quoted string\n\
\t     | '(\\\\.|[^'])*+'            # eat a single quoted string\n\
\t     |   [^#\"']                    # eat all but comments and strings\n\
\t     )*\n\
\t     ( \\{ (?!  [^}]*+ \\} )\n\
\t     | \\[ (?! [^\\]]*+ \\] )\n\
\t     )\n\
\t    ).*$\n\
\t|   [#] .*? \\(fold\\) \\s*+ $         # Sune\xE2\x80\x99s special marker\n\
\t"

patterns:

foldingStopMarker: “(?x)n\

\t\t(   (^|;) \\s*+ end   \\s*+ ([#].*)? $\n\
\t\t|   (^|;) \\s*+ end \\. .* $\n\
\t\t|   ^     \\s*+ [}\\]] \\s*+ ([#].*)? $\n\
\t\t|   [#] .*? \\(end\\) \\s*+ $    # Sune\xE2\x80\x99s special marker\n\
\t\t|   ^=end\n\
\t\t)"

keyEquivalent: ^~R comment: “n\

\tTODO: unresolved issues\n\n\
\ttext:\n\
\t\"p << end\n\
\tprint me!\n\
\tend\"\n\
\tsymptoms:\n\
\tnot recognized as a heredoc\n\
\tsolution:\n\
\tthere is no way to distinguish perfectly between the << operator and the start\n\
\tof a heredoc. Currently, we require assignment to recognize a heredoc. More\n\
\trefinement is possible.\n\
\t\xE2\x80\xA2 Heredocs with indented terminators (<<-) are always distinguishable, however.\n\
\t\xE2\x80\xA2 Nested heredocs are not really supportable at present\n\n\
\ttext:\n\
\tprint <<-'THERE' \n\
\tThis is single quoted. \n\
\tThe above used #{Time.now} \n\
\tTHERE \n\
\tsymtoms:\n\
\tFrom Programming Ruby p306; should be a non-interpolated heredoc.\n\
\t\n\
\ttext:\n\
\t\"a\\332a\"\n\
\tsymptoms:\n\
\t'\\332' is not recognized as slash3.. which should be octal 332.\n\
\tsolution:\n\
\tplain regexp.. should be easy.\n\n    text:\n    val?(a):p(b)\n    val?'a':'b'\n    symptoms:\n    ':p' is recognized as a symbol.. its 2 things ':' and 'p'.\n    :'b' has same problem.\n    solution:\n    ternary operator rule, precedence stuff, symbol rule.\n    but also consider 'a.b?(:c)' ??\n"