Skip to content

Commit

Permalink
* Nanorc: Copy comment syntax from nano 4.6 nanorcs
Browse files Browse the repository at this point in the history
  • Loading branch information
earboxer committed Dec 18, 2019
1 parent c705a50 commit 97f06f6
Show file tree
Hide file tree
Showing 29 changed files with 47 additions and 2 deletions.
2 changes: 2 additions & 0 deletions asm.nanorc
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## Here is an example for assembler.
##
syntax "ASM" "\.(S|s|asm)$"
comment "//"

color red "\<[A-Z_]{2,}\>"
color brightgreen "\.(data|subsection|text)"
color green "\.(align|file|globl|global|hidden|section|size|type|weak)"
Expand Down
1 change: 1 addition & 0 deletions awk.nanorc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
syntax "AWK" "\.awk$"
header "^#!.*bin/(env +)?awk( |$)"
comment "#"

color brightyellow "\$[A-Za-z0-9_!@#$*?-]+"
color brightyellow "\<(ARGC|ARGIND|ARGV|BINMODE|CONVFMT|ENVIRON|ERRNO|FIELDWIDTHS)\>"
Expand Down
1 change: 1 addition & 0 deletions c.nanorc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## Here is an example for C/C++.
##
syntax "C" "\.(c(c|pp|xx)?|C)$" "\.(h(h|pp|xx)?|H)$" "\.ii?$" "\.(def)$"
comment "//"
color brightred "\<[A-Z_][0-9A-Z_]+\>"
color green "\<(float|double|bool|char|wchar_t|int|short|long|sizeof|enum|void|static|const|struct|union|typedef|extern|(un)?signed|inline)\>"
color green "\<((s?size)|(char(16|32))|((u_?)?int(_fast|_least)?(8|16|32|64))|u?int(max|ptr))_t\>"
Expand Down
1 change: 1 addition & 0 deletions cmake.nanorc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## CMake syntax highlighter for GNU Nano
##
syntax "CMake" "(CMakeLists\.txt|\.cmake)$"
comment "#"

icolor green "^[[:space:]]*[A-Z0-9_]+"
icolor brightyellow "^[[:space:]]*(include|include_directories|include_external_msproject)\>"
Expand Down
2 changes: 1 addition & 1 deletion fortran.nanorc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Here is an example for Fortran 90/95

syntax "Fortran" "\.([Ff]|[Ff]90|[Ff]95|[Ff][Oo][Rr])$"

comment "!"
#color red "\<[A-Z_]a[0-9A-Z_]+\>"
color red "\<[0-9]+\>"

Expand Down
2 changes: 2 additions & 0 deletions gentoo.nanorc
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## Here is an example for ebuilds/eclasses
##
syntax "Ebuild" "\.e(build|class)$"
comment "#"

## All the standard portage functions
color brightgreen "^src_(unpack|compile|install|test)" "^pkg_(config|nofetch|setup|(pre|post)(inst|rm))"
## Highlight bash related syntax
Expand Down
1 change: 1 addition & 0 deletions go.nanorc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
syntax "GO" "\.go$"
comment "//"

color brightblue "[A-Za-z_][A-Za-z0-9_]*[[:space:]]*[()]"
color brightblue "\<(append|cap|close|complex|copy|delete|imag|len)\>"
Expand Down
2 changes: 2 additions & 0 deletions groff.nanorc
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## Here is an example for groff.
##
syntax "Groff" "\.m[ems]$" "\.rof" "\.tmac$" "^tmac."
comment ".\""

## The argument of .ds or .nr
color cyan "^\.(ds|nr) [^[[:space:]]]*"
## Single character escapes
Expand Down
2 changes: 2 additions & 0 deletions java.nanorc
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## Here is an example for Java.
##
syntax "Java" "\.java$"
comment "//"

color green "\<(boolean|byte|char|double|float|int|long|new|short|this|transient|void)\>"
color red "\<(break|case|catch|continue|default|do|else|finally|for|if|return|switch|throw|try|while)\>"
color cyan "\<(abstract|class|extends|final|implements|import|instanceof|interface|native|package|private|protected|public|static|strictfp|super|synchronized|throws|volatile)\>"
Expand Down
2 changes: 1 addition & 1 deletion javascript.nanorc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
syntax "JavaScript" "\.js$"

comment "//"
color blue "\<[-+]?([1-9][0-9]*|0[0-7]*|0x[0-9a-fA-F]+)([uU][lL]?|[lL][uU]?)?\>"
color blue "\<[-+]?([0-9]+\.[0-9]*|[0-9]*\.[0-9]+)([EePp][+-]?[0-9]+)?[fFlL]?"
color blue "\<[-+]?([0-9]+[EePp][+-]?[0-9]+)[fFlL]?"
Expand Down
1 change: 1 addition & 0 deletions js.nanorc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
## New updated taken from http://wiki.linuxhelp.net/index.php/Nano_Syntax_Highlighting

syntax "JavaScript" "\.(js)$"
comment "//"

## Default
color white "^.+$"
Expand Down
2 changes: 2 additions & 0 deletions json.nanorc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
syntax "JSON" "\.json$"
header "^\{$"
# You can't add a comment to JSON.
comment ""

color blue "\<[-]?[1-9][0-9]*([Ee][+-]?[0-9]+)?\>" "\<[-]?[0](\.[0-9]+)?\>"
color cyan "\<null\>"
Expand Down
1 change: 1 addition & 0 deletions lua.nanorc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

# Automatically use for '.lua' files
syntax "Lua" ".*\.lua$"
comment "--"

# General
color brightwhite ".+"
Expand Down
1 change: 1 addition & 0 deletions makefile.nanorc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
syntax "Makefile" "([Mm]akefile|\.ma?k)$"
header "^#!.*/(env +)?[bg]?make( |$)"
comment "#"

color cyan "\<(ifeq|ifdef|ifneq|ifndef|else|endif)\>"
color cyan "^(export|include|override)\>"
Expand Down
2 changes: 2 additions & 0 deletions man.nanorc
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## Here is an example for manpages.
##
syntax "Man" "\.[1-9]x?$"
comment ".\""

color green "\.(S|T)H.*$"
color brightgreen "\.(S|T)H" "\.TP"
color brightred "\.(BR?|I[PR]?).*$"
Expand Down
2 changes: 2 additions & 0 deletions nanorc.nanorc
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## Here is an example for nanorc files.
##
syntax "Nanorc" "\.?nanorc$"
comment "#"

## Possible errors and parameters
icolor brightred "^[[:space:]]*((un)?set|include|syntax|i?color).*$"
## Colors
Expand Down
4 changes: 4 additions & 0 deletions ocaml.nanorc
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
## Syntax highlighting for OCaml.

syntax "OCaml" "\.mli?$"
comment "(*|*)"

#uid
color red "\<[A-Z][0-9a-z_]{2,}\>"
#declarations
Expand Down
3 changes: 3 additions & 0 deletions patch.nanorc
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
## Here is an example for patch files.
##
syntax "Patch" "\.(patch|diff)$"
# You can't add comments in patch files.
comment ""

color brightgreen "^\+.*"
color green "^\+\+\+.*"
color brightblue "^ .*"
Expand Down
1 change: 1 addition & 0 deletions perl.nanorc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
##
syntax "Perl" "\.p[lm]$"
header "^#!.*/(env +)?perl( |$)"
comment "#"

color red "\<(accept|alarm|atan2|bin(d|mode)|c(aller|h(dir|mod|op|own|root)|lose(dir)?|onnect|os|rypt)|d(bm(close|open)|efined|elete|ie|o|ump)|e(ach|of|val|x(ec|ists|it|p))|f(cntl|ileno|lock|ork))\>" "\<(get(c|login|peername|pgrp|ppid|priority|pwnam|(host|net|proto|serv)byname|pwuid|grgid|(host|net)byaddr|protobynumber|servbyport)|([gs]et|end)(pw|gr|host|net|proto|serv)ent|getsock(name|opt)|gmtime|goto|grep|hex|index|int|ioctl|join)\>" "\<(keys|kill|last|length|link|listen|local(time)?|log|lstat|m|mkdir|msg(ctl|get|snd|rcv)|next|oct|open(dir)?|ord|pack|pipe|pop|printf?|push|q|qq|qx|rand|re(ad(dir|link)?|cv|do|name|quire|set|turn|verse|winddir)|rindex|rmdir|s|scalar|seek(dir)?)\>" "\<(se(lect|mctl|mget|mop|nd|tpgrp|tpriority|tsockopt)|shift|shm(ctl|get|read|write)|shutdown|sin|sleep|socket(pair)?|sort|spli(ce|t)|sprintf|sqrt|srand|stat|study|substr|symlink|sys(call|read|tem|write)|tell(dir)?|time|tr(y)?|truncate|umask)\>" "\<(un(def|link|pack|shift)|utime|values|vec|wait(pid)?|wantarray|warn|write)\>"
color magenta "\<(continue|else|elsif|do|for|foreach|if|unless|until|while|eq|ne|lt|gt|le|ge|cmp|x|my|sub|use|package|can|isa)\>"
Expand Down
1 change: 1 addition & 0 deletions php.nanorc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## PHP Syntax Highlighting
syntax "PHP" "\.php[2345s~]?$"
comment "//"
color white start="<\?(php|=)?" end="\?>"
# Functions
color brightblue "([a-zA-Z0-9_-]*)\("
Expand Down
1 change: 1 addition & 0 deletions po.nanorc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
syntax "PO" "\.pot?$"
comment "#"

color cyan "\<(msgid|msgstr)\>"
color yellow ""(\\.|[^"])*"|'(\\.|[^'])*'"
Expand Down
2 changes: 2 additions & 0 deletions pov.nanorc
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## Here is an example for POV-Ray.
##
syntax "POV" "\.(pov|POV|povray|POVRAY)$"
comment "//"

color brightcyan "^[[:space:]]*#[[:space:]]*(declare)"
color brightyellow "\<(sphere|cylinder|translate|matrix|rotate|scale)\>"
color brightyellow "\<(orthographic|location|up|right|direction|clipped_by)\>"
Expand Down
1 change: 1 addition & 0 deletions python.nanorc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
syntax "python" "\.py$"
header "^#!.*/(env +)?python[-0-9._]*( |$)"
magic "Python script"
comment "#"

## built-in objects
color cyan "\<(None|self|True|False)\>"
Expand Down
1 change: 1 addition & 0 deletions ruby.nanorc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
##
syntax "Ruby" "\.rb$" "Gemfile" "config.ru" "Rakefile" "Capfile" "Vagrantfile"
header "^#!.*/(env +)?ruby( |$)"
comment "#"

## 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|module|next|nil|not|or|redo|rescue|retry|return|self|super|then|true|undef|unless|until|when|while|yield)\>"
Expand Down
3 changes: 3 additions & 0 deletions rust.nanorc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
# Copyright 2015 The Rust Project Developers.
#
# NOTE: Rules are applied in order: later rules re-colorize matching text.


syntax "Rust" "\.rs"
comment "//"

# function definition
color magenta "fn [a-z0-9_]+"
Expand Down
2 changes: 2 additions & 0 deletions sh.nanorc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
##
syntax "SH" "\.sh$" "\.bashrc" "bashrc" "\.bash_aliases" "bash_aliases" "\.bash_functions" "bash_functions" "\.bash_login" "\.bash_logout" "\.bash_profile" "bash_profile" "\.profile" "revise\..+$"
header "^#!.*/(env +)?(ba)?sh( |$)"
comment "#"

## keywords:
color green "\<(case|do|done|elif|else|esac|fi|for|function|if|in|select|then|time|until|while)\>"
color green "(\{|\}|\(|\)|\;|\]|\[|`|\\|\$|<|>|!|=|&|\|)"
Expand Down
2 changes: 2 additions & 0 deletions tcl.nanorc
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
syntax "TCL" "\.tcl$"
header "^#!.*/(env +)?tclsh( |$)"

comment "#"

## Standard Tcl [info commands]
color cyan "\<(after|append|array|auto_execok|auto_import|auto_load|auto_load_index|auto_qualify|binary|break|case|catch|cd|clock|close|concat|continue|else|encoding|eof|error|eval|exec|exit|expr|fblocked|fconfigure|fcopy|file|fileevent|flush|for|foreach|format|gets|glob|global|history|if|incr|info|interp|join|lappend|lindex|linsert|list|llength|load|lrange|lreplace|lsearch|lset|lsort|namespace|open|package|pid|puts|pwd|read|regexp|regsub|rename|return|scan|seek|set|socket|source|split|string|subst|switch|tclLog|tell|time|trace|unknown|unset|update|uplevel|upvar|variable|vwait|while)\>"
## Basic Tcl sub commands
Expand Down
2 changes: 2 additions & 0 deletions tex.nanorc
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## Here is a short example for TeX files.
##
syntax "TeX" "\.tex$" "bib" "\.bib$" "cls" "\.cls$"
comment "%"

color yellow "\$(\\\$|[^$])*[^\\]\$"
color yellow "\$\$(\\\$|[^$])*[^\\]\$\$"
icolor green "\\.|\\[A-Z]*"
Expand Down
1 change: 1 addition & 0 deletions xml.nanorc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
##

syntax "XML" ".*\.([jrs]?html?|xml|sgml?|rng)$"
comment "<!--|-->"
color white "^.+$"
color green start="<" end=">"
color cyan "<[^> ]+"
Expand Down

3 comments on commit 97f06f6

@Rah1x
Copy link

@Rah1x Rah1x commented on 97f06f6 Mar 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you do this? All ive got now is for every single file you altered:
Command "comment" not understood

@earboxer
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Rah1x Sounds like you're on an older version of nano.

Looks like the comment feature was added in nano 2.6.0 (https://www.nano-editor.org/news.php) (in June of 2016).

@scopatz provides a v2.9 branch, but of course, you're on < 2.6.0, so this won't help you

I highly recommend that you update to nano 4.8 or at least 2.9, but I understand that might not be practical for you (on many distributions, you need to install libncursesw5-dev or similar package before you can compile it)

In #355 (comment) @rasa has provided many branches which remove these syntax errors for older version of nano.

(I'll probably switch to zor pre-5.0 branch at some point, because I prefer sticking to the ANSI 16 color scheme)

@Rah1x
Copy link

@Rah1x Rah1x commented on 97f06f6 Mar 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@earboxer
I just installed nano yesterday yet it turns out to be 2.3.1

image

Please sign in to comment.