|
| 1 | +# [PackageDev] target_format: plist, ext: tmLanguage |
| 2 | +name: JSON (Javascript Next) |
| 3 | +scopeName: source.json |
| 4 | +fileTypes: [json, sublime-settings, sublime-menu, sublime-keymap, sublime-mousemap, |
| 5 | + sublime-theme, sublime-build, sublime-project, sublime-completions] |
| 6 | +uuid: 8f97457b-516e-48ce-83c7-08ae12fb327a |
| 7 | +foldingStartMarker: >- |
| 8 | + (?x) # turn on extended mode |
| 9 | + ^ # a line beginning with |
| 10 | + \s* # some optional space |
| 11 | + [{\[] # the start of an object or array |
| 12 | + (?! # but not followed by |
| 13 | + .* # whatever |
| 14 | + [}\]] # and the close of an object or array |
| 15 | + ,? # an optional comma |
| 16 | + \s* # some optional space |
| 17 | + $ # at the end of the line |
| 18 | + ) |
| 19 | + | # ...or... |
| 20 | + [{\[] # the start of an object or array |
| 21 | + \s* # some optional space |
| 22 | + $ # at the end of the line |
| 23 | +foldingStopMarker: >- |
| 24 | + (?x) # turn on extended mode |
| 25 | + ^ # a line beginning with |
| 26 | + \s* # some optional space |
| 27 | + [}\]] # and the close of an object or array |
| 28 | +keyEquivalent: ^~J |
| 29 | + |
| 30 | +patterns: |
| 31 | +- include: '#value' |
| 32 | + |
| 33 | +repository: |
| 34 | + array: |
| 35 | + name: meta.structure.array.json |
| 36 | + begin: \[ |
| 37 | + beginCaptures: |
| 38 | + '0': {name: punctuation.definition.array.begin.json} |
| 39 | + end: \] |
| 40 | + endCaptures: |
| 41 | + '0': {name: punctuation.definition.array.end.json} |
| 42 | + patterns: |
| 43 | + - include: '#value' |
| 44 | + - name: punctuation.separator.array.json |
| 45 | + match: ',' |
| 46 | + - name: invalid.illegal.expected-array-separator.json |
| 47 | + match: '[^\s\]]' |
| 48 | + |
| 49 | + comments: |
| 50 | + patterns: |
| 51 | + - name: comment.block.documentation.json |
| 52 | + begin: /\*\* |
| 53 | + end: \*/ |
| 54 | + captures: |
| 55 | + '0': {name: punctuation.definition.comment.json} |
| 56 | + - name: comment.block.json |
| 57 | + begin: /\* |
| 58 | + end: \*/ |
| 59 | + captures: |
| 60 | + '0': {name: punctuation.definition.comment.json} |
| 61 | + - name: comment.line.double-slash.js |
| 62 | + match: (//).*$\n? |
| 63 | + captures: |
| 64 | + '1': {name: punctuation.definition.comment.json} |
| 65 | + |
| 66 | + constant: |
| 67 | + name: constant.language.json |
| 68 | + match: \b(?:true|false|null)\b |
| 69 | + |
| 70 | + # handles integer and decimal numbers |
| 71 | + number: |
| 72 | + name: constant.numeric.json |
| 73 | + match: >- |
| 74 | + (?x) # turn on extended mode |
| 75 | + -? # an optional minus |
| 76 | + (?: |
| 77 | + 0 # a zero |
| 78 | + | # ...or... |
| 79 | + [1-9] # a 1-9 character |
| 80 | + \d* # followed by zero or more digits |
| 81 | + ) |
| 82 | + (?: |
| 83 | + (?: |
| 84 | + \. # a period |
| 85 | + \d+ # followed by one or more digits |
| 86 | + )? |
| 87 | + (?: |
| 88 | + [eE] # an e character |
| 89 | + [+-]? # followed by an option +/- |
| 90 | + \d+ # followed by one or more digits |
| 91 | + )? # make exponent optional |
| 92 | + )? # make decimal portion optional |
| 93 | +
|
| 94 | + # a JSON object |
| 95 | + object: |
| 96 | + name: meta.structure.dictionary.json |
| 97 | + begin: \{ |
| 98 | + beginCaptures: |
| 99 | + '0': {name: punctuation.definition.dictionary.begin.json} |
| 100 | + end: \} |
| 101 | + endCaptures: |
| 102 | + '0': {name: punctuation.definition.dictionary.end.json} |
| 103 | + patterns: |
| 104 | + - comment: the JSON object key |
| 105 | + include: '#string' |
| 106 | + - include: '#comments' |
| 107 | + - name: meta.structure.dictionary.value.json |
| 108 | + begin: ':' |
| 109 | + beginCaptures: |
| 110 | + '0': {name: punctuation.separator.dictionary.key-value.json} |
| 111 | + end: (,)|(?=\}) |
| 112 | + endCaptures: |
| 113 | + '1': {name: punctuation.separator.dictionary.pair.json} |
| 114 | + patterns: |
| 115 | + - comment: the JSON object value |
| 116 | + include: '#value' |
| 117 | + - name: invalid.illegal.expected-dictionary-separator.json |
| 118 | + match: '[^\s,]' |
| 119 | + - name: invalid.illegal.expected-dictionary-separator.json |
| 120 | + match: '[^\s\}]' |
| 121 | + |
| 122 | + string: |
| 123 | + name: string.quoted.double.json |
| 124 | + begin: '"' |
| 125 | + beginCaptures: |
| 126 | + '0': {name: punctuation.definition.string.begin.json} |
| 127 | + end: '"' |
| 128 | + endCaptures: |
| 129 | + '0': {name: punctuation.definition.string.end.json} |
| 130 | + patterns: |
| 131 | + - name: constant.character.escape.json |
| 132 | + match: >- |
| 133 | + (?x) # turn on extended mode |
| 134 | + \\ # a literal backslash |
| 135 | + (?: # ...followed by... |
| 136 | + ["\\/bfnrt] # one of these characters |
| 137 | + | # ...or... |
| 138 | + u # a u |
| 139 | + [0-9a-fA-F]{4}) # and four hex digits |
| 140 | + - name: invalid.illegal.unrecognized-string-escape.json |
| 141 | + match: \\. |
| 142 | + |
| 143 | + # the 'value' diagram at http://json.org |
| 144 | + value: |
| 145 | + patterns: |
| 146 | + - include: '#constant' |
| 147 | + - include: '#number' |
| 148 | + - include: '#string' |
| 149 | + - include: '#array' |
| 150 | + - include: '#object' |
| 151 | + - include: '#comments' |
0 commit comments