├── README.md ├── js.nanorc └── ts.nanorc /README.md: -------------------------------------------------------------------------------- 1 | # javascript-nanorc 2 | Syntax highlighting for javascript and typescript for nanorc. 3 | 4 | ## Installation 5 | 6 | 1. clone the repository: 7 | 8 | ```sh 9 | git clone https://github.com/nousantx/javascript-nanorc.git 10 | ``` 11 | 2. include file: 12 | 13 | ```sh 14 | nano ~/.nanorc 15 | ``` 16 | 17 | or 18 | 19 | ```sh 20 | nano /etc/.nanorc 21 | ``` 22 | 23 | 3. Inside of `.nanorc`: 24 | 25 | Let's say the configuration file is on /home/javascript-nanorc : 26 | ```sh 27 | include ~/javascript-nanorc/js.nanorc 28 | include ~/javascript-nanorc/ts.nanorc 29 | ``` 30 | 31 | ## Syntax Highlighting Support 32 | 33 | - js 34 | - mjs 35 | - cjs 36 | - json 37 | - ts 38 | - tsx 39 | -------------------------------------------------------------------------------- /js.nanorc: -------------------------------------------------------------------------------- 1 | syntax "javascript" "\.(mjs)|(cjs)|(js)|(jsx)|(json)$" 2 | 3 | ## Default 4 | color white "^.+$" 5 | 6 | ## Decimal, cotal and hexadecimal numbers 7 | color yellow "\<[-+]?([1-9][0-9]*|0[0-7]*|0x[0-9a-fA-F]+)([uU][lL]?|[lL][uU]?)?\>" 8 | 9 | ## Floating point number with at least one digit before decimal point 10 | color yellow "\<[-+]?([0-9]+\.[0-9]*|[0-9]*\.[0-9]+)([EePp][+-]?[0-9]+)?[fFlL]?" 11 | color yellow "\<[-+]?([0-9]+[EePp][+-]?[0-9]+)[fFlL]?" 12 | 13 | ## Keywords 14 | color green "\<(abstract|async|await|boolean|break|byte|case|catch|char)\>" 15 | color green "\<(class|const|continue|debugger|default|delete|double)\>" 16 | color green "\<(do|else|enum|export|extends|finally|final|float|for)\>" 17 | color green "\<(from|function|goto|if|implements|import|instanceof)\>" 18 | color green "\<(interface|int|in|let|long|native|new|package|private)\>" 19 | color green "\<(protected|public|return|short|static|super|switch)\>" 20 | color green "\<(synchronized|this|throws|throw|transient|try|typeof)\>" 21 | color green "\<(var|void|volatile|while|with|yield)\>" 22 | 23 | ## Type specifiers 24 | color red "\<(Array|Boolean|Date|Enumerator|Error|Function|Math)\>" 25 | color red "\<(Number|Object|RegExp|String)\>" 26 | color red "\<(true|false)\>" 27 | 28 | ## String 29 | color brightyellow "L?\"(\\"|[^"])*\"" 30 | color brightyellow "L?'(\'|[^'])*'" 31 | color brightcyan "L?`(\`|[^`])*`" 32 | color brightwhite,blue start="\$\{" end="\}" 33 | 34 | ## Escapes 35 | color red "\\[0-7][0-7]?[0-7]?|\\x[0-9a-fA-F]+|\\[bfnrt'"\?\\]" 36 | 37 | ## Comments 38 | color magenta start="/\*" end="\*/" 39 | color magenta "//.*$" 40 | 41 | ## JSX Attributes 42 | color brightblue "\<(key|ref|defaultValue|dangerouslySetInnerHTML|suppressContentEditableWarning|suppressHydrationWarning|autoFocus|contentEditable|spellCheck)\>" 43 | 44 | ## Emphasis tags 45 | color brightwhite start="<([biu]|em|strong)[^>]*>" end="" 46 | 47 | ## Tags 48 | color red start="" 49 | 50 | ## color brightyellow start="<([biu]|em|strong)[^>]*>" end="" 51 | color brightyellow ""(\\.|[^"])*"" 52 | 53 | ## Attributes 54 | color green "[[:space:]](abbr|accept(-charset)?|accesskey|action|[av]?link|alt|archive|axis|background|(bg)?color|border)=" 55 | color green "[[:space:]](cell(padding|spacing)|char(off|set)?|checked|cite|class(id)?|className|compact|code(base|tag)?|cols(pan)?)=" 56 | color green "[[:space:]](content(editable)?|contextmenu|coords|data|datetime|declare|defer|dir|enctype)=" 57 | color green "[[:space:]](for|frame(border)?|headers|height|hidden|href(lang)?|hspace|http-equiv|id|ismap)=" 58 | color green "[[:space:]](label|lang|longdesc|margin(height|width)|maxlength|media|method|multiple)=" 59 | color green "[[:space:]](name|nohref|noresize|noshade|object|on(click|focus|load|mouseover|keypress)|profile|readonly|rel|rev)=" 60 | color green "[[:space:]](rows(pan)?|rules|scheme|scope|scrolling|shape|size|span|src|standby|start|style|summary|pattern)=" 61 | color green "[[:space:]](tabindex|target|text|title|type|usemap|v?align|value(type)?|vspace|width|xmlns|xml:space)=" 62 | color green "[[:space:]](required|disabled|selected)[[:space:]=>]" 63 | -------------------------------------------------------------------------------- /ts.nanorc: -------------------------------------------------------------------------------- 1 | syntax "typescript" "\.(ts)|(tsx)$" 2 | header "^#!.*\/(env +)ts-node" 3 | 4 | ## Default 5 | color white "^.+$" 6 | 7 | ## Decimal, octal and hexadecimal numbers 8 | color yellow "\<[-+]?([1-9][0-9]*|0[0-7]*|0x[0-9a-fA-F]+)([uU][lL]?|[lL][uU]?)?\>" 9 | 10 | ## Floating point number with at least one digit before decimal point 11 | color yellow "\<[-+]?([0-9]+\.[0-9]*|[0-9]*\.[0-9]+)([EePp][+-]?[0-9]+)?[fFlL]?" 12 | color yellow "\<[-+]?([0-9]+[EePp][+-]?[0-9]+)[fFlL]?" 13 | 14 | ## Keywords 15 | color green "\<(as|abstract|asserts|boolean|break|byte|case|catch)\>" 16 | color green "\<(class|const|continue|debugger|default|delete|readonly)\>" 17 | color green "\<(do|else|enum|export|extends|finally|final|for)\>" 18 | color green "\<(from|function|goto|if|implements|import|instanceof)\>" 19 | color green "\<(var|interface|int|in|is|infer|let|new|package|private)\>" 20 | color green "\<(protected|public|return|static|super|switch)\>" 21 | color green "\<(this|throw|try|typeof|type)\>" 22 | color green "\<(void|while|with|yield)\>" 23 | color green "\<(async|await)\>" 24 | color green "\<(set|get)\>" 25 | color green "\<(module|namespace)\>" 26 | color green "\<(declare)\>" 27 | 28 | ## Type specifiers 29 | color red "\<(Array|Boolean|Date|Enumerator|Error|Function)\>" 30 | color red "\<(Number|Object|RegExp|String)\>" 31 | color red "\<(true|false)\>" 32 | 33 | ## String 34 | color brightyellow "L?\"(\\"|[^"])*\"" 35 | color brightyellow "L?'(\'|[^'])*'" 36 | color brightcyan "L?`(\`|[^`])*`" 37 | color brightwhite,blue start="\$\{" end="\}" 38 | 39 | ## Escapes 40 | color red "\\[0-7][0-7]?[0-7]?|\\x[0-9a-fA-F]+|\\[bfnrt'"\?\\]" 41 | 42 | ## Comments 43 | color magenta start="/\*" end="\*/" 44 | color magenta "^\s*//.*$" 45 | 46 | ## Trailing whitespace 47 | color ,green "[[:space:]]+$" 48 | 49 | ## JSX Attributes 50 | color brightblue "\<(key|ref|defaultValue|dangerouslySetInnerHTML|suppressContentEditableWarning|suppressHydrationWarning|autoFocus|contentEditable|spellCheck)\>" 51 | 52 | ## Emphasis tags 53 | color brightwhite start="<([biu]|em|strong)[^>]*>" end="" 54 | 55 | ## Tags 56 | color red start="" 57 | 58 | ## color brightyellow start="<([biu]|em|strong)[^>]*>" end="" 59 | color brightyellow ""(\\.|[^"])*"" 60 | 61 | ## Attributes 62 | color green "[[:space:]](abbr|accept(-charset)?|accesskey|action|[av]?link|alt|archive|axis|background|(bg)?color|border)=" 63 | color green "[[:space:]](cell(padding|spacing)|char(off|set)?|checked|cite|class(id)?|className|compact|code(base|tag)?|cols(pan)?)=" 64 | color green "[[:space:]](content(editable)?|contextmenu|coords|data|datetime|declare|defer|dir|enctype)=" 65 | color green "[[:space:]](for|frame(border)?|headers|height|hidden|href(lang)?|hspace|http-equiv|id|ismap)=" 66 | color green "[[:space:]](label|lang|longdesc|margin(height|width)|maxlength|media|method|multiple)=" 67 | color green "[[:space:]](name|nohref|noresize|noshade|object|on(click|focus|load|mouseover|keypress)|profile|readonly|rel|rev)=" 68 | color green "[[:space:]](rows(pan)?|rules|scheme|scope|scrolling|shape|size|span|src|standby|start|style|summary|pattern)=" 69 | color green "[[:space:]](tabindex|target|text|title|type|usemap|v?align|value(type)?|vspace|width|xmlns|xml:space)=" 70 | color green "[[:space:]](required|disabled|selected)[[:space:]=>]" 71 | --------------------------------------------------------------------------------