diff --git a/JSON/Comments.tmPreferences b/JSON/Comments.tmPreferences new file mode 100644 index 00000000000..dd46f14e7ac --- /dev/null +++ b/JSON/Comments.tmPreferences @@ -0,0 +1,33 @@ + + + + name + Comments + scope + source.json + settings + + shellVariables + + + name + TM_COMMENT_START + value + // + + + name + TM_COMMENT_START_2 + value + /* + + + name + TM_COMMENT_END_2 + value + */ + + + + + diff --git a/JSON/Indentation Rules.tmPreferences b/JSON/Indentation Rules.tmPreferences new file mode 100644 index 00000000000..8944a9e8379 --- /dev/null +++ b/JSON/Indentation Rules.tmPreferences @@ -0,0 +1,67 @@ + + + + name + JavaScript Indent + scope + source.json + settings + + decreaseIndentPattern + (?x) + # When an object is closed, but not opened + ( + ^ + ( + # Consume strings + "(?:[^"\\]|\\.)*" + | + # Consume all chars that don't start a string, comment or + # open an object on this line + [^"/{\n] + )* + \}.*$ + ) + | + # When an array is closed by itself on a line (interacts with indentSquareBrackets) + ( + ^(.*\*/)?\s*\].*$ + ) + + increaseIndentPattern + (?x) + # When an object is opened, but not closed + ( + ^.*\{ + ( + # Consume strings + "(?:[^"\\]|\\.)*" + | + # Consume all chars that don't start a string, comment or + # end the object that was opened on this line + [^"/}] + )* + # Stop matching at the end of the line, or once we hit a comment + ($|/[/*]) + ) + | + # When an array is opened, but not closed + ( + ^.*\[ + ( + # Consume strings + "(?:[^"\\]|\\.)*" + | + # Consume all chars that don't start a string, comment or + # end the array that was opened on this line + [^"/\]] + )* + # Stop matching at the end of the line, or once we hit a comment + ($|/[/*]) + ) + + indentSquareBrackets + + + + diff --git a/JSON/syntax_test_json.json b/JSON/syntax_test_json.json index 4a6c940e090..60a3e645e7e 100644 --- a/JSON/syntax_test_json.json +++ b/JSON/syntax_test_json.json @@ -1,4 +1,4 @@ -// SYNTAX TEST "Packages/JavaScript/JSON.sublime-syntax" +// SYNTAX TEST "Packages/JSON/JSON.sublime-syntax" { // <- meta.mapping.json punctuation.section.mapping.begin.json diff --git a/JavaScript/Comments.tmPreferences b/JavaScript/Comments.tmPreferences index f16fa66e313..d24c0f708c2 100644 --- a/JavaScript/Comments.tmPreferences +++ b/JavaScript/Comments.tmPreferences @@ -4,7 +4,7 @@ name Comments scope - source.js, source.json + source.js settings shellVariables