-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
154 changed files
with
2,804 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
build/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
THEME = theme.sed | ||
FILTER = sed -f mixins.sed | sed -f $(THEME) | ||
|
||
install: ~/.nano/syntax.nanorc | ||
|
||
install-separate: $(addprefix ~/.nano/syntax/, $(wildcard *.nanorc)) | ||
|
||
~/.nano/syntax.nanorc: *.nanorc mixins/*.nanorc $(THEME) | ~/.nano/ | ||
@cat *.nanorc | $(FILTER) > $@ | ||
@grep '^include $@' ~/.nanorc >/dev/null 2>&1 || \ | ||
echo 'include $@' >> ~/.nanorc | ||
@echo 'Installed: $@' | ||
|
||
~/.nano/syntax/%.nanorc: %.nanorc mixins/*.nanorc $(THEME) | ~/.nano/syntax/ | ||
@cat $< | $(FILTER) > $@ | ||
@echo 'Installed: $@' | ||
|
||
~/.nano/ ~/.nano/syntax/: | ||
@mkdir -p $@ | ||
|
||
|
||
ifeq ($(shell test -f ~/.nanotheme && echo 1),1) | ||
THEME = ~/.nanotheme | ||
endif | ||
|
||
# Remove "header" directives if not supported (introduced in nano 2.1.6) | ||
NANOVER = $(shell nano -V | sed -n 's/^.* version \([0-9\.]*\).*/\1/p') | ||
ifeq ($(shell printf "2.1.5\n$(NANOVER)" | sort -nr | head -1),2.1.5) | ||
FILTER += | sed -e '/^header/d' | ||
endif | ||
|
||
ifdef TEXT | ||
FILTER += | sed -e 's|^color \(bright\)\{0,1\}black|color \1$(TEXT)|' | ||
endif | ||
|
||
ifdef BSDREGEX | ||
FILTER += | sed -e 's|\\<|[[:<:]]|g;s|\\>|[[:>:]]|g' | ||
endif | ||
|
||
|
||
.PHONY: install install-separate ~/.nano/syntax.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
Project Status | ||
============== | ||
|
||
I am no longer using nano as my editor and hence have little motivation | ||
to continue working on this project. I will answer GitHub issues and fix | ||
existing bugs, but beyond that, please consider this repository only an | ||
archive. | ||
|
||
Everything in the repository is in the Public Domain. Feel free to fork | ||
it and/or use the files for any purpose. | ||
|
||
P.S. I highly recommend [dex](https://github.com/tihirvon/dex) as a | ||
simple but much more capable editor. | ||
|
||
|
||
------ | ||
|
||
|
||
Description | ||
----------- | ||
|
||
The syntax highlighting definitions that come bundled with nano are of | ||
pretty poor quality. This is an attempt at providing a good set of accurate | ||
syntax definitions to replace and expand the defaults. | ||
|
||
Screenshots: | ||
------------ | ||
|
||
#### Editing HTML: | ||
|
||
![HTML Screenshot](http://cra.igbarn.es/img/nanorc-html.png) | ||
|
||
#### Editing C: | ||
|
||
![C Screenshot](http://cra.igbarn.es/img/nanorc-c.png) | ||
|
||
Installation | ||
------------ | ||
|
||
Using `make install` will concatenate and install the syntax definitions | ||
to `~/.nano/syntax.nanorc` and append an `include` command to | ||
`~/.nanorc`, if necessary. | ||
|
||
If your terminal **text** color isn't black, you'll need to specify it when | ||
installing, using `make install TEXT=color`, where `color` must be one of: | ||
`red`, `green`, `yellow`, `blue`, `magenta`, `cyan` or `white`. | ||
|
||
After installation, use `nano examples/*` to test if everything is | ||
working properly. If some or all of the files aren't highlighted properly, | ||
see the FAQ below. | ||
|
||
Theme System | ||
------------ | ||
|
||
All `*.nanorc` files are passed through [mixins.sed] and [theme.sed] before | ||
installation. These scripts allow rules to be specified in terms of token | ||
names or [mixins], instead of hard-coded colors. | ||
|
||
For example, the following named rule: | ||
|
||
TYPE: "int|bool|string" | ||
|
||
becomes: | ||
|
||
color green "int|bool|string" | ||
|
||
and the following "mixin": | ||
|
||
+BOOLEAN | ||
|
||
becomes: | ||
|
||
color brightcyan "\<(true|false)\>" | ||
|
||
This system helps to keep colors uniform across different languages and | ||
also to keep the definitions clear and maintainable, which is something that | ||
becomes quite awkward using only plain [nanorc] files. | ||
|
||
**Note:** if `~/.nanotheme` exists it will be used as a custom theme, in | ||
place of [theme.sed]. A custom theme may also be specified by installing | ||
with `make THEME=your-custom-theme.sed`. Themes must be valid sed scripts, | ||
defining *all* color codes found in [theme.sed] in order to work correctly. | ||
|
||
FAQ | ||
---- | ||
|
||
### Why does syntax highlighting only work for a subset of supported files? | ||
|
||
There appears to be a [bug][issue #5] in older versions of nano that causes | ||
highlighting to fail when `/etc/nanorc` and `~/.nanorc` both contain | ||
`syntax` rules. The usual workaround is to remove all `syntax` and `include` | ||
lines from `/etc/nanorc`. | ||
|
||
### Why do I get wierd errors when running nano < 2.1.5 on *BSD systems? | ||
|
||
In order to reliably highlight keywords, this projects makes heavy use of | ||
the GNU regex word boundary extensions (`\<` and `\>`). BSD implementations | ||
also have these extensions but use a different, incompatible syntax | ||
(`[[:<:]]` and `[[:>:]]`). Since version 2.1.5, nano can automatically | ||
translate the GNU syntax to BSD syntax at run-time, but for the benefit of | ||
people running a pre-2.1.5 version of nano on OS X or *BSD, the `.nanorc` | ||
file itself can be translated by installing with `make BSDREGEX=1`. | ||
|
||
### Why not use `\s` instead of the verbose `[[:space:]]` pattern? | ||
|
||
Because nano compiles against the platform's native regex library and some | ||
platforms don't support `\s` (as it's not required by POSIX [ERE]). | ||
|
||
Unlicense | ||
--------- | ||
|
||
This is free and unencumbered software released into the public domain. | ||
|
||
Anyone is free to copy, modify, publish, use, compile, sell, or | ||
distribute this software, either in source code form or as a compiled | ||
binary, for any purpose, commercial or non-commercial, and by any | ||
means. | ||
|
||
In jurisdictions that recognize copyright laws, the author or authors | ||
of this software dedicate any and all copyright interest in the | ||
software to the public domain. We make this dedication for the benefit | ||
of the public at large and to the detriment of our heirs and | ||
successors. We intend this dedication to be an overt act of | ||
relinquishment in perpetuity of all present and future rights to this | ||
software under copyright law. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
For more information, please refer to <http://unlicense.org/> | ||
|
||
|
||
[GNU nano]: http://www.nano-editor.org/ | ||
[nanorc]: http://www.nano-editor.org/dist/v2.3/nanorc.5.html | ||
[theme.sed]: https://github.com/craigbarnes/nanorc/tree/master/theme.sed | ||
[mixins.sed]: https://github.com/craigbarnes/nanorc/tree/master/mixins.sed | ||
[mixins]: https://github.com/craigbarnes/nanorc/tree/master/mixins | ||
[issue #5]: https://github.com/craigbarnes/nanorc/issues/5 | ||
[issue #25]: https://github.com/craigbarnes/nanorc/issues/25 | ||
[ERE]: http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap09.html#tag_09_04 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
syntax "awk" "\.awk$" | ||
header "^#!.*bin/(env +)?awk( |$)" | ||
|
||
VARIABLE: "\$[A-Za-z0-9_!@#$*?-]+" | ||
VARIABLE: "\<(ARGC|ARGIND|ARGV|BINMODE|CONVFMT|ENVIRON|ERRNO|FIELDWIDTHS)\>" | ||
VARIABLE: "\<(FILENAME|FNR|FS|IGNORECASE|LINT|NF|NR|OFMT|OFS|ORS)\>" | ||
VARIABLE: "\<(PROCINFO|RS|RT|RSTART|RLENGTH|SUBSEP|TEXTDOMAIN)\>" | ||
FUNCTION: "\<(function|extension|BEGIN|END)\>" | ||
OPERATOR: "[-+*/%^|!=&<>?;:]|\\|\[|\]" | ||
KEYWORD: "\<(for|if|while|do|else|in|delete|exit)\>" | ||
KEYWORD: "\<(break|continue|return)\>" | ||
FUNCTION: "\<(close|getline|next|nextfile|print|printf|system|fflush)\>" | ||
FUNCTION: "\<(atan2|cos|exp|int|log|rand|sin|sqrt|srand)\>" | ||
FUNCTION: "\<(asort|asorti|gensub|gsub|index|length|match)\>" | ||
FUNCTION: "\<(split|sprintf|strtonum|sub|substr|tolower|toupper)\>" | ||
FUNCTION: "\<(mktime|strftime|systime)\>" | ||
FUNCTION: "\<(and|compl|lshift|or|rshift|xor)\>" | ||
FUNCTION: "\<(bindtextdomain|dcgettext|dcngettext)\>" | ||
REGEXP: "/.*[^\]/" | ||
+STRING | ||
ESCAPE: "\\." | ||
+HASHCOMMENT | ||
+TODO | ||
+LINT |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
syntax "c" "\.(c(c|pp|xx)?|C)$" "\.(h(h|pp|xx)?|H)$" "\.ii?$" | ||
|
||
+FUNCTION | ||
MACRO: "\<[A-Z_][0-9A-Z_]+\>" | ||
TYPE: "\<(float|double|bool|char|int|short|long|void|(un)?signed)\>" | ||
TYPE: "\<[a-z0-9_]+_t\>" | ||
KEYWORD: "\<(struct|enum|static|const|union|typedef|extern)\>" | ||
KEYWORD: "\<(for|if|while|do|else|case|default|switch)\>" | ||
KEYWORD: "\<(return|inline|sizeof|auto|register|volatile|restrict)\>" | ||
KEYWORD: "\<(try|throw|catch|operator|new|delete)\>" | ||
JUMP: "\<(goto|break|continue)\>" | ||
+BOOLEAN | ||
OPERATOR: "[-+/*=<>?:!~%&|^]" | ||
NUMBER: "\<([0-9]+|0x[0-9a-fA-F]*)\>|'.'" | ||
MACRO: "^[[:space:]]*#[[:space:]]*(define|include(_next)?|(un|ifn?)def|endif|el(if|se)|if|warning|error|pragma)" | ||
ATTRIBUTE: "__attribute__[[:space:]]*\(\([^)]*\)\)" "__(aligned|asm|builtin|hidden|inline|packed|restrict|section|typeof|weak)__" | ||
STRING: ""(\\.|[^"])*"|<[A-Za-z_./-]+>" | ||
ESCAPE: "\\([\"'abfnrtv\\]|[0-3]?[0-7]{1,2}|x[A-Fa-f0-9]{1,2}|$)" | ||
+CCOMMENT | ||
+TODO | ||
+LINT |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
syntax "cmake" "CMakeLists\.txt$|\.cmake$" | ||
|
||
+FUNCTION | ||
BOOLEAN: "\<(ON|OFF|TRUE|FALSE|YES|NO)\>" | ||
VARIABLE: "\$\{[A-Za-z0-9_!@#$*?-]+\}" | ||
+STRING | ||
ESCAPE: "\\([()#$^]|\\|\")" | ||
+HASHCOMMENT | ||
+LINT |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
syntax "coffeescript" "\.coffee$" | ||
header "^#!.*/(env +)?coffee" | ||
|
||
OPERATOR: "[!&|=/*+-<>]|\<(and|or|is|isnt|not)\>" | ||
FUNCTION: "[A-Za-z_][A-Za-z0-9_]*:[[:space:]]*(->|\()" "->" | ||
PLAIN: "[()]" | ||
KEYWORD: "\<(for|of|continue|break|isnt|null|unless|this|else|if|return)\>" | ||
KEYWORD: "\<(try|catch|finally|throw|new|delete|typeof|in|instanceof)\>" | ||
KEYWORD: "\<(debugger|switch|while|do|class|extends|super)\>" | ||
KEYWORD: "\<(undefined|then|unless|until|loop|of|by|when)\>" | ||
BOOLEAN: "\<(true|false|yes|no|on|off)\>" | ||
VARIABLE: "@[A-Za-z0-9_]*" | ||
+STRING | ||
+HASHCOMMENT | ||
+LINT |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
syntax "colortest" "ColorTest$" | ||
|
||
color black "\<PLAIN\>" | ||
|
||
color red "\<red\>" | ||
color green "\<green\>" | ||
color yellow "\<yellow\>" | ||
color blue "\<blue\>" | ||
color magenta "\<magenta\>" | ||
color cyan "\<cyan\>" | ||
|
||
color brightred "\<brightred\>" | ||
color brightgreen "\<brightgreen\>" | ||
color brightyellow "\<brightyellow\>" | ||
color brightblue "\<brightblue\>" | ||
color brightmagenta "\<brightmagenta\>" | ||
color brightcyan "\<brightcyan\>" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
syntax "c#" "\.cs$" | ||
|
||
# Class | ||
SECTION: "class +[A-Za-z0-9]+ *((:) +[A-Za-z0-9.]+)?" | ||
|
||
# Annotation | ||
ESCAPE: "@[A-Za-z]+" | ||
|
||
+FUNCTION | ||
TYPE: "\<(bool|byte|sbyte|char|decimal|double|float|IntPtr|int|uint|long|ulong|object|short|ushort|string|base|this|var|void)\>" | ||
KEYWORD: "\<(alias|as|case|catch|checked|default|do|dynamic|else|finally|fixed|for|foreach|goto|if|is|lock|new|null|return|switch|throw|try|unchecked|while)\>" | ||
KEYWORD: "\<(abstract|async|class|const|delegate|enum|event|explicit|extern|get|implicit|in|internal|interface|namespace|operator|out|override|params|partial|private|protected|public|readonly|ref|sealed|set|sizeof|stackalloc|static|struct|typeof|unsafe|using|value|virtual|volatile|yield)\>" | ||
# LINQ-only keywords (ones that cannot be used outside of a LINQ query - lots others can) | ||
KEYWORD: "\<(from|where|select|group|info|orderby|join|let|in|on|equals|by|ascending|descending)\>" | ||
JUMP: "\<(break|continue)\>" | ||
+BOOLEAN | ||
OPERATOR: "[-+/*=<>?:!~%&|]" | ||
NUMBER: "\<([0-9._]+|0x[A-Fa-f0-9_]+|0b[0-1_]+)[FL]?\>" | ||
+STRING | ||
ESCAPE: "\\([btnfr]|'|\"|\\)" | ||
ESCAPE: "\\u[A-Fa-f0-9]{4}" | ||
+CCOMMENT | ||
+TODO | ||
+LINT |
Oops, something went wrong.