forked from Shopify/liquid-tmbundle
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit vendors JSON.sublime-syntax from sublimehq/Packages#3876 to fix various highlighting issues caused by limitations of bundled JSON syntax shipped with current releases of ST.
- Loading branch information
Showing
4 changed files
with
298 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,204 @@ | ||
%YAML 1.2 | ||
--- | ||
name: JSON | ||
scope: source.json.vendored-for-liquid | ||
version: 2 | ||
hidden: true | ||
|
||
contexts: | ||
|
||
prototype: | ||
- include: comments | ||
|
||
main: | ||
- include: values | ||
|
||
values: | ||
- include: constants | ||
- include: floats | ||
- include: integers | ||
- include: strings | ||
- include: arrays | ||
- include: objects | ||
|
||
###[ COMMENTS ]################################################################ | ||
|
||
comments: | ||
- include: block-comments | ||
- include: line-comments | ||
|
||
block-comments: | ||
# empty block comments | ||
- match: /\*\*+/ | ||
scope: comment.block.empty.json punctuation.definition.comment.json | ||
# documentation block comments | ||
- match: /\*\*+ | ||
scope: punctuation.definition.comment.begin.json | ||
push: block-comment-documentation-body | ||
# normal block comments | ||
- match: /\* | ||
scope: punctuation.definition.comment.begin.json | ||
push: block-comment-body | ||
|
||
block-comment-documentation-body: | ||
- meta_include_prototype: false | ||
- meta_scope: comment.block.documentation.json | ||
- match: \*+/ | ||
scope: punctuation.definition.comment.end.json | ||
pop: 1 | ||
- match: ^\s*(\*)(?![*/]) | ||
captures: | ||
1: punctuation.definition.comment.json | ||
|
||
block-comment-body: | ||
- meta_include_prototype: false | ||
- meta_scope: comment.block.json | ||
- match: \*/ | ||
scope: punctuation.definition.comment.end.json | ||
pop: 1 | ||
- match: ^\s*(\*)(?![*/]) | ||
captures: | ||
1: punctuation.definition.comment.json | ||
|
||
line-comments: | ||
- match: // | ||
scope: punctuation.definition.comment.json | ||
push: line-comment-body | ||
|
||
line-comment-body: | ||
- meta_include_prototype: false | ||
- meta_scope: comment.line.double-slash.json | ||
- match: $\n? | ||
pop: 1 | ||
|
||
###[ ARRAYS ]################################################################## | ||
|
||
arrays: | ||
- match: \[ | ||
scope: punctuation.section.sequence.begin.json | ||
push: array-body | ||
|
||
array-body: | ||
- meta_scope: meta.sequence.json | ||
- match: \] | ||
scope: punctuation.section.sequence.end.json | ||
pop: 1 | ||
- match: ',' | ||
scope: punctuation.separator.sequence.json | ||
- include: values | ||
- match: \S | ||
scope: invalid.illegal.expected-sequence-separator.json | ||
|
||
###[ OBJECTS ]################################################################# | ||
|
||
objects: | ||
- match: \{ | ||
scope: punctuation.section.mapping.begin.json | ||
push: object-body | ||
|
||
object-body: | ||
- meta_scope: meta.mapping.json | ||
- match: \} | ||
scope: punctuation.section.mapping.end.json | ||
pop: 1 | ||
- match: \" | ||
scope: punctuation.definition.string.begin.json | ||
push: object-key-body | ||
- match: ':' | ||
scope: punctuation.separator.key-value.json | ||
push: expect-object-value | ||
- match: \S | ||
scope: invalid.illegal.expected-mapping-key.json | ||
|
||
object-key-body: | ||
- clear_scopes: 1 | ||
- meta_include_prototype: false | ||
- meta_scope: meta.mapping.key.json string.quoted.double.json | ||
- include: double-quoted-string-body | ||
|
||
expect-object-value: | ||
- meta_include_prototype: false | ||
- include: comments | ||
- match: ',|\s?(?=\})' | ||
scope: invalid.illegal.expected-mapping-value.json | ||
pop: 1 | ||
- match: (?=\S) | ||
set: object-value-body | ||
|
||
object-value-body: | ||
- clear_scopes: 1 | ||
- meta_scope: meta.mapping.value.json | ||
- include: values | ||
- match: '' | ||
set: object-value-end | ||
|
||
object-value-end: | ||
- meta_include_prototype: false | ||
- include: comments | ||
- match: (?=\s*\}) | ||
pop: 1 | ||
- match: ',' | ||
scope: punctuation.separator.sequence.json | ||
pop: 1 | ||
- match: \s(?!/[/*])(?=[^\s,])|[^\s,] | ||
scope: invalid.illegal.expected-mapping-separator.json | ||
pop: 1 | ||
|
||
###[ LITERALS ]################################################################ | ||
|
||
constants: | ||
- match: \b(?:false|true)\b | ||
scope: constant.language.boolean.json | ||
- match: \bnull\b | ||
scope: constant.language.null.json | ||
|
||
floats: | ||
- match: (-?)((?:0|[1-9]\d*)(?:(?:(\.)\d+)(?:[eE][-+]?\d+)?|(?:[eE][-+]?\d+))) | ||
scope: meta.number.float.decimal.json | ||
captures: | ||
1: keyword.operator.arithmetic.json | ||
2: constant.numeric.value.json | ||
3: punctuation.separator.decimal.json | ||
|
||
integers: | ||
- match: (-?)(0|[1-9]\d*) | ||
scope: meta.number.integer.decimal.json | ||
captures: | ||
1: keyword.operator.arithmetic.json | ||
2: constant.numeric.value.json | ||
|
||
strings: | ||
- match: \" | ||
scope: punctuation.definition.string.begin.json | ||
push: double-quoted-string-body | ||
|
||
double-quoted-string-body: | ||
- meta_include_prototype: false | ||
- meta_scope: meta.string.json string.quoted.double.json | ||
- match: \" | ||
scope: punctuation.definition.string.end.json | ||
pop: 1 | ||
- match: \n | ||
scope: invalid.illegal.unclosed-string.json | ||
pop: 1 | ||
- include: string-prototype | ||
- include: string-escapes | ||
|
||
# for use by inheriting syntaxes to easily inject string interpolation | ||
# in any kind of quoted or unquoted string | ||
string-prototype: [] | ||
|
||
string-escapes: | ||
- match: |- | ||
(?x: # turn on extended mode | ||
\\ # a literal backslash | ||
(?: # ...followed by... | ||
["\\/bfnrt] # one of these characters | ||
| # ...or... | ||
u # a u | ||
[0-9a-fA-F]{4} # and four hex digits | ||
) | ||
) | ||
scope: constant.character.escape.json | ||
- match: \\. | ||
scope: invalid.illegal.unrecognized-string-escape.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,60 @@ | ||
// SYNTAX TEST "Packages/Liquid/Syntaxes/JSON (Liquid).sublime-syntax" | ||
{ | ||
{{ key }}: {{ value }}, | ||
// ^ meta.mapping.json - meta.interpolation | ||
// ^^^^^^^^^ meta.mapping.json meta.interpolation.liquid | ||
// ^^ meta.mapping.json - meta.interpolation | ||
// ^^^^^^^^^^^ meta.mapping.json meta.interpolation.liquid | ||
// ^ meta.mapping.json - meta.interpolation | ||
// ^^ punctuation.section.interpolation.begin.liquid | ||
// ^^^^^ source.liquid | ||
// ^^ punctuation.section.interpolation.end.liquid | ||
// ^ punctuation.separator.key-value.json | ||
// ^^ punctuation.section.interpolation.begin.liquid | ||
// ^^^^^^^ source.liquid | ||
// ^^ punctuation.section.interpolation.end.liquid | ||
{ | ||
{{ key }}: {{ value }}, | ||
// ^ meta.mapping.json - meta.interpolation | ||
// ^^^^^^^^^ meta.mapping.json meta.interpolation.liquid | ||
// ^^ meta.mapping.json - meta.interpolation | ||
// ^^^^^^^^^^^ meta.mapping.value.json meta.interpolation.liquid | ||
// ^ meta.mapping.json - meta.interpolation | ||
// ^^ punctuation.section.interpolation.begin.liquid | ||
// ^^^^^ source.liquid | ||
// ^^ punctuation.section.interpolation.end.liquid | ||
// ^ punctuation.separator.key-value.json | ||
// ^^ punctuation.section.interpolation.begin.liquid | ||
// ^^^^^^^ source.liquid | ||
// ^^ punctuation.section.interpolation.end.liquid | ||
// ^ punctuation.separator.sequence.json | ||
|
||
"key": "String {{val}}!", | ||
// ^^^^^^^^ string.quoted.double.json | ||
// ^^^^^^^ meta.interpolation.liquid | ||
// ^^ string.quoted.double.json | ||
{%- if foo.bar -%} | ||
// ^ meta.mapping.json - meta.embedded - invalid | ||
// ^^^^^^^^^^^^^^^^^^ meta.mapping.json meta.embedded.liquid source.liquid meta.statement.liquid | ||
// ^^^ punctuation.section.embedded.begin.liquid | ||
// ^^^ punctuation.section.embedded.end.liquid | ||
// ^ meta.mapping.json - meta.embedded - invalid | ||
|
||
"key": [ {{item1}}, {{item2}} ], | ||
// ^^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping.value.json meta.sequence.json | ||
// ^ punctuation.section.sequence.begin.json | ||
// ^^^^^^^^^ meta.interpolation.liquid | ||
// ^ punctuation.separator.sequence.json | ||
// ^^^^^^^^^ meta.interpolation.liquid | ||
// ^ punctuation.section.sequence.end.json | ||
} | ||
"key": "String {{val}}!", | ||
// ^ meta.mapping.json - meta.mapping.key - invalid | ||
// ^^^^^ meta.mapping.key.json string.quoted.double.json | ||
// ^^ meta.mapping.json | ||
// ^^^^^^^^^^^^^^^^^ meta.mapping.value.json meta.string.json | ||
// ^^^^^^^^ string.quoted.double.json - meta.interpolation | ||
// ^^^^^^^ meta.interpolation.liquid - string | ||
// ^^ string.quoted.double.json - meta.interpolation | ||
// ^ punctuation.separator.sequence.json | ||
{% else %} | ||
// ^ meta.mapping.json - meta.embedded - invalid | ||
// ^^^^^^^^^^ meta.mapping.json meta.embedded.liquid source.liquid meta.statement.liquid | ||
// ^^ punctuation.section.embedded.begin.liquid | ||
// ^^ punctuation.section.embedded.end.liquid | ||
// ^ meta.mapping.json - meta.embedded - invalid | ||
|
||
"key": [ {{item1}}, {{item2}} ], | ||
// ^ meta.mapping.json - meta.mapping.key - invalid | ||
// ^^^^^ meta.mapping.key.json string.quoted.double.json | ||
// ^^ meta.mapping.json | ||
// ^^^^^^^^^^^^^^^^^^^^^^^^ meta.mapping.value.json meta.sequence.json | ||
// ^ punctuation.section.sequence.begin.json | ||
// ^^^^^^^^^ meta.interpolation.liquid | ||
// ^ punctuation.separator.sequence.json | ||
// ^^^^^^^^^ meta.interpolation.liquid | ||
// ^ punctuation.section.sequence.end.json | ||
// ^ punctuation.separator.sequence.json | ||
// ^ - invalid | ||
|
||
{% endif %} | ||
// ^ meta.mapping.json - meta.embedded - invalid | ||
// ^^^^^^^^^^^ meta.mapping.json meta.embedded.liquid source.liquid meta.statement.liquid | ||
// ^^ punctuation.section.embedded.begin.liquid | ||
// ^^ punctuation.section.embedded.end.liquid | ||
// ^ meta.mapping.json - meta.embedded - invalid | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters