Skip to content

Commit

Permalink
[JSON] add latest upstream changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jrappen committed Nov 6, 2021
1 parent 985aec7 commit d332980
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 50 deletions.
43 changes: 32 additions & 11 deletions JSON/JSON (Basic).sublime-syntax
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
%YAML 1.2
---
# https://yaml.org/spec/1.2/spec.html
# https://www.sublimetext.com/docs/syntax.html#ver-dev
# https://www.sublimetext.com/docs/syntax.html#testing:ver-dev
# https://www.sublimetext.com/docs/scope_naming.html
# YAML Documentation:
# https://yaml.org/spec/1.2/spec.html
# Sublime Text Documentation:
# https://www.sublimetext.com/docs/syntax.html#ver-dev
# https://www.sublimetext.com/docs/syntax.html#testing:ver-dev
# https://www.sublimetext.com/docs/scope_naming.html
# This file is being maintained at:
# https://github.com/sublimehq/Packages/blob/master/JSON/JSON%20(Basic).sublime-syntax
#
name: JSON (Basic)
scope: source.json.basic
version: 2
Expand All @@ -24,6 +29,10 @@ contexts:
- match: '(?=\S)'
push: top-level-expect-object

####[ Top level ]#######################################################################################################

# Try these below one-by-one.

top-level-expect-object:
- include: top-level-objects
- match: ''
Expand Down Expand Up @@ -57,6 +66,8 @@ contexts:
- match: '\S*'
scope: invalid.illegal.unexpected-code-after-first-structure-or-value.json

####[ Structural helpers ]##############################################################################################

any:
- include: structures
- include: values
Expand All @@ -70,46 +81,52 @@ contexts:
- include: numbers
- include: strings

####[ Helpers ]#########################################################################################################

eol-pop:
- match: '$\n?'
pop: 1


####[ Comments ]########################################################################################################

comments:
- meta_include_prototype: false
- include: comment-line
- include: comment-doc-block
- include: comment-block

comment-line:
- meta_include_prototype: false
- match: '//'
scope: invalid.illegal.comment.json
push:
- meta_content_scope: invalid.illegal.comment.json
- meta_include_prototype: false
- meta_content_scope: invalid.illegal.comment.json
- include: eol-pop

comment-doc-block:
- meta_include_prototype: false
- match: '/\*\*(?!/)'
scope: invalid.illegal.comment.json
push:
- meta_content_scope: invalid.illegal.comment.json
- meta_include_prototype: false
- meta_content_scope: invalid.illegal.comment.json
- include: comment-block-end
- match: '^\s*(\*)(?!/)'
captures:
1: invalid.illegal.comment.json

comment-block:
- meta_include_prototype: false
- match: '/\*'
scope: invalid.illegal.comment.json
push:
- meta_content_scope: invalid.illegal.comment.json
- meta_include_prototype: false
- meta_content_scope: invalid.illegal.comment.json
- include: comment-block-end

comment-block-end:
- meta_include_prototype: false
- match: '\*/'
scope: invalid.illegal.comment.json
pop: 1
Expand All @@ -121,7 +138,7 @@ contexts:
scope: constant.language.null.json
- match: \b(?:false|true)\b
scope: constant.language.boolean.json
# when for example typing "Null" or "NULL" instead of "null"
# when erroneously containing upper case letters
- match: \b(?i:null)\b
scope: invalid.illegal.expected-lower-case-null.json
- match: \b(?i:false|true)\b
Expand Down Expand Up @@ -190,15 +207,18 @@ contexts:
pop: 1

double-quoted-string-escape-characters:
- meta_include_prototype: false
- match: \\\"
scope: constant.character.escape.double-quote.json
- include: string-escape-characters

string-escape-characters:
- meta_include_prototype: false
- include: valid-string-escape-characters
- include: invalid-string-escape-characters

valid-string-escape-characters:
- meta_include_prototype: false
- match: \\\\
scope: constant.character.escape.back-slash.json
- match: \\\/
Expand All @@ -217,6 +237,7 @@ contexts:
scope: constant.character.escape.unicode-symbol.basic-multilingual-plane.json

invalid-string-escape-characters:
- meta_include_prototype: false
- match: \\.
scope: invalid.illegal.unrecognized-string-escape.json

Expand Down Expand Up @@ -329,14 +350,14 @@ contexts:

top-level-mapping-key-double-quoted:
- clear_scopes: 1
- meta_scope: meta.mapping.key.json meta.toc-list.json meta.string.json string.quoted.double.json
- meta_include_prototype: false
- meta_scope: meta.mapping.key.json meta.toc-list.json meta.string.json string.quoted.double.json
- include: inside-double-quoted-string

mapping-key-double-quoted:
- clear_scopes: 1
- meta_scope: meta.mapping.key.json meta.string.json string.quoted.double.json
- meta_include_prototype: false
- meta_scope: meta.mapping.key.json meta.string.json string.quoted.double.json
- include: inside-double-quoted-string

mapping-separator:
Expand Down
13 changes: 9 additions & 4 deletions JSON/JSON.sublime-syntax
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
%YAML 1.2
---
# https://yaml.org/spec/1.2/spec.html
# https://www.sublimetext.com/docs/syntax.html#ver-dev
# https://www.sublimetext.com/docs/syntax.html#testing:ver-dev
# https://www.sublimetext.com/docs/scope_naming.html
# YAML Documentation:
# https://yaml.org/spec/1.2/spec.html
# Sublime Text Documentation:
# https://www.sublimetext.com/docs/syntax.html#ver-dev
# https://www.sublimetext.com/docs/syntax.html#testing:ver-dev
# https://www.sublimetext.com/docs/scope_naming.html
# This file is being maintained at:
# https://github.com/sublimehq/Packages/blob/master/JSON/JSON.sublime-syntax
#
name: JSON
scope: source.json
version: 2
Expand Down
22 changes: 14 additions & 8 deletions JSON/JSON5.sublime-syntax
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
%YAML 1.2
---
# https://yaml.org/spec/1.2/spec.html
# https://www.sublimetext.com/docs/syntax.html#ver-dev
# https://www.sublimetext.com/docs/syntax.html#testing:ver-dev
# https://www.sublimetext.com/docs/scope_naming.html
# YAML Documentation:
# https://yaml.org/spec/1.2/spec.html
# Sublime Text Documentation:
# https://www.sublimetext.com/docs/syntax.html#ver-dev
# https://www.sublimetext.com/docs/syntax.html#testing:ver-dev
# https://www.sublimetext.com/docs/scope_naming.html
# This file is being maintained at:
# https://github.com/sublimehq/Packages/blob/master/JSON/JSON5.sublime-syntax
#
name: JSON5
scope: source.json.json5
version: 2
Expand Down Expand Up @@ -141,6 +146,7 @@ contexts:
pop: 1

single-quoted-string-escape-characters:
- meta_include_prototype: false
- match: \\\'
scope: constant.character.escape.single-quote.json5
- include: string-escape-characters
Expand Down Expand Up @@ -193,13 +199,13 @@ contexts:
top-level-mapping-key-ecma:
- clear_scopes: 1
- match: '{{identifier_name}}'
scope: meta.mapping.key.json5 meta.toc-list.json5
scope: meta.mapping.key.json5 meta.toc-list.json5 meta.string.json5 string.unquoted.plain.json5
pop: 1

top-level-mapping-key-single-quoted:
- clear_scopes: 1
- meta_scope: meta.mapping.key.json5 meta.toc-list.json5 meta.string.json5 string.quoted.single.json5
- meta_include_prototype: false
- meta_scope: meta.mapping.key.json5 meta.toc-list.json5 meta.string.json5 string.quoted.single.json5
- include: inside-single-quoted-string

mapping-key:
Expand All @@ -213,11 +219,11 @@ contexts:
mapping-key-ecma:
- clear_scopes: 1
- match: '{{identifier_name}}'
scope: meta.mapping.key.json5
scope: meta.mapping.key.json5 meta.string.json5 string.unquoted.plain.json5
pop: 1

mapping-key-single-quoted:
- clear_scopes: 1
- meta_scope: meta.mapping.key.json5 meta.string.json5 string.quoted.single.json5
- meta_include_prototype: false
- meta_scope: meta.mapping.key.json5 meta.string.json5 string.quoted.single.json5
- include: inside-single-quoted-string
23 changes: 16 additions & 7 deletions JSON/JSONC.sublime-syntax
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
%YAML 1.2
---
# https://yaml.org/spec/1.2/spec.html
# https://www.sublimetext.com/docs/syntax.html#ver-dev
# https://www.sublimetext.com/docs/syntax.html#testing:ver-dev
# https://www.sublimetext.com/docs/scope_naming.html
# YAML Documentation:
# https://yaml.org/spec/1.2/spec.html
# Sublime Text Documentation:
# https://www.sublimetext.com/docs/syntax.html#ver-dev
# https://www.sublimetext.com/docs/syntax.html#testing:ver-dev
# https://www.sublimetext.com/docs/scope_naming.html
# This file is being maintained at:
# https://github.com/sublimehq/Packages/blob/master/JSON/JSONC.sublime-syntax
#
name: JSONC (JSON with Comments)
scope: source.json.jsonc
version: 2
Expand Down Expand Up @@ -114,36 +119,40 @@ contexts:

# completely override original context
comment-line:
- meta_include_prototype: false
- match: '//'
scope: punctuation.definition.comment.jsonc
push:
- meta_scope: comment.line.double-slash.jsonc
- meta_include_prototype: false
- meta_scope: comment.line.double-slash.jsonc
- include: eol-pop

# completely override original context
comment-doc-block:
- meta_include_prototype: false
- match: '/\*\*(?!/)'
scope: punctuation.definition.comment.begin.jsonc
push:
- meta_scope: comment.block.documentation.jsonc
- meta_include_prototype: false
- meta_scope: comment.block.documentation.jsonc
- include: comment-block-end
- match: '^\s*(\*)(?!/)'
captures:
1: punctuation.definition.comment.jsonc

# completely override original context
comment-block:
- meta_include_prototype: false
- match: '/\*'
scope: punctuation.definition.comment.begin.jsonc
push:
- meta_scope: comment.block.jsonc
- meta_include_prototype: false
- meta_scope: comment.block.jsonc
- include: comment-block-end

# completely override original context
comment-block-end:
- meta_include_prototype: false
- match: '\*/'
scope: punctuation.definition.comment.end.jsonc
pop: 1
Expand Down
17 changes: 0 additions & 17 deletions JSON/Line Terminator.tmPreferences

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
[
1,
2,
3],
3
],
[
{"a": "a"},
{"b": "b"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
[
1,
2,
3],
3
],
[
{"a": "a"},
{"b": "b"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
[
1,
2,
3],
3
],
[
{"a": "a"},
{"b": "b"},
Expand Down
3 changes: 3 additions & 0 deletions JSON/tests/syntax/syntax_test_json5.meta.mapping.json5
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// ^^^^^^^^^^^^^^ meta.mapping.key
// ^^^^^^^^^^^^^^ - meta.mapping meta.mapping.key
// ^^^^^^^^^^^^^^ meta.toc-list
// ^^^^^^^^^^^^^^ meta.string string.unquoted.plain
// ^ meta.mapping punctuation.separator.mapping.key-value
// ^^^^ meta.mapping.value
// ^^^^ - meta.mapping meta.mapping.value
Expand All @@ -17,6 +18,7 @@
// ^^^^^^^^^^^^^^ meta.mapping.key
// ^^^^^^^^^^^^^^ - meta.mapping meta.mapping.key
// ^^^^^^^^^^^^^^ meta.toc-list
// ^^^^^^^^^^^^^^ meta.string string.unquoted.plain
// ^ meta.mapping punctuation.separator.mapping.key-value
// ^^^^ meta.mapping.value
// ^^^^ - meta.mapping meta.mapping.value
Expand All @@ -25,6 +27,7 @@
// ^^^^^^^^^ meta.mapping.key
// ^^^^^^^^^ - meta.mapping meta.mapping.key
// ^^^^^^^^^ meta.toc-list
// ^^^^^^^^^ meta.string string.unquoted.plain
// ^ meta.mapping punctuation.separator.mapping.key-value
// ^^^^ meta.mapping.value
// ^^^^ - meta.mapping meta.mapping.value
Expand Down

0 comments on commit d332980

Please sign in to comment.