]> git.lizzy.rs Git - micro.git/blob - runtime/syntax/javascript.yaml
fix javascript syntax recognizing parts of words as keywords (#2462)
[micro.git] / runtime / syntax / javascript.yaml
1 filetype: javascript
2
3 detect:
4     filename: "(\\.js$|\\.es[5678]?$|\\.mjs$)"
5     header: "^#!.*/(env +)?node( |$)"
6
7 rules:
8     - constant.number: "\\b[-+]?([1-9][0-9]*|0[0-7]*|0x[0-9a-fA-F]+)([uU][lL]?|[lL][uU]?)?\\b"
9     - constant.number: "\\b[-+]?([0-9]+\\.[0-9]*|[0-9]*\\.[0-9]+)([EePp][+-]?[0-9]+)?[fFlL]?"
10     - constant.number: "\\b[-+]?([0-9]+[EePp][+-]?[0-9]+)[fFlL]?"
11     #- identifier: "[A-Za-z_][A-Za-z0-9_]*[[:space:]]*[(]"
12     # ^ this is not correct usage of the identifier color
13     - symbol.brackets: "(\\{|\\})"
14     - symbol.brackets: "(\\(|\\))"
15     - symbol.brackets: "(\\[|\\])"
16     - symbol.brackets: "(\\{|\\})"
17     - symbol.brackets: "(\\(|\\))"
18     - symbol.brackets: "(\\[|\\])"
19     - symbol.operator: "([-+/*=<>!~%?:&|]|[.]{3})"
20     - statement: "\\b(async|await|break|case|catch|const|continue|debugger|default)\\b"
21     - statement: "\\b(delete|do|else|export|finally|for|function\\*?|class|extends)\\b"
22     - statement: "\\b(get|if|import|from|in|of|instanceof|let|new|reject|resolve|return)\\b"
23     - statement: "\\b(set|static|super|switch|this|throw|try|typeof|var|void|while|with|yield)\\b"
24     # reserved but unassigned
25     - error: "\\b(enum|implements|interface|package|private|protected|public)\\b"
26     - constant: "\\b(globalThis|Infinity|null|undefined|NaN)\\b"
27     - constant: "\\b(null|undefined|NaN)\\b"
28     - constant: "\\b(true|false)\\b"
29     - type: "\\b(Array|Boolean|Date|Enumerator|Error|Function|Generator|Map|Math)\\b"
30     - type: "\\b(Number|Object|Promise|Proxy|Reflect|RegExp|Set|String|Symbol|WeakMap|WeakSet)\\b"
31     - type: "\\b(BigInt64Array|BigUint64Array|Float32Array|Float64Array|Int16Array)\\b"
32
33     # - constant: "/[^*]([^/]|(\\\\/))*[^\\\\]/[gim]*"
34     - constant: "\\\\[0-7][0-7]?[0-7]?|\\\\x[0-9a-fA-F]+|\\\\[bfnrt'\"\\?\\\\]"
35     - comment: "^#!.*/(env +)?node( |$)"
36
37     - identifier: "\\b(alert|decodeURI|decodeURIComponent|document|encodeURI|encodeURIComponent|escape|eval|isFinite|isNaN|parseFloat|parseInt|unescape|uneval|window)\\b"
38     - identifier: "\\b(Intl|WebAssembly)\\b"
39     - identifier: "\\b(Arguments)\\b"
40
41
42     - constant.string:
43         start: "\""
44         end: "\""
45         skip: "\\\\."
46         rules:
47             - constant.specialChar: "\\\\."
48
49     - constant.string:
50         start: "'"
51         end: "'"
52         skip: "\\\\."
53         rules:
54             - constant.specialChar: "\\\\."
55
56     - constant.string:
57         start: "`"
58         end: "`"
59         rules:
60             - constant.specialChar: "\\\\."
61             - identifier: "\\x24\\{.*?\\}"
62
63     - constant.bool: "\\b(true|false)\\b"
64     - constant.bool.false: "\\b(false)\\b"
65     - constant.bool.true: "\\b(true)\\b"
66
67     - comment:
68         start: "//"
69         end: "$"
70         rules:
71             - todo: "(TODO|XXX|FIXME)"
72
73     - comment:
74         start: "/\\*"
75         end: "\\*/"
76         rules:
77             # function documentation
78             - identifier: "\\s\\*\\s.*"
79             - todo: "(TODO|XXX|FIXME)"