Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate JSON and "JSON with comments" syntaxes? #285

Open
FichteFoll opened this issue Apr 14, 2016 · 9 comments · May be fixed by #3097
Open

Separate JSON and "JSON with comments" syntaxes? #285

FichteFoll opened this issue Apr 14, 2016 · 9 comments · May be fixed by #3097
Labels
C: Syntax T: enhancement Improvement of existing language features

Comments

@FichteFoll
Copy link
Collaborator

FichteFoll commented Apr 14, 2016

I've been thinking about this for quite a while now. It has always bothered me that Sublime Text's JSON syntax definition allows JavaScript-style comments, which are a clear violation of the standard. Users hand-editing JSON files with Sublime Text might be confused why whatever is parsing the .json file chokes on the comments that ST highlighted perfectly fine.

In order to make things more canon, I suggest introducing a different syntax for Sublime Text configuration files named "JSON with comments" or "JSONC" that will keep the features of the current JSON definition, while the "JSON" syntax gets comment support removed.

I tried googling for a possible standard for this that might have emerged over the time, but there doesn't seem to be any. I found:

Opinions?

@MattDMo
Copy link
Contributor

MattDMo commented Apr 15, 2016

Why not tighten the current JSON definition to exclude comments (and all the other additions) and strictly adhere to the JSON standard? We could then adapt the PackageDev syntax definitions into Sublime's core? This way, all users have default highlighting of .sublime-settings, .sublime-keymap, .sublime-mousemap, and all of the other pseudo-JSON files.

@FichteFoll
Copy link
Collaborator Author

Why not tighten the current JSON definition to exclude comments

Yes, that is the plan.

I wouldn't object having specific syntax definitions for ST's configuration in ST's core, but not the current ones in PackageDev. I intend to redo them anyway. Will and Jon will need to decide on that however.

@rchl
Copy link
Contributor

rchl commented Apr 26, 2016

I personally wouldn't be so happy about such change as I work with JSON files where comments are allowed. That is with chrome extensions whose manifest.json file accepts comments and also with chromium code itself which uses JSON for many things and uses https://github.com/open-source-parsers/jsoncpp to parse them which allows comments.

Of course if two separate syntaxes would be included in Sublime, then it would be easy to change for the more lax parser to be the default, so it wouldn't be that much problem.

@jskinner
Copy link
Member

There's a clear cost to this: forcing the user to change from JSON to JSON-with-comments when they're dealing with a file that allows comments. Most users won't know this is an option, so they'll just see ugly syntax errors. Users who do know to do this will still be faced with more manual work.

Given that it's making users life worse, I'd want to see a pretty strong benefit, but I'm struggling to see any at all.

@FichteFoll
Copy link
Collaborator Author

@jps, how many "JSON formats" out there outside of ST's resource files do you of that allow comments and what file extension do they use? I don't remember a single encounter, personally.

Since the resource files are known to us and they even use different file extensions, it's easy to open them with the correct syntax.

@michaelblyons
Copy link
Collaborator

@jps, how many "JSON formats" out there outside of ST's resource files do you know of that allow comments and what file extension do they use? I don't remember a single encounter, personally.

Config for VS Code (and maybe Atom?). The VSC ones are *.json extension.

Since the resource files are known to us and they even use different file extensions, it's easy to open them with the correct syntax.

True.

I'm not here to make a case for either side. I griped a little at another syntax highlighting project to do what @FichteFoll wants, but the eventual compromise was basically what ST already does now.

I was mostly annoyed there that there wasn't any lenient, comment-permitting JSON option at all, and we (that is to say "users of Discourse," like ST's forum) had to use Javascript highlighting instead, where keys were marked as strings rather than something special.

@keith-hall
Copy link
Collaborator

have you seen https://json5.org/ (kinda mentioned in the OP) and https://hjson.github.io/ ? they go beyond just adding comment support though and the latter certainly uses a different file ext, not sure about the former.

@FichteFoll
Copy link
Collaborator Author

FichteFoll commented Feb 13, 2020

Config for VS Code (and maybe Atom?).

Atom primarily uses CSON afaik (which is the same but in CoffeeScript) with the .cson extension. At least that's what the flight manual says about snippets and keymaps. It also seems to support JSON but I don't know about comments within.

@jrappen
Copy link
Contributor

jrappen commented Oct 22, 2021

Could anyone interested in having this issue fixed please test whether #3097 does indeed fix it? Thanks.

jrappen added a commit to jrappen/Packages that referenced this issue Oct 28, 2021
- Split `JSON.sublime-syntax` into ... using inheritance:
    - `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`
- Although the base syntax does not define a `prototype`, we add
  `meta_include_prototype: false` to the base syntax, to prevent
  inheriting syntaxes from injecting rules.
- make use of `variables`
- Add many more file extensions for `JSON` and `JSONC`
- Significantly extend tests to cover more parts of the syntaxes
  defined:
    - Split original test file into logical parts
    - Add indentation tests for:
        - `JSON`, `JSONC`
        - `mapping` (objects), `sequence` (arrays)
- leave `JSON` headers in `Markdown` as json only, but split up
  fenced code blocks into `json` and `jsonc` to behave similarly
  to `GitHub Flavored Markdown`
- fix tests for `meta.mapping meta.mapping.*`
- make `mapping.*` contexts more modular

- fix sublimehq#285 as requested by Jon
- address sublimehq#757 and use tips to fix line comments for `JSONC`
- address sublimehq#2430 and use sort-order as requested by deathaxe
- address sublimehq#2852 and use 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]>
jrappen added a commit to jrappen/Packages that referenced this issue Oct 28, 2021
- Split `JSON.sublime-syntax` into ... using inheritance:
    - `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`
- Although the base syntax does not define a `prototype`, we add
  `meta_include_prototype: false` to the base syntax, to prevent
  inheriting syntaxes from injecting rules.
- make use of `variables`
- Add many more file extensions for `JSON` and `JSONC`
- Significantly extend tests to cover more parts of the syntaxes
  defined:
    - Split original test file into logical parts
    - Add indentation tests for:
        - `JSON`, `JSONC`
        - `mapping` (objects), `sequence` (arrays)
- leave `JSON` headers in `Markdown` as json only, but split up
  fenced code blocks into `json` and `jsonc` to behave similarly
  to `GitHub Flavored Markdown`
- fix tests for `meta.mapping meta.mapping.*`
- make `mapping.*` contexts more modular

- fix sublimehq#285 as requested by Jon
- address sublimehq#757 and use tips to fix line comments for `JSONC`
- address sublimehq#2430 and use sort-order as requested by deathaxe
- address sublimehq#2852 and use 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]>
jrappen added a commit to jrappen/Packages that referenced this issue Oct 28, 2021
- Split `JSON.sublime-syntax` into ... using inheritance:
    - `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`
- Although the base syntax does not define a `prototype`, we add
  `meta_include_prototype: false` to the base syntax, to prevent
  inheriting syntaxes from injecting rules.
- make use of `variables`
- Add many more file extensions for `JSON` and `JSONC`
- Significantly extend tests to cover more parts of the syntaxes
  defined:
    - Split original test file into logical parts
    - Add indentation tests for:
        - `JSON`, `JSONC`
        - `mapping` (objects), `sequence` (arrays)
- leave `JSON` headers in `Markdown` as json only, but split up
  fenced code blocks into `json` and `jsonc` to behave similarly
  to `GitHub Flavored Markdown`
- fix tests for `meta.mapping meta.mapping.*`
- make `mapping.*` contexts more modular

- fix sublimehq#285 as requested by Jon
- address sublimehq#757 and use tips to fix line comments for `JSONC`
- address sublimehq#2430 and use sort-order as requested by deathaxe
- address sublimehq#2852 and use 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]>
jrappen added a commit to jrappen/Packages that referenced this issue Oct 28, 2021
- Split `JSON.sublime-syntax` into ... using inheritance:
    - `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`
- Although the base syntax does not define a `prototype`, we add
  `meta_include_prototype: false` to the base syntax, to prevent
  inheriting syntaxes from injecting rules.
- make use of `variables`
- Add many more file extensions for `JSON` and `JSONC`
- Significantly extend tests to cover more parts of the syntaxes
  defined:
    - Split original test file into logical parts
    - Add indentation tests for:
        - `JSON`, `JSONC`
        - `mapping` (objects), `sequence` (arrays)
- leave `JSON` headers in `Markdown` as json only, but split up
  fenced code blocks into `json` and `jsonc` to behave similarly
  to `GitHub Flavored Markdown`
- fix tests for `meta.mapping meta.mapping.*`
- make `mapping.*` contexts more modular

- fix sublimehq#285 as requested by Jon
- address sublimehq#757 and use tips to fix line comments for `JSONC`
- address sublimehq#2430 and use sort-order as requested by deathaxe
- address sublimehq#2852 and use 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]>
jrappen added a commit to jrappen/Packages that referenced this issue Oct 28, 2021
- Split `JSON.sublime-syntax` into ... using inheritance:
    - `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`
- Although the base syntax does not define a `prototype`, we add
  `meta_include_prototype: false` to the base syntax, to prevent
  inheriting syntaxes from injecting rules.
- make use of `variables`
- Add many more file extensions for `JSON` and `JSONC`
- Significantly extend tests to cover more parts of the syntaxes
  defined:
    - Split original test file into logical parts
    - Add indentation tests for:
        - `JSON`, `JSONC`
        - `mapping` (objects), `sequence` (arrays)
- leave `JSON` headers in `Markdown` as json only, but split up
  fenced code blocks into `json` and `jsonc` to behave similarly
  to `GitHub Flavored Markdown`
- fix tests for `meta.mapping meta.mapping.*`
- make `mapping.*` contexts more modular

- fix sublimehq#285 as requested by Jon
- address sublimehq#757 and use tips to fix line comments for `JSONC`
- address sublimehq#2430 and use sort-order as requested by deathaxe
- address sublimehq#2852 and use 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]>
jrappen added a commit to jrappen/Packages that referenced this issue Oct 31, 2021
- 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]>
jrappen added a commit to jrappen/Packages that referenced this issue Oct 31, 2021
- 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]>
jrappen added a commit to jrappen/Packages that referenced this issue Dec 2, 2021
- 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 extensions where applicable as a reference to be
      able to more quickly verify that they (still) use said syntax
      flavor
- JSON:
    - (correctly formatted) JSON code can now be prettified or minified
      via the context menu or the command palette
    - highlight leading, trailing & multiple commas as invalid
    - only allow exactly one structure (object, array) or value
      (constant, number, string) at top level (thanks to Keith)
- JSONC:
    - highlight some files by default as `JSONC` (as decided by Jon
      in sublimehq#285)
    - highlight leading & multiple commas as invalid, trailing as valid
- JSON5:
    - explicitly pos numbers, hexadecimal ints, Infinity and NaN
    - single quoted strings
    - more escape chars for strings
    - ECMA identifierName as object keys (thanks to Thomas)
        - scoped as plain unquoted strings
    - line continuation in strings (with tests thanks to Keith)
- Objects:
    - Add `meta.toc-list` scope to top level object keys to add them to
      the symbol list (also add tests, see below)
    - Highlighting speed improvements for empty objects (thanks to
      FichteFoll)
    - Make `mapping.*` contexts more modular
- Arrays:
    - Highlighting speed improvements for empty arrays (thanks to
      FichteFoll)
- Numbers:
    - Correctly scope number signs with `constant.numeric.sign` instead
      of `keyword.operator.arithmetic`
    - Significantly improve number highlighting (thanks to deathaxe)
- Syntaxes:
    - Make use of newer syntax features including those only available
      in `version: 2` syntaxes
    - Make use of `variables` (with optimizations provided by deathaxe
      and regex patterns provided by Thomas)
- Tests:
    - 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.*`
- 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:

- JSON does not have values that can be set via an inline calculation
  with the help of operators, but only simple number values. Scopes for
  number signs have changed from being `keyword.operator.arithmetic` to
  `constant.numeric.sign`. Color scheme authors should add this, should
  it be missing.
- The `JSON.sublime-syntax` now marks comments as `invalid`, third party
  plugin authors should target `JSONC.sublime-syntax` instead to have
  the same user experience as before.


- fix sublimehq#285
- address sublimehq#481 to remove incompatible regex patterns according to Will
- address sublimehq#757 to fix line comments for `JSONC` (thanks to Keith)
- address sublimehq#2430 using sort-order (as requested by deathaxe)
- address sublimehq#2852 to fix scopes of curly braces & square brackets in
  `JSON` (thanks to Thomas)
- address sublimehq/sublime_text#3154 and add symbol tests


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: Thomas Smith <[email protected]>
Co-authored-by: Will Bond <[email protected]>
Co-authored-by: deathaxe <[email protected]>
jrappen added a commit to jrappen/Packages that referenced this issue May 31, 2022
- Using inheritance split up `JSON.sublime-syntax` into:
    - `JSON.sublime-syntax` with `scope:source.json`
    - `JSONC.sublime-syntax` with `scope:source.json.jsonc`
    - `JSON5.sublime-syntax` with `scope:source.json.json5`
    - `JSON_dotNET.sublime-syntax` with `scope:source.json.json-dotnet`
- Add many more file extensions for `JSON` & `JSONC`:
    - add doc links to extensions where applicable as a reference to be
      able to more quickly verify that they (still) use said syntax
      flavor
- JSON:
    - Make use of newer syntax features including those only available
      in `version: 2` syntaxes
    - Make use of `variables` (with optimizations provided by @deathaxe
      and regex patterns provided by @Thom1729)
    - Context names now more closely match the naming scheme of other
      (recently re-written) default syntaxes
    - (correctly formatted) JSON code can now be prettified or minified
      via the context menu or the command palette. JSON code can
      optionally be auto-prettified on pre save events.
    - highlight leading, trailing & multiple commas as invalid
    - only allow exactly one structure (object, array) or value
      (constant, number, string) at top level (thanks to @keith-hall)
    - links (`meta.link.inet`) and email addresses (`meta.link.email`) are
      scoped the same as in Markdown (thanks to @deathaxe)
- JSONC:
    - highlight some files by default as `JSONC` (as decided by
      @jskinner in sublimehq#285)
    - highlight leading & multiple commas as invalid, trailing as valid
    - scope empty block comments as such
    - support syntax based folding of ST4131+,
      compare sublimehq#3291
- JSON5:
    - explicitly pos numbers, hexadecimal ints, Infinity and NaN
    - single quoted strings
    - more escape chars for strings
    - ECMA identifierName as object keys (regexes thanks to @Thom1729)
        - scoped as plain unquoted strings (thanks to @Thom1729)
        - support string interpolation (thanks to @deathaxe)
    - line continuation in strings (with tests thanks to @keith-hall)
- JSON.NET:
    - support requested by @keith-hall,
      built with feedback from @michaelblyons
- Objects:
    - Highlighting speed improvements for empty objects (thanks to
      @FichteFoll)
    - Make `mapping.*` contexts more modular
- Arrays:
    - Highlighting speed improvements for empty arrays (thanks to
      @FichteFoll)
- Numbers:
    - Correctly scope number signs with `constant.numeric.sign` instead
      of `keyword.operator.arithmetic`
    - Significantly improve number highlighting (thanks to @deathaxe)
- Completions:
    - completions have been added for language constants, including kind info
      and details (with links to docs)
        - `null`, `false`, `true` for JSON
        - `Infinity` and `NaN` for JSON5
- Settings:
    - a `default_extension` is now set for all JSON flavors
- Symbol index:
    - with an object structure at the top-level, only top-level keys
      within now show up in the index (including tests for symbols and
      syntax)
- Tests:
    - test files now test the base scope
    - Significantly extend tests to cover more parts of the syntaxes
    - Split original test file into logical parts
    - Add indentation tests for:
        - `json`, `json5` & `jsonc`
        - `mapping` (objects), `sequence` (arrays)
    - Add symbols tests for:
        - top-level keys of object structures (thanks to deathaxe)
        - languages: `json`, `json5` & `jsonc`
    - Fix tests for `meta.mapping meta.mapping.*`
- Leave `JSON` headers in `Markdown` as `json` only, but split up fenced
  code blocks into `json`, `json5` & `jsonc` to behave similarly to
  `GitHub Flavored Markdown`

BREAKING CHANGES:

- JSON does not have values that can be set via an inline calculation
  with the help of operators, but only simple number values. Scopes for
  number signs have changed from being `keyword.operator.arithmetic` to
  `constant.numeric.sign`. Color scheme authors should add this, should
  it be missing.
- The `JSON.sublime-syntax` now marks comments as `invalid`, third party
  plugin authors should instead target `JSONC.sublime-syntax` to keep
  the user experience as-is.
- Indexed symbols (i.e. top-level keys in JSON object structures) are
  scoped as `source.json meta.mapping.key - (meta.mapping.value meta.mapping.key | meta.sequence.list meta.mapping.key)`.
  Color scheme authors should add special highlighting to differentiate
  them from other keys.

- fix sublimehq#285
- address sublimehq#421 (thanks to @FichteFoll)
- address sublimehq#481 to remove incompatible regex patterns according
  to @wbond
- address sublimehq#757 to fix line comments for `JSONC` (thanks to
  @keith-hall)
- address sublimehq#2430 using sort-order (as requested by @deathaxe)
- address sublimehq#2711 with regards to `constant.language.null`
  vs. `constant.language.empty` (thanks to @FichteFoll)
- address sublimehq#2852 to fix scopes of curly braces & square
  brackets in `JSON` (thanks to @Thom1729)
- address sublimehq#3228 to fix `punctuation.separator` scopes,
  compare sublimehq#3270
- address sublimehq/sublime_text#3154 and add symbol tests

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: Thomas Smith <[email protected]>
Co-authored-by: Will Bond <[email protected]>
Co-authored-by: deathaxe <[email protected]>
jrappen added a commit to jrappen/Packages that referenced this issue May 31, 2022
- Using inheritance split up `JSON.sublime-syntax` into:
    - `JSON.sublime-syntax` with `scope:source.json`
    - `JSONC.sublime-syntax` with `scope:source.json.jsonc`
    - `JSON5.sublime-syntax` with `scope:source.json.json5`
    - `JSON_dotNET.sublime-syntax` with `scope:source.json.json-dotnet`
- Add many more file extensions for `JSON` & `JSONC`:
    - add doc links to extensions where applicable as a reference to be
      able to more quickly verify that they (still) use said syntax
      flavor
- JSON:
    - Make use of newer syntax features including those only available
      in `version: 2` syntaxes
    - Make use of `variables` (with optimizations provided by @deathaxe
      and regex patterns provided by @Thom1729)
    - Context names now more closely match the naming scheme of other
      (recently re-written) default syntaxes
    - (correctly formatted) JSON code can now be prettified or minified
      via the context menu or the command palette. JSON code can
      optionally be auto-prettified on pre save events.
    - highlight leading, trailing & multiple commas as invalid
    - only allow exactly one structure (object, array) or value
      (constant, number, string) at top level (thanks to @keith-hall)
    - links (`meta.link.inet`) and email addresses (`meta.link.email`) are
      scoped the same as in Markdown (thanks to @deathaxe)
- JSONC:
    - highlight some files by default as `JSONC` (as decided by
      @jskinner in sublimehq#285)
    - highlight leading & multiple commas as invalid, trailing as valid
    - scope empty block comments as such
    - support syntax based folding of ST4131+,
      compare sublimehq#3291
- JSON5:
    - explicitly pos numbers, hexadecimal ints, Infinity and NaN
    - single quoted strings
    - more escape chars for strings
    - ECMA identifierName as object keys (regexes thanks to @Thom1729)
        - scoped as plain unquoted strings (thanks to @Thom1729)
        - support string interpolation (thanks to @deathaxe)
    - line continuation in strings (with tests thanks to @keith-hall)
- JSON.NET:
    - support requested by @keith-hall,
      built with feedback from @michaelblyons
- Objects:
    - Highlighting speed improvements for empty objects (thanks to
      @FichteFoll)
    - Make `mapping.*` contexts more modular
- Arrays:
    - Highlighting speed improvements for empty arrays (thanks to
      @FichteFoll)
- Numbers:
    - Correctly scope number signs with `constant.numeric.sign` instead
      of `keyword.operator.arithmetic`
    - Significantly improve number highlighting (thanks to @deathaxe)
- Completions:
    - completions have been added for language constants, including kind info
      and details (with links to docs)
        - `null`, `false`, `true` for JSON
        - `Infinity` and `NaN` for JSON5
- Settings:
    - a `default_extension` is now set for all JSON flavors
- Symbol index:
    - with an object structure at the top-level, only top-level keys
      within now show up in the index (including tests for symbols and
      syntax)
- Tests:
    - test files now test the base scope
    - Significantly extend tests to cover more parts of the syntaxes
    - Split original test file into logical parts
    - Add indentation tests for:
        - `json`, `json5` & `jsonc`
        - `mapping` (objects), `sequence` (arrays)
    - Add symbols tests for:
        - top-level keys of object structures (thanks to deathaxe)
        - languages: `json`, `json5` & `jsonc`
    - Fix tests for `meta.mapping meta.mapping.*`
- Leave `JSON` headers in `Markdown` as `json` only, but split up fenced
  code blocks into `json`, `json5` & `jsonc` to behave similarly to
  `GitHub Flavored Markdown`

BREAKING CHANGES:

- JSON does not have values that can be set via an inline calculation
  with the help of operators, but only simple number values. Scopes for
  number signs have changed from being `keyword.operator.arithmetic` to
  `constant.numeric.sign`. Color scheme authors should add this, should
  it be missing.
- The `JSON.sublime-syntax` now marks comments as `invalid`, third party
  plugin authors should instead target `JSONC.sublime-syntax` to keep
  the user experience as-is.
- Indexed symbols (i.e. top-level keys in JSON object structures) are
  scoped as `source.json meta.mapping.key - (meta.mapping.value meta.mapping.key | meta.sequence.list meta.mapping.key)`.
  Color scheme authors should add special highlighting to differentiate
  them from other keys.

- fix sublimehq#285
- address sublimehq#421 (thanks to @FichteFoll)
- address sublimehq#481 to remove incompatible regex patterns according
  to @wbond
- address sublimehq#757 to fix line comments for `JSONC` (thanks to
  @keith-hall)
- address sublimehq#2430 using sort-order (as requested by @deathaxe)
- address sublimehq#2711 with regards to `constant.language.null`
  vs. `constant.language.empty` (thanks to @FichteFoll)
- address sublimehq#2852 to fix scopes of curly braces & square
  brackets in `JSON` (thanks to @Thom1729)
- address sublimehq#3228 to fix `punctuation.separator` scopes,
  compare sublimehq#3270
- address sublimehq/sublime_text#3154 and add symbol tests

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: Thomas Smith <[email protected]>
Co-authored-by: Will Bond <[email protected]>
Co-authored-by: deathaxe <[email protected]>
jrappen added a commit to jrappen/Packages that referenced this issue May 31, 2022
- Using inheritance split up `JSON.sublime-syntax` into:
    - `JSON.sublime-syntax` with `scope:source.json`
    - `JSONC.sublime-syntax` with `scope:source.json.jsonc`
    - `JSON5.sublime-syntax` with `scope:source.json.json5`
    - `JSON_dotNET.sublime-syntax` with `scope:source.json.json-dotnet`
- Add many more file extensions for `JSON` & `JSONC`:
    - add doc links to extensions where applicable as a reference to be
      able to more quickly verify that they (still) use said syntax
      flavor
- JSON:
    - Make use of newer syntax features including those only available
      in `version: 2` syntaxes
    - Make use of `variables` (with optimizations provided by @deathaxe
      and regex patterns provided by @Thom1729)
    - Context names now more closely match the naming scheme of other
      (recently re-written) default syntaxes
    - (correctly formatted) JSON code can now be prettified or minified
      via the context menu or the command palette. JSON code can
      optionally be auto-prettified on pre save events.
    - highlight leading, trailing & multiple commas as invalid
    - only allow exactly one structure (object, array) or value
      (constant, number, string) at top level (thanks to @keith-hall)
    - links (`meta.link.inet`) and email addresses (`meta.link.email`) are
      scoped the same as in Markdown (thanks to @deathaxe)
- JSONC:
    - highlight some files by default as `JSONC` (as decided by
      @jskinner in sublimehq#285)
    - highlight leading & multiple commas as invalid, trailing as valid
    - scope empty block comments as such
    - support syntax based folding of ST4131+,
      compare sublimehq#3291
- JSON5:
    - explicitly pos numbers, hexadecimal ints, Infinity and NaN
    - single quoted strings
    - more escape chars for strings
    - ECMA identifierName as object keys (regexes thanks to @Thom1729)
        - scoped as plain unquoted strings (thanks to @Thom1729)
        - support string interpolation (thanks to @deathaxe)
    - line continuation in strings (with tests thanks to @keith-hall)
- JSON.NET:
    - support requested by @keith-hall,
      built with feedback from @michaelblyons
- Objects:
    - Highlighting speed improvements for empty objects (thanks to
      @FichteFoll)
    - Make `mapping.*` contexts more modular
- Arrays:
    - Highlighting speed improvements for empty arrays (thanks to
      @FichteFoll)
- Numbers:
    - Correctly scope number signs with `constant.numeric.sign` instead
      of `keyword.operator.arithmetic`
    - Significantly improve number highlighting (thanks to @deathaxe)
- Completions:
    - completions have been added for language constants, including kind info
      and details (with links to docs)
        - `null`, `false`, `true` for JSON
        - `Infinity` and `NaN` for JSON5
- Settings:
    - a `default_extension` is now set for all JSON flavors
- Symbol index:
    - with an object structure at the top-level, only top-level keys
      within now show up in the index (including tests for symbols and
      syntax)
- Tests:
    - test files now test the base scope
    - Significantly extend tests to cover more parts of the syntaxes
    - Split original test file into logical parts
    - Add indentation tests for:
        - `json`, `json5` & `jsonc`
        - `mapping` (objects), `sequence` (arrays)
    - Add symbols tests for:
        - top-level keys of object structures (thanks to deathaxe)
        - languages: `json`, `json5` & `jsonc`
    - Fix tests for `meta.mapping meta.mapping.*`
- Leave `JSON` headers in `Markdown` as `json` only, but split up fenced
  code blocks into `json`, `json5` & `jsonc` to behave similarly to
  `GitHub Flavored Markdown`

BREAKING CHANGES:

- JSON does not have values that can be set via an inline calculation
  with the help of operators, but only simple number values. Scopes for
  number signs have changed from being `keyword.operator.arithmetic` to
  `constant.numeric.sign`. Color scheme authors should add this, should
  it be missing.
- The `JSON.sublime-syntax` now marks comments as `invalid`, third party
  plugin authors should instead target `JSONC.sublime-syntax` to keep
  the user experience as-is.
- Indexed symbols (i.e. top-level keys in JSON object structures) are
  scoped as `source.json meta.mapping.key - (meta.mapping.value meta.mapping.key | meta.sequence.list meta.mapping.key)`.
  Color scheme authors should add special highlighting to differentiate
  them from other keys.

- fix sublimehq#285
- address sublimehq#421 (thanks to @FichteFoll)
- address sublimehq#481 to remove incompatible regex patterns according
  to @wbond
- address sublimehq#757 to fix line comments for `JSONC` (thanks to
  @keith-hall)
- address sublimehq#2430 using sort-order (as requested by @deathaxe)
- address sublimehq#2711 with regards to `constant.language.null`
  vs. `constant.language.empty` (thanks to @FichteFoll)
- address sublimehq#2852 to fix scopes of curly braces & square
  brackets in `JSON` (thanks to @Thom1729)
- address sublimehq#3228 to fix `punctuation.separator` scopes,
  compare sublimehq#3270
- address sublimehq/sublime_text#3154 and add symbol tests

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: Thomas Smith <[email protected]>
Co-authored-by: Will Bond <[email protected]>
Co-authored-by: deathaxe <[email protected]>
jrappen added a commit to jrappen/Packages that referenced this issue Jun 1, 2022
- Using inheritance split up `JSON.sublime-syntax` into:
    - `JSON.sublime-syntax` with `scope:source.json`
    - `JSONC.sublime-syntax` with `scope:source.json.jsonc`
    - `JSON5.sublime-syntax` with `scope:source.json.json5`
    - `JSON_dotNET.sublime-syntax` with `scope:source.json.json-dotnet`
- Add many more file extensions for `JSON` & `JSONC`:
    - add doc links to extensions where applicable as a reference to be
      able to more quickly verify that they (still) use said syntax
      flavor
- JSON:
    - Make use of newer syntax features including those only available
      in `version: 2` syntaxes
    - Make use of `variables` (with optimizations provided by @deathaxe
      and regex patterns provided by @Thom1729)
    - Context names now more closely match the naming scheme of other
      (recently re-written) default syntaxes
    - (correctly formatted) JSON code can now be prettified or minified
      via the context menu or the command palette. JSON code can
      optionally be auto-prettified on pre save events.
    - highlight leading, trailing & multiple commas as invalid
    - only allow exactly one structure (object, array) or value
      (constant, number, string) at top level (thanks to @keith-hall)
    - links (`meta.link.inet`) and email addresses (`meta.link.email`) are
      scoped the same as in Markdown (thanks to @deathaxe)
- JSONC:
    - highlight some files by default as `JSONC` (as decided by
      @jskinner in sublimehq#285)
    - highlight leading & multiple commas as invalid, trailing as valid
    - scope empty block comments as such
    - support syntax based folding of ST4131+,
      compare sublimehq#3291
- JSON5:
    - explicitly pos numbers, hexadecimal ints, Infinity and NaN
    - single quoted strings
    - more escape chars for strings
    - ECMA identifierName as object keys (regexes thanks to @Thom1729)
        - scoped as plain unquoted strings (thanks to @Thom1729)
        - support string interpolation (thanks to @deathaxe)
    - line continuation in strings (with tests thanks to @keith-hall)
- JSON.NET:
    - support requested by @keith-hall,
      built with feedback from @michaelblyons
- Objects:
    - Highlighting speed improvements for empty objects (thanks to
      @FichteFoll)
    - Make `mapping.*` contexts more modular
- Arrays:
    - Highlighting speed improvements for empty arrays (thanks to
      @FichteFoll)
- Numbers:
    - Correctly scope number signs with `constant.numeric.sign` instead
      of `keyword.operator.arithmetic`
    - Significantly improve number highlighting (thanks to @deathaxe)
- Completions:
    - completions have been added for language constants, including kind info
      and details (with links to docs)
        - `null`, `false`, `true` for JSON
        - `Infinity` and `NaN` for JSON5
- Settings:
    - a `default_extension` is now set for all JSON flavors
- Symbol index:
    - with an object structure at the top-level, only top-level keys
      within now show up in the index (including tests for symbols and
      syntax)
- Tests:
    - test files now test the base scope
    - Significantly extend tests to cover more parts of the syntaxes
    - Split original test file into logical parts
    - Add indentation tests for:
        - `json`, `json5` & `jsonc`
        - `mapping` (objects), `sequence` (arrays)
    - Add symbols tests for:
        - top-level keys of object structures (thanks to deathaxe)
        - languages: `json`, `json5` & `jsonc`
    - Fix tests for `meta.mapping meta.mapping.*`
- Leave `JSON` headers in `Markdown` as `json` only, but split up fenced
  code blocks into `json`, `json5` & `jsonc` to behave similarly to
  `GitHub Flavored Markdown`

BREAKING CHANGES:

- JSON does not have values that can be set via an inline calculation
  with the help of operators, but only simple number values. Scopes for
  number signs have changed from being `keyword.operator.arithmetic` to
  `constant.numeric.sign`. Color scheme authors should add this, should
  it be missing.
- The `JSON.sublime-syntax` now marks comments as `invalid`, third party
  plugin authors should instead target `JSONC.sublime-syntax` to keep
  the user experience as-is.
- Indexed symbols (i.e. top-level keys in JSON object structures) are
  scoped as `source.json meta.mapping.key - (meta.mapping.value meta.mapping.key | meta.sequence.list meta.mapping.key)`.
  Color scheme authors should add special highlighting to differentiate
  them from other keys.

- fix sublimehq#285
- address sublimehq#421 (thanks to @FichteFoll)
- address sublimehq#481 to remove incompatible regex patterns according
  to @wbond
- address sublimehq#757 to fix line comments for `JSONC` (thanks to
  @keith-hall)
- address sublimehq#2430 using sort-order (as requested by @deathaxe)
- address sublimehq#2711 with regards to `constant.language.null`
  vs. `constant.language.empty` (thanks to @FichteFoll)
- address sublimehq#2852 to fix scopes of curly braces & square
  brackets in `JSON` (thanks to @Thom1729)
- address sublimehq#3228 to fix `punctuation.separator` scopes,
  compare sublimehq#3270
- address sublimehq/sublime_text#3154 and add symbol tests

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: Thomas Smith <[email protected]>
Co-authored-by: Will Bond <[email protected]>
Co-authored-by: deathaxe <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: Syntax T: enhancement Improvement of existing language features
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants