Skip to content

Commit

Permalink
[JSON] Rewrite syntax
Browse files Browse the repository at this point in the history
- 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]>
  • Loading branch information
10 people committed Oct 31, 2021
1 parent 258ace9 commit a82b226
Show file tree
Hide file tree
Showing 51 changed files with 3,275 additions and 313 deletions.
25 changes: 25 additions & 0 deletions JSON/Comments - JSON5.tmPreferences
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
<key>scope</key>
<string>source.json.json5</string>
<key>settings</key>
<dict>
<key>shellVariables</key>
<array>
<dict>
<key>name</key><string>TM_COMMENT_START</string>
<key>value</key><string>// </string>
</dict>
<dict>
<key>name</key><string>TM_COMMENT_START_2</string>
<key>value</key><string>/*</string>
</dict>
<dict>
<key>name</key><string>TM_COMMENT_END_2</string>
<key>value</key><string>*/</string>
</dict>
</array>
</dict>
</dict>
</plist>
25 changes: 25 additions & 0 deletions JSON/Comments - JSONC.tmPreferences
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
<key>scope</key>
<string>source.json.jsonc</string>
<key>settings</key>
<dict>
<key>shellVariables</key>
<array>
<dict>
<key>name</key><string>TM_COMMENT_START</string>
<key>value</key><string>// </string>
</dict>
<dict>
<key>name</key><string>TM_COMMENT_START_2</string>
<key>value</key><string>/*</string>
</dict>
<dict>
<key>name</key><string>TM_COMMENT_END_2</string>
<key>value</key><string>*/</string>
</dict>
</array>
</dict>
</dict>
</plist>
31 changes: 0 additions & 31 deletions JSON/Comments.tmPreferences

This file was deleted.

2 changes: 1 addition & 1 deletion JSON/Default.sublime-keymap
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@
{ "key": "following_text", "operator": "regex_contains", "operand": "^\\]", "match_all": true }
]
},
]
]
Loading

0 comments on commit a82b226

Please sign in to comment.