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

[JSON] Rewrite syntax #3097

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions HTML/syntax_test_html.html
Original file line number Diff line number Diff line change
Expand Up @@ -127,23 +127,23 @@

<script type=application/json>
{
## ^ source.json.embedded.html meta.mapping.json punctuation.section.mapping.begin.json
## ^ source.json.embedded.html meta.mapping.json punctuation.definition.mapping.begin.json
"key": "value",
## ^^^^^ source.json.embedded.html meta.mapping.key.json
## ^^^^^^^ source.json.embedded.html meta.mapping.value.json
}
## ^ source.json.embedded.html meta.mapping.json punctuation.section.mapping.end.json
## ^ source.json.embedded.html meta.mapping.json punctuation.definition.mapping.end.json
</script>

<script type="whatever+json">
<![CDATA[
{
## ^ meta.tag.sgml.cdata.html source.json.embedded.html meta.mapping.json punctuation.section.mapping.begin.json
## ^ meta.tag.sgml.cdata.html source.json.embedded.html meta.mapping.json punctuation.definition.mapping.begin.json
"key": "value",
## ^^^^^ meta.tag.sgml.cdata.html source.json.embedded.html meta.mapping.key.json
## ^^^^^^^ meta.tag.sgml.cdata.html source.json.embedded.html meta.mapping.value.json
}
## ^ meta.tag.sgml.cdata.html source.json.embedded.html meta.mapping.json punctuation.section.mapping.end.json
## ^ meta.tag.sgml.cdata.html source.json.embedded.html meta.mapping.json punctuation.definition.mapping.end.json
]]>
</script>

Expand Down
1 change: 1 addition & 0 deletions JSON/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.8
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.

29 changes: 29 additions & 0 deletions JSON/Context.sublime-menu
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Packages/JSON/Context.sublime-menu


// This file is being maintained at:
// https://github.com/sublimehq/Packages/blob/master/JSON/Context.sublime-menu


[
// visible only with JSON syntax highlighting
{
"caption": "JSON: Minify",
"command": "json_minify"
},
{
"caption": "JSON: Prettify",
"command": "json_prettify"
},


// visible only with JSONC syntax highlighting
{
"caption": "JSONC: Minify",
"command": "jsonc_minify"
},
{
"caption": "JSONC: Prettify",
"command": "jsonc_prettify"
}
]
29 changes: 29 additions & 0 deletions JSON/Default.sublime-commands
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Packages/JSON/Default.sublime-commands


// This file is being maintained at:
// https://github.com/sublimehq/Packages/blob/master/JSON/Default.sublime-commands


[
// visible only with JSON syntax highlighting
{
"caption": "JSON: Minify JSON",
"command": "json_minify"
},
{
"caption": "JSON: Prettify JSON",
"command": "json_prettify"
},


// visible only with JSONC syntax highlighting
{
"caption": "JSONC: Minify JSONC",
"command": "jsonc_minify"
},
{
"caption": "JSONC: Prettify JSONC",
"command": "jsonc_prettify"
}
]
131 changes: 69 additions & 62 deletions JSON/Default.sublime-keymap
Original file line number Diff line number Diff line change
@@ -1,63 +1,70 @@
// Packages/JSON/Default.sublime-keymap


// This file is being maintained at:
// https://github.com/sublimehq/Packages/blob/master/JSON/Default.sublime-keymap


[
// Auto-pair quotations: "key": '|',
{ "keys": ["'"], "command": "insert_snippet", "args": {"contents": "'$0'"}, "context":
[
{ "key": "setting.auto_match_enabled" },
{ "key": "selector", "operand": "source.json" },
{ "key": "selection_empty", "match_all": true },
{ "key": "preceding_text", "operator": "not_regex_contains", "operand": "['\\w]$", "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^(?:\t| |]|,|:|\\}|$)", "match_all": true }
]
},

// Auto-pair quotations: "key": "|",
{ "keys": ["\""], "command": "insert_snippet", "args": {"contents": "\"$0\""}, "context":
[
{ "key": "setting.auto_match_enabled" },
{ "key": "selector", "operand": "source.json" },
{ "key": "selection_empty", "match_all": true },
{ "key": "preceding_text", "operator": "not_regex_contains", "operand": "[\"\\w]$", "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^(?:\t| |]|,|:|\\}|$)", "match_all": true }
]
},

// Auto-pair braces: "key": {|},
{ "keys": ["{"], "command": "insert_snippet", "args": {"contents": "{$0}"}, "context":
[
{ "key": "setting.auto_match_enabled" },
{ "key": "selector", "operand": "source.json" },
{ "key": "selection_empty", "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^(?:\t| |]|,|:|\\}|$)", "match_all": true }
]
},

// Auto-pair square brackets: "key": [|],
{ "keys": ["["], "command": "insert_snippet", "args": {"contents": "[$0]"}, "context":
[
{ "key": "setting.auto_match_enabled" },
{ "key": "selector", "operand": "source.json" },
{ "key": "selection_empty", "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^(?:\t| |]|,|:|\\}|$)", "match_all": true }
]
},

// Add indented line in square brackets
{ "keys": ["enter"], "command": "insert_snippet", "args": {"contents": "\n\t$0\n"}, "context":
[
{ "key": "setting.auto_indent" },
{ "key": "selector", "operand": "source.json" },
{ "key": "selection_empty", "match_all": true },
{ "key": "preceding_text", "operator": "regex_contains", "operand": "\\[$", "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^\\]", "match_all": true }
]
},
{ "keys": ["shift+enter"], "command": "insert_snippet", "args": {"contents": "\n\t$0\n"}, "context":
[
{ "key": "setting.auto_indent" },
{ "key": "selector", "operand": "source.json" },
{ "key": "selection_empty", "match_all": true },
{ "key": "preceding_text", "operator": "regex_contains", "operand": "\\[$", "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^\\]", "match_all": true }
]
},
]
// Auto-pair quotations: "key": '|',
{ "keys": ["'"], "command": "insert_snippet", "args": {"contents": "'$0'"}, "context":
[
{ "key": "setting.auto_match_enabled" },
{ "key": "selector", "operand": "source.json" },
{ "key": "selection_empty", "match_all": true },
{ "key": "preceding_text", "operator": "not_regex_contains", "operand": "['\\w]$", "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^(?:\t| |]|,|:|\\}|$)", "match_all": true }
]
},

// Auto-pair quotations: "key": "|",
{ "keys": ["\""], "command": "insert_snippet", "args": {"contents": "\"$0\""}, "context":
[
{ "key": "setting.auto_match_enabled" },
{ "key": "selector", "operand": "source.json" },
{ "key": "selection_empty", "match_all": true },
{ "key": "preceding_text", "operator": "not_regex_contains", "operand": "[\"\\w]$", "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^(?:\t| |]|,|:|\\}|$)", "match_all": true }
]
},

// Auto-pair braces: "key": {|},
{ "keys": ["{"], "command": "insert_snippet", "args": {"contents": "{$0}"}, "context":
[
{ "key": "setting.auto_match_enabled" },
{ "key": "selector", "operand": "source.json" },
{ "key": "selection_empty", "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^(?:\t| |]|,|:|\\}|$)", "match_all": true }
]
},

// Auto-pair square brackets: "key": [|],
{ "keys": ["["], "command": "insert_snippet", "args": {"contents": "[$0]"}, "context":
[
{ "key": "setting.auto_match_enabled" },
{ "key": "selector", "operand": "source.json" },
{ "key": "selection_empty", "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^(?:\t| |]|,|:|\\}|$)", "match_all": true }
]
},

// Add indented line in square brackets
{ "keys": ["enter"], "command": "insert_snippet", "args": {"contents": "\n\t$0\n"}, "context":
[
{ "key": "setting.auto_indent" },
{ "key": "selector", "operand": "source.json" },
{ "key": "selection_empty", "match_all": true },
{ "key": "preceding_text", "operator": "regex_contains", "operand": "\\[$", "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^\\]", "match_all": true }
]
},
{ "keys": ["shift+enter"], "command": "insert_snippet", "args": {"contents": "\n\t$0\n"}, "context":
[
{ "key": "setting.auto_indent" },
{ "key": "selector", "operand": "source.json" },
{ "key": "selection_empty", "match_all": true },
{ "key": "preceding_text", "operator": "regex_contains", "operand": "\\[$", "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^\\]", "match_all": true }
]
},
]
27 changes: 0 additions & 27 deletions JSON/Fold.tmPreferences

This file was deleted.

27 changes: 27 additions & 0 deletions JSON/Folding Rules - JSON.tmPreferences
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
<key>scope</key>
<string>source.json - (source.json.json-dotnet | source.json.json5 | source.json.jsonc)</string>
<key>settings</key>
<dict>
<key>indentationFoldingEnabled</key>
<false/>
<key>foldScopes</key>
<array>
<dict>
<key>begin</key>
<string>punctuation.definition.mapping.begin</string>
<key>end</key>
<string>punctuation.definition.mapping.end</string>
</dict>
<dict>
<key>begin</key>
<string>punctuation.definition.sequence.begin</string>
<key>end</key>
<string>punctuation.definition.sequence.end</string>
</dict>
</array>
</dict>
</dict>
</plist>
31 changes: 31 additions & 0 deletions JSON/Folding Rules - JSON5.tmPreferences
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?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>foldScopes</key>
<array>
<dict>
<key>begin</key>
<string>punctuation.definition.comment.begin</string>
<key>end</key>
<string>punctuation.definition.comment.end</string>
</dict>
<dict>
<key>begin</key>
<string>punctuation.definition.mapping.begin</string>
<key>end</key>
<string>punctuation.definition.mapping.end</string>
</dict>
<dict>
<key>begin</key>
<string>punctuation.definition.sequence.begin</string>
<key>end</key>
<string>punctuation.definition.sequence.end</string>
</dict>
</array>
</dict>
</dict>
</plist>
Loading