Skip to content

Commit cc2f446

Browse files
jrappenAshwin Shenoyjfcherngjwortmannjskinner
committed
[JSON] Rewrite syntax
- Using inheritance split up `JSON.sublime-syntax` into: - `JSON (Basic).sublime-syntax` with `scope:source.json.basic` - `JSON.sublime-syntax` with `scope:source.json` - `JSONC.sublime-syntax` with `scope:source.json.jsonc` - `JSON5.sublime-syntax` with `scope:source.json.json5` - Add many more file extensions for `JSON` & `JSONC`: - add doc links to exensions where applicable as a reference to be able to more quickly verify that they (still) use said syntax flavor - Add JSON5 with support for: - explicitly pos numbers, hexadecimal ints, Infinity and NaN - single quoted strings - more escape chars for strings - Only allow objects or arrays at the top level - add `meta.toc-list` scope to top level object keys to add them to the symbol list (also add tests, see below) - Make use of newer syntax features including those only available in `version: 2` syntaxes - Make use of `variables` - Highlighting speed improvements for empty objects and empty arrays - Significantly improve number highlighting - Correctly scope number signs with `constant.numeric.sign` instead of `keyword.operator.arithmetic` - Significantly extend tests to cover more parts of the syntaxes defined: - Split original test file into logical parts - Add indentation tests for: - `json`, `jsonc` & `json5` - `mapping` (objects), `sequence` (arrays) - Add symbols tests for: - scope: `meta.toc-list.json | meta.toc-list.json5` - languages: `json`, `jsonc` & `json5` - Fix tests for `meta.mapping meta.mapping.*` - Make `mapping.*` contexts more modular - Leave `JSON` headers in `Markdown` as `json` only, but split up fenced code blocks into `json`, `jsonc` & `json5` to behave similarly to `GitHub Flavored Markdown` BREAKING CHANGES: - scopes for number signs have changed from being `keyword.operator.arithmetic` to `constant.numeric.sign` - fix sublimehq#285 as requested by Jon - address sublimehq#757 using tips to fix line comments for `JSONC` - address sublimehq#2430 using sort-order as requested by deathaxe - address sublimehq#2852 using tips to fix scopes of curly braces & square brackets in `JSON` Co-authored-by: Ashwin Shenoy <[email protected]> Co-authored-by: Jack Cherng <[email protected]> Co-authored-by: Janos Wortmann <[email protected]> Co-authored-by: Jon Skinner <[email protected]> Co-authored-by: FichteFoll <[email protected]> Co-authored-by: Keith Hall <[email protected]> Co-authored-by: Michael B. Lyons <[email protected]> Co-authored-by: Rafał Chłodnicki <[email protected]> Co-authored-by: deathaxe <[email protected]>
1 parent 258ace9 commit cc2f446

File tree

50 files changed

+3262
-313
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+3262
-313
lines changed

JSON/Comments - JSON5.tmPreferences

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<plist version="1.0">
3+
<dict>
4+
<key>scope</key>
5+
<string>source.json.json5</string>
6+
<key>settings</key>
7+
<dict>
8+
<key>shellVariables</key>
9+
<array>
10+
<dict>
11+
<key>name</key><string>TM_COMMENT_START</string>
12+
<key>value</key><string>// </string>
13+
</dict>
14+
<dict>
15+
<key>name</key><string>TM_COMMENT_START_2</string>
16+
<key>value</key><string>/*</string>
17+
</dict>
18+
<dict>
19+
<key>name</key><string>TM_COMMENT_END_2</string>
20+
<key>value</key><string>*/</string>
21+
</dict>
22+
</array>
23+
</dict>
24+
</dict>
25+
</plist>

JSON/Comments - JSONC.tmPreferences

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<plist version="1.0">
3+
<dict>
4+
<key>scope</key>
5+
<string>source.json.jsonc</string>
6+
<key>settings</key>
7+
<dict>
8+
<key>shellVariables</key>
9+
<array>
10+
<dict>
11+
<key>name</key><string>TM_COMMENT_START</string>
12+
<key>value</key><string>// </string>
13+
</dict>
14+
<dict>
15+
<key>name</key><string>TM_COMMENT_START_2</string>
16+
<key>value</key><string>/*</string>
17+
</dict>
18+
<dict>
19+
<key>name</key><string>TM_COMMENT_END_2</string>
20+
<key>value</key><string>*/</string>
21+
</dict>
22+
</array>
23+
</dict>
24+
</dict>
25+
</plist>

JSON/Comments.tmPreferences

-31
This file was deleted.

JSON/Default.sublime-keymap

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,4 @@
6060
{ "key": "following_text", "operator": "regex_contains", "operand": "^\\]", "match_all": true }
6161
]
6262
},
63-
]
63+
]

0 commit comments

Comments
 (0)