(This is json default synatx)
i copy a json .sublime-syntax from github. but i found it cant folder/unfolder the code block.
how to fix it?
git repo:
JSON syntax file for Sublime Text
(This is json default synatx)
i copy a json .sublime-syntax from github. but i found it cant folder/unfolder the code block.
how to fix it?
git repo:
JSON syntax file for Sublime Text
The linked JSON syntax is a rather dated revision of ST’s default syntax, which isn’t optimized to be used in template languages, thus likely causing trouble.
Why wouldn’t you want to use ST’s current default JSON syntax?
also, syntax aware code folding relies on tmPreferences
files as well as the sublime-syntax
. Not sure if the community docs are up to date here though…
https://docs.sublimetext.io/reference/metadata.html#file-format
thanks for your reply.
as ST’s default JSON syntax can not highlight key/value,because i have a huge data to review at my works.
(this is use git repo syntax, it’s looks nice.)
This is not an issue of default JSON syntax, but color schemes, which don’t provide proper rules to highlight them.
All syntaxes have been tweaked to use same scopes for dictionaries and lists.
JSON and especially YAML support different data types or even expressions to be “keys”. Thus former entity.name.key
was not sufficient to satisfy all those use cases.
To fix your color scheme add a rule like…
{
"name": "Mapping Key Names",
"scope": "meta.mapping.key string",
"foreground": "var(my-desired-key-color)"
}
see also:
Rainbow like key highlighting can be defined by rules like…
{
"name": "Dictionary: 1st level",
"scope": "meta.mapping.key string",
"foreground": "var(blue)",
},
{
"name": "Dictionary: 2nd level",
"scope": "meta.mapping.value meta.mapping.key string",
"foreground": "var(violet)",
},
{
"name": "Dictionary: 3rd level",
"scope": "meta.mapping.value meta.mapping.value meta.mapping.key string",
"foreground": "var(purple)",
},
{
"name": "Dictionary: 4th level",
"scope": "meta.mapping.value meta.mapping.value meta.mapping.value meta.mapping.key string",
"foreground": "var(green)",
},
{
"name": "Dictionary: 5th level",
"scope": "meta.mapping.value meta.mapping.value meta.mapping.value meta.mapping.value meta.mapping.key string",
"foreground": "var(pink)",
},