Nano syntax highlighting

From Gentoo Linux Wiki
Jump to: navigation, search
This article is not very long. You could help Gentoo-Wiki by editing this article.

Gentoo installs nano with a decent set of syntax highlighting files. This page contains some that are improvements on the default files, or not included in the pre-existing set.

Note: By default, syntax files in /usr/share/nano are commented out in /etc/nanorc. To enable syntax highlighting, uncomment the lines near the bottom of /etc/nanorc.

[edit] PHP

PHP syntax highlighting, similar to vim default color scheme

File: /usr/share/nano/php.nanorc
syntax "php" "\.php[2345s~]?|\.ctp$"

#html
color yellow "</?[a-z0-9]+"
color yellow ">"

#functions
color white "\<[a-z_][A-Za-z_]*\("

#vars
color brightred "\$[A-Za-z_]*"
color cyan "->[A-Za-z_]*"
color green "->"

#keywords
color green "\<(array|as|class|compact|empty|extends|null|parent)\>"
color yellow "\<(empty|endforeach|endif|for|foreach|if|return|var)\>"
color magenta "\<(function)\>"
color brightmagenta "\<(echo)\>"

#operators
color yellow "\s(&&|&=|<|==|=>|\|\|)\s"
color yellow "(=|::)"

#types
color red "(true|false)"
color red "\s[0-9]+\s"

#strings
color red "'([^'\\]*(\\.[^'\\]*)*)'"
color red ""([^"\\]*(\\.[^"\\]*)*)""

#parens/brackets/braces
color magenta "(\(|\))"
color magenta "(\[|\])"
color magenta "(\{|\})"

#quotes
color white "'"
color white """

#comments
color brightblue "^//.*"
color brightblue "\s//.*"
color brightblue start="/\*" end="\*/"

# Trailing whitespace
color ,green "[[:space:]]+$"

#php tags
color magenta "(<\?(php)?|\?>)"


[edit] make.conf

File: /usr/share/nano/make.conf.nanorc
## if you now how make it better, please write)

syntax "make.conf" "make.conf$"
color brightred "\$+[{(][a-zA-Z0-9_-]+[})]"

## "="
color yellow "[=]"

## strings
color green start=""(\\.|[^\"])" end="""
color green start="'(\\.|[^\'])" end="'"

## quotes (" and ')
color brightwhite "['\"]"

##main symbols
color brightmagenta "\<(PORTAGE_TMPDIR|PORTDIR_OVERLAY|PORTDIR|DISTDIR|PORT_LOGDIR|WANT_MP|FEATURES|MAKEOPTS|AUTOCLEAN|EMERGE_DEFAULT_OPTS|INSTALL_MASK|LINGUAS|LANGUAGE)\>"
color brightmagenta "\<(PORTAGE_ELOG_CLASSES|PORTAGE_ELOG_SYSTEM|PORTAGE_ELOG_MAILURI|PORTAGE_ELOG_MAILFROM|PORTAGE_ELOG_MAILSUBJECT|PKGDIR|LANG|ACCEPT_KEYWORDS|ACCEPT_LICENSE)\>"
color brightgreen "\<(CFLAGS|CXXFLAGS|LDFLAGS|FFLAGS|FCFLAGS|CHOST|CBUILD|ICCCFLAGS|ICCCXXFLAGS|USE|source)\>"

##hardware
color brightyellow "\<(VIDEO_CARDS|ALSA_CARDS|INPUT_DEVICES|LIRC_DEVICES)\>"

##for ccache
color brightyellow "\<(CCACHE_SIZE|CCACHE_DIR|DISTCC_DIR|PORTAGE_NICENESS|PORTAGE_IONICE_COMMAND)\>"

##for proxy
color brightred "\<(http_proxy|RSYNC_PROXY|ftp_proxy)\>"

##fetch & resume command
color brightred "\<(FETCHCOMMAND|RESUMECOMMAND)\>"

## mirrors & sync
color brightred "\<(GENTOO_MIRRORS|SYNC|PORTAGE_BINHOST|PORTAGE_RSYNC_RETRIES|PORTAGE_RSYNC_EXTRA_OPTS)\>"

##comments
icolor brightblue "^[[:space:]]*#.*$"
icolor brightcyan "^[[:space:]]*##.*$"

##miscellaneous stuff
color brightcyan "\<(NETBEANS_MODULES)\>"

Also add this line to /etc/nanorc

include "/usr/share/nano/make.conf.nanorc"

or for 1 user to file ~/.nanorc

[edit] ebuild

## Example for ebuilds/eclasses
##
 syntax "ebuild" "\.e(build|class)$"
## Standatr functions.
 color brightgreen "^src_(unpack|compile|install)" "^pkg_(config|nofetch|setup|(pre|post)(inst|rm))"
## bash syntax
 color green "\<(case|do|done|elif|else|esac|exit|fi|for|function|if|in|local|read|return|select|shift|then|
time|until|while)\>"
 color green "(\{|\}|\(|\)|\;|\]|\[|`|\\|\$|<|>|!|=|&|\|)"
 color green "-(e|d|f|r|g|u|w|x|L)\>"
 color green "-(eq|ne|gt|lt|ge|le|s|n|z)\>"
## vars
 color brightred "\$\{?[a-zA-Z_0-9]+\}?"
 color red "\<(ARCH|HOMEPAGE|DESCRIPTION|IUSE|SRC_URI|LICENSE|SLOT|KEYWORDS|FILESDIR|WORKDIR|(P|R)?DEPEND|
PROVIDE|DISTDIR|RESTRICT)\>"
 color red "\<(S|D|T|PV|PF|P|PN|A)\>" "\<C(XX)?FLAGS\>"
## Command of portages
 color magenta "\<use(_(with|enable))?\> [a-z0-9X ]*" "inherit.*"
 color brightblue "e(begin|end|conf|install|make|warn|infon?|error|patch)"
 color brightblue "\<die\>" "\<use(_(with|enable))?\>" "\<inherit\>" "\<has\>" "\<(has|best)_version\>" "\<unpack\>"
 color brightblue "\<(do|new)(ins|s?bin|doc|lib(|\.so|\.a)|man|info|exe)\>"
 color brightblue "\<do(python|sed|dir|hard|sym|html|jar|mo)\>" "\<keepdir\>" 
 color brightblue "prepall(|docs|info|man|strip)" "prep(info|lib|lib\.so|man|strip)"
 color brightblue "\<(|doc|ins|exe)into\>" "\<f(owners|perms)\>" "\<(exe|ins)opts\>"
## Main commands, that use in ebuilds
 color blue "\<make\>" "\<(cat|cd|chmod|chown|cp|echo|env|export|grep|let|ln|mkdir|mv|rm|sed|set|tar|touch|unset)\>"
## Comments
 color yellow "#.*$"
## Strings
 color brightyellow ""(\\.|[^\"])*"" "'(\\.|[^'])*'"
Personal tools