Last active
March 7, 2019 06:23
-
-
Save jtzero/7259292 to your computer and use it in GitHub Desktop.
a better ruby.nanorc /usr/share/nano/ruby.nanorc
This file contains 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
## Here is an example for Ruby. | |
## | |
syntax "ruby" "(Gemfile|Rakefile|\.(rb|rake|gemspec|ru|simplecov))$" | |
header "^#!.*(env\s|\/)ruby[-0-9._]*" | |
## Asciibetical list of reserved words | |
color yellow "\<(BEGIN|END|alias|and|begin|break|case|class|def|defined\?|do|else|elsif|end|ensure|false|for|if|in|lambda|module|next|nil|not|or|redo|rescue|retry|return|self|super|then|true|undef|unless|until|when|while|yield)\>" | |
## Constants | |
color brightblue "(\$|@|@@)?\<[A-Z]+[0-9A-Z_a-z]*" | |
## Some unique things we want to stand out | |
color brightyellow "\<(__FILE__|__LINE__)\>" | |
## Regular expressions | |
color brightmagenta "/([^/]|(\\/))*/[iomx]*" "%r\{([^}]|(\\}))*\}[iomx]*" | |
## Shell command expansion is in `backticks` or like %x{this}. These are | |
## "double-quotish" (to use a perlism). | |
color brightblue "`[^`]*`" "%x\{[^}]*\}" | |
#--- | |
##+ Ruby "symbols" | |
##+ must be above Constants Chain, below Strings it will make :"some symbol" will work | |
icolor magenta ":(\"|'|@|@@)?([0-9A-Z_>]+(\"|'|\?)?|(\[\]))" "(\"|'|@|@@)?[0-9A-Za-z_>]+(\"|'|\?|\!)?:" | |
## Ruby "symbols" (original) | |
#icolor magenta "([ ]|^):[0-9A-Z_]+\>" | |
## Variables | |
icolor brightblue "(\$|@|@@)\<[0-9A-Z_]*" | |
## Strings, double-quoted | |
color green ""([^"]|(\\"))*"" "%[QW]?\{[^}]*\}" "%[QW]?\([^)]*\)" "%[QW]?<[^>]*>" "%[QW]?\[[^]]*\]" "%[QW]?\$[^$]*\$" "%[QW]?\^[^^]*\^" "%[QW]?![^!]*!" | |
## Expression substitution. These go inside double-quoted strings, | |
## "like #{this}". | |
color brightgreen "#\{[^}]*\}" | |
## Strings, single-quoted | |
color green "'([^']|(\\'))*'" "%[qw]\{[^}]*\}" "%[qw]\([^)]*\)" "%[qw]<[^>]*>" "%[qw]\[[^]]*\]" "%[qw]\$[^$]*\$" "%[qw]\^[^^]*\^" "%[qw]![^!]*!" | |
## symbols % syntax | |
color magenta "%[i]?\{[^}]*\}" "%i?\([^)]*\)" "%[i]?<[^>]*>" "%[i]?\[[^]]*\]" "%[i]?\$[^$]*\$" "%[i]?\^[^^]*\^" "%[i]?![^!]*!" | |
##+ Constants chain | |
##+ this colors the :: as well, otherwise it show some pink | |
##+ because of symbol and this overwrites it | |
color brightblue "::[A-Z]+[A-Za-z0-9_]+?" "[A-Z]+[A-Za-z0-9_]+?::" | |
##+ (reset some of the color that gets 'written' due to lack of lookahead) | |
##+ method | |
color white "::[a-z][A-Za-z0-9_]+" | |
#--- | |
## block Comments | |
## place above the normal Comments section | |
color cyan start="^=begin" end="^=end" | |
## Comments | |
color cyan "#[^{].*$" "#$" | |
color brightcyan "##[^{].*$" "##$" | |
## "Here" docs | |
color green start="<<-?'?EOT'?" end="^EOT" | |
## Some common markers | |
color brightcyan "(XXX|TODO|FIXME|\?\?\?)" | |
##+ Trailing whitespace | |
color ,green "[[:space:]]+$" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
+ for lines added, and some spaces for clarity