micro/runtime/syntax/ruby.yaml
Dmytro Maluka b2a428f1cd Restore header instead of signature in most syntax files
Turning `header` patterns into `signature` patterns in all syntax files
was a mistake. The two are different things. In almost all syntax files
those patterns are things like shebangs or <?xml ... ?> or
<!DOCTYPE html5> i.e. things that:

1. can be (and should be) used for detecting the filetype when there is
   no `filename` match (and that is actually the purpose of those
   patterns, so it's a regression that it doesn't work anymore).

2. should only occur in the first line of the file, not in the first
   100 lines or so.

In other words, the old `header` semantics was exactly what was needed
for those filetypes, while the new `signature` semantics makes little
sense for them.

So replace `signature` back with `header` in most syntax files. Keep
`signature` only in C++ and Objective-C syntax files, for which it was
actually introduced.
2024-03-24 04:47:04 +01:00

69 lines
2.4 KiB
YAML

filetype: ruby
detect:
filename: "\\.(rb|rake|gemspec)$|^(.*[\\/])?(Gemfile|config.ru|Rakefile|Capfile|Vagrantfile|Guardfile|Appfile|Fastfile|Pluginfile|Podfile|\\.?[Bb]rewfile)$"
header: "^#!.*/(env +)?ruby( |$)"
rules:
- comment.bright:
start: "##"
end: "$"
rules:
- todo: "(XXX|TODO|FIXME|BUG|\\?\\?\\?)"
- comment:
start: "#"
end: "$"
rules:
- todo: "(XXX|TODO|FIXME|BUG|\\?\\?\\?)"
- statement: "\\b(BEGIN|END|alias|and|begin|break|case|class|def|defined\\?|do|else|elsif|end|ensure|for|if|in|module|next|nil|not|or|private|protected|public|redo|rescue|retry|return|self|super|then|undef|unless|until|when|while|yield)\\b"
- constant: "(\\$|@|@@)?\\b[A-Z]+[0-9A-Z_a-z]*"
- constant.number: "(?i)\\b0x[0-9a-fA-F][0-9a-f_]*\\b"
- constant.number: "(?i)\\b0b[01][01_]*\\b"
- constant.number: "(?i)\\b[0-9][0-9_]*(['.'][0-9_]+)?(e[\\-]?[0-9_]+)?\\b"
# Ruby "Symbols"
- constant: "(i?)([ ]|^):[0-9A-Z_]+\\b"
- constant: "\\b(__FILE__|__LINE__)\\b"
- constant: "/([^/]|(\\\\/))*/[iomx]*|%r\\{([^}]|(\\\\}))*\\}[iomx]*"
- constant.string:
start: "'"
end: "'"
skip: "\\\\."
rules: []
- constant.string:
start: "\""
end: "\""
skip: "\\\\."
rules:
- symbol.brackets:
start: "#\\{"
end: "\\}"
rules:
- default: ".*"
- constant.string.exec:
start: "`"
end: "`"
skip: "\\\\."
rules:
- symbol.brackets:
start: "#\\{"
end: "\\}"
rules:
- default: ".*"
- constant.string: "%[QW]?\\{[^}]*\\}|%[QW]?\\([^)]*\\)|%[QW]?<[^>]*>|%[QW]?\\[[^]]*\\]|%[QW]?\\$[^$]*\\$|%[QW]?\\^[^^]*\\^|%[QW]?![^!]*!"
- constant.string: "%[qw]\\{[^}]*\\}|%[qw]\\([^)]*\\)|%[qw]<[^>]*>|%[qw]\\[[^]]*\\]|%[qw]\\$[^$]*\\$|%[qw]\\^[^^]*\\^|%[qw]![^!]*!"
- constant.string.exec: "%[x]\\{[^}]*\\}|%[x]\\([^)]*\\)|%[x]<[^>]*>|%[x]\\[[^]]*\\]|%[x]\\$[^$]*\\$|%[x]\\^[^^]*\\^|%[x]![^!]*!"
- constant.bool: "\\b(true|false|nil|TRUE|FALSE|NIL)\\b"
- symbol.operator: "[-+/*=<>!~%&|^]|\\b:"
- symbol.brackets: "([(){}]|\\[|\\])"
- constant.macro:
start: "<<-?'?EOT'?"
end: "^EOT"
rules: []
- preproc.shebang: "^#!.+?( |$)"