tweak automatic selection of mode

This commit is contained in:
nightwing 2017-02-02 12:33:35 +04:00
parent 9879e5ce51
commit a0bf81ed8f
2 changed files with 18 additions and 2 deletions

View File

@ -60,8 +60,12 @@ var JsonHighlightRules = function() {
token : "invalid.illegal", // single quoted strings are not allowed
regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
}, {
token : "invalid.illegal", // comments are not allowed
token : "comment", // comments are not allowed, but who cares?
regex : "\\/\\/.*$"
}, {
token : "comment.start", // comments are not allowed, but who cares?
regex : "\\/\\*",
next : "comment"
}, {
token : "paren.lparen",
regex : "[[({]"
@ -89,6 +93,15 @@ var JsonHighlightRules = function() {
regex : "",
next : "start"
}
],
"comment" : [
{
token : "comment.end", // comments are not allowed, but who cares?
regex : "\\*\\/",
next : "start"
}, {
defaultToken: "comment"
}
]
};

View File

@ -1477,9 +1477,12 @@ define(function(require, exports, module) {
else if (/<\?xml/.test(firstLine)) {
syntax = "xml";
}
else if (/^{/.test(firstLine)) {
else if (/^{\s*("|$)/.test(firstLine)) {
syntax = "json";
}
else if (/^---$/.test(firstLine)) {
syntax = "yaml";
}
else if (/\.(bash|inputrc|profile|zsh)/.test(path)) {
syntax = "sh";
}