├── .editorconfig
├── .gitignore
├── .vscodeignore
├── LICENSE
├── README.md
├── icon.png
├── json5.configuration.json
├── package.json
├── syntaxes
└── json5.json
└── test
├── package.json5
└── repository-syntax.json5
/.editorconfig:
--------------------------------------------------------------------------------
1 | # editorconfig.org
2 | root = true
3 |
4 | [*]
5 | indent_style = tab
6 | indent_size = 4
7 | end_of_line = lf
8 | charset = utf-8
9 | trim_trailing_whitespace = true
10 | insert_final_newline = true
11 |
12 | # The indent size used in the `package.json` file cannot be changed
13 | # https://github.com/npm/npm/pull/3180#issuecomment-16336516
14 | [{.travis.yml,npm-shrinkwrap.json,package.json}]
15 | indent_style = space
16 | indent_size = 2
17 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs/
3 | *.log
4 | npm-debug.log*
5 |
6 | # IDE & editors
7 | .idea
8 | .vscode
9 |
10 | # Dependency directory
11 | node_modules/
12 |
13 | # Compiled and tempory files
14 | .tmp/
15 | out/
16 |
--------------------------------------------------------------------------------
/.vscodeignore:
--------------------------------------------------------------------------------
1 | .vscode/**
2 | typings/**
3 | test/**
4 | lib/**/*.spec.js
5 | .editorconfig
6 | .gitignore
7 | .travis.yml
8 | jsconfig.json
9 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) Denis Malinochkin
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # vscode-json5
2 |
3 | > This extension adds syntax highlighting of JSON5 files in VS Code.
4 |
5 | ## Colorization
6 |
7 | 
8 |
9 | (imported from [Atom package](https://github.com/wiredmax/language-json5))
10 |
11 | ## Usage
12 |
13 | ### Install the extension in VS Code
14 |
15 | * Open the command palette using Ctrl+P.
16 | * Type `ext install json5` in the command palette.
17 |
18 | ### Select **JSON5** as a language
19 |
20 | * On the bottom-right corner, click on the select language mode button, if you have created a new file it should display Plain Text.
21 | * Select **JSON5** in the list of languages.
22 | * Alternatively, saving the file with a `.json5` extension, will allow VS Code to understand that it is a JSON5 file, and automatically select the language correctly.
23 |
24 | ### Supported features
25 |
26 | * Syntax highlight
27 |
28 | ### Supported filetypes
29 |
30 | * `.json5`
31 |
32 | ## Contributing
33 |
34 | > These simple rules will help me to solve your problem.
35 |
36 | * Check the **Issues** and **Pull requests** sections for duplicates of your question or path.
37 | * Please, use GitHub emotions.
38 | * If you want create **Issue**:
39 | * Specify the version of your editor and used theme.
40 | * Detailed description of your problem:
41 | * Description
42 | * Code sample
43 | * Screenshot
44 | * If you want create **Pull request**:
45 | * Fork this repository and clone it to your machine.
46 | * Open folder contains this extension in VS Code.
47 | * Press F5.
48 | * Make your changes and send a PR.
49 |
50 | ## Changelog
51 |
52 | See the [Releases section of our GitHub project](https://github.com/mrmlnc/vscode-json5/releases) for changelogs for each release version.
53 |
54 | ## License
55 |
56 | This software is released under the terms of the MIT license.
57 |
--------------------------------------------------------------------------------
/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mrmlnc/vscode-json5/e884b89929103ff009322c393080ff45a4544e88/icon.png
--------------------------------------------------------------------------------
/json5.configuration.json:
--------------------------------------------------------------------------------
1 | {
2 | "comments": {
3 | "lineComment": "//",
4 | "blockComment": [ "/*", "*/" ]
5 | },
6 | "brackets": [
7 | ["{", "}"],
8 | ["[", "]"]
9 | ],
10 | "autoClosingPairs": [
11 | { "open": "{", "close": "}", "notIn": ["string"] },
12 | { "open": "[", "close": "]", "notIn": ["string"] },
13 | { "open": "(", "close": ")", "notIn": ["string"] },
14 | { "open": "'", "close": "'", "notIn": ["string"] },
15 | { "open": "\"", "close": "\"", "notIn": ["string", "comment"] },
16 | { "open": "`", "close": "`", "notIn": ["string", "comment"] }
17 | ]
18 | }
19 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "vscode-json5",
3 | "displayName": "JSON5 syntax",
4 | "description": "Adds syntax highlighting of JSON5 files",
5 | "version": "1.0.0",
6 | "publisher": "mrmlnc",
7 | "license": "MIT",
8 | "engines": {
9 | "vscode": "^1.3.0"
10 | },
11 | "icon": "icon.png",
12 | "homepage": "https://github.com/mrmlnc/vscode-json5/blob/master/README.md",
13 | "repository": {
14 | "type": "git",
15 | "url": "https://github.com/mrmlnc/vscode-json5"
16 | },
17 | "keywords": [
18 | "json5",
19 | "syntax",
20 | "highlight"
21 | ],
22 | "categories": [
23 | "Languages"
24 | ],
25 | "contributes": {
26 | "languages": [{
27 | "id": "json5",
28 | "aliases": ["JSON5", "json5"],
29 | "extensions": [".json5"],
30 | "configuration": "./json5.configuration.json"
31 | }],
32 | "grammars": [{
33 | "language": "json5",
34 | "scopeName": "source.json5",
35 | "path": "./syntaxes/json5.json"
36 | }]
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/syntaxes/json5.json:
--------------------------------------------------------------------------------
1 | {
2 | "scopeName": "source.json5",
3 | "fileTypes": ["json5"],
4 | "name": "JSON5",
5 | "patterns": [
6 | { "include": "#comments" },
7 | { "include": "#value" }
8 | ],
9 | "repository": {
10 | "array": {
11 | "begin": "\\[",
12 | "beginCaptures": {
13 | "0": { "name": "punctuation.definition.array.begin.json5" }
14 | },
15 | "end": "\\]",
16 | "endCaptures": {
17 | "0": { "name": "punctuation.definition.array.end.json5" }
18 | },
19 | "name": "meta.structure.array.json5",
20 | "patterns": [
21 | { "include": "#comments" },
22 | { "include": "#value" },
23 | {
24 | "match": ",",
25 | "name": "punctuation.separator.array.json5"
26 | },
27 | {
28 | "match": "[^\\s\\]]",
29 | "name": "invalid.illegal.expected-array-separator.json5"
30 | }
31 | ]
32 | },
33 | "constant": {
34 | "match": "\\b(?:true|false|null|Infinity|NaN)\\b",
35 | "name": "constant.language.json5"
36 | },
37 | "infinity": {
38 | "match": "(-)*\\b(?:Infinity|NaN)\\b",
39 | "name": "constant.language.json5"
40 | },
41 | "number": {
42 | "patterns": [
43 | {
44 | "comment": "handles hexadecimal numbers",
45 | "match": "(0x)[0-9a-fA-f]*",
46 | "name": "constant.hex.numeric.json5"
47 | },
48 | {
49 | "comment": "handles integer and decimal numbers",
50 | "match": "[+-.]?(?=[1-9]|0(?!\\d))\\d+(\\.\\d+)?([eE][+-]?\\d+)?",
51 | "name": "constant.dec.numeric.json5"
52 | }
53 | ]
54 | },
55 | "object": {
56 | "begin": "\\{",
57 | "beginCaptures": {
58 | "0": { "name": "punctuation.definition.dictionary.begin.json5" }
59 | },
60 | "comment": "a json5 object",
61 | "end": "\\}",
62 | "endCaptures": {
63 | "0": { "name": "punctuation.definition.dictionary.end.json5" }
64 | },
65 | "name": "meta.structure.dictionary.json5",
66 | "patterns": [
67 | { "include": "#comments" },
68 | {
69 | "comment": "the json5 object key",
70 | "include": "#key"
71 | },
72 | {
73 | "begin": ":",
74 | "beginCaptures": {
75 | "0": { "name": "punctuation.separator.dictionary.key-value.json5" }
76 | },
77 | "end": "(,)|(?=\\})",
78 | "endCaptures": {
79 | "1": { "name": "punctuation.separator.dictionary.pair.json5" }
80 | },
81 | "name": "meta.structure.dictionary.value.json5",
82 | "patterns": [
83 | {
84 | "comment": "the json5 object value",
85 | "include": "#value"
86 | },
87 | {
88 | "match": "[^\\s,]",
89 | "name": "invalid.illegal.expected-dictionary-separator.json5"
90 | }
91 | ]
92 | },
93 | {
94 | "match": "[^\\s\\}]",
95 | "name": "invalid.illegal.expected-dictionary-separator.json5"
96 | }
97 | ]
98 | },
99 | "stringSingle": {
100 | "begin": "[']",
101 | "beginCaptures": {
102 | "0": { "name": "punctuation.definition.string.begin.json5" }
103 | },
104 | "end": "[']",
105 | "endCaptures": {
106 | "0": { "name": "punctuation.definition.string.end.json5" }
107 | },
108 | "name": "string.quoted.json5",
109 | "patterns": [
110 | {
111 | "match": "(?x: # turn on extended mode\n \\\\ # a literal backslash\n (?: # ...followed by...\n [\"\\\\/bfnrt] # one of these characters\n | # ...or...\n u # a u\n [0-9a-fA-F]{4} # and four hex digits\n )\n )",
112 | "name": "constant.character.escape.json5"
113 | },
114 | {
115 | "match": "\\\\.",
116 | "name": "invalid.illegal.unrecognized-string-escape.json5"
117 | }
118 | ]
119 | },
120 | "stringDouble": {
121 | "begin": "[\"]",
122 | "beginCaptures": {
123 | "0": { "name": "punctuation.definition.string.begin.json5" }
124 | },
125 | "end": "[\"]",
126 | "endCaptures": {
127 | "0": { "name": "punctuation.definition.string.end.json5" }
128 | },
129 | "name": "string.quoted.json5",
130 | "patterns": [
131 | {
132 | "match": "(?x: # turn on extended mode\n \\\\ # a literal backslash\n (?: # ...followed by...\n [\"\\\\/bfnrt] # one of these characters\n | # ...or...\n u # a u\n [0-9a-fA-F]{4} # and four hex digits\n )\n )",
133 | "name": "constant.character.escape.json5"
134 | },
135 | {
136 | "match": "\\\\.",
137 | "name": "invalid.illegal.unrecognized-string-escape.json5"
138 | }
139 | ]
140 | },
141 | "key": {
142 | "name": "string.key.json5",
143 | "patterns": [
144 | { "include": "#stringSingle" },
145 | { "include": "#stringDouble" },
146 | {
147 | "match": "[a-zA-Z0-9_-]",
148 | "name": "string.key.json5"
149 | }
150 | ]
151 | },
152 | "value": {
153 | "comment": "the 'value' diagram at http://json.org",
154 | "patterns": [
155 | { "include": "#constant" },
156 | { "include": "#infinity" },
157 | { "include": "#number" },
158 | { "include": "#stringSingle" },
159 | { "include": "#stringDouble" },
160 | { "include": "#array" },
161 | { "include": "#object" }
162 | ]
163 | },
164 | "comments": {
165 | "patterns": [
166 | {
167 | "match": "/{2}.*",
168 | "name": "comment.single.json5"
169 | },
170 | {
171 | "begin": "/\\*\\*(?!/)",
172 | "captures": {
173 | "0": { "name": "punctuation.definition.comment.json5" }
174 | },
175 | "end": "\\*/",
176 | "name": "comment.block.documentation.json5"
177 | },
178 | {
179 | "begin": "/\\*",
180 | "captures": {
181 | "0": { "name": "punctuation.definition.comment.json5" }
182 | },
183 | "end": "\\*/",
184 | "name": "comment.block.json5"
185 | }
186 | ]
187 | }
188 | }
189 | }
190 |
--------------------------------------------------------------------------------
/test/package.json5:
--------------------------------------------------------------------------------
1 | // This file is written in JSON5 syntax, naturally, but npm needs a regular
2 | // JSON file, so compile via `npm run build`. Be sure to keep both in sync!
3 |
4 | {
5 | name: 'json5',
6 | version: '0.5.0',
7 | description: 'JSON for the ES5 era.',
8 | keywords: ['json', 'es5'],
9 | author: 'Aseem Kishore ',
10 | contributors: [
11 | // TODO: Should we remove this section in favor of GitHub's list?
12 | // https://github.com/aseemk/json5/contributors
13 | 'Max Nanasy ',
14 | 'Andrew Eisenberg ',
15 | 'Jordan Tucker ',
16 | ],
17 | main: 'lib/json5.js',
18 | bin: 'lib/cli.js',
19 | files: ["lib/"],
20 | dependencies: {},
21 | devDependencies: {
22 | gulp: "^3.9.1",
23 | 'gulp-jshint': "^2.0.0",
24 | jshint: "^2.9.1",
25 | 'jshint-stylish': "^2.1.0",
26 | mocha: "^2.4.5"
27 | },
28 | scripts: {
29 | build: 'node ./lib/cli.js -c package.json5',
30 | test: 'mocha --ui exports --reporter spec',
31 | // TODO: Would it be better to define these in a mocha.opts file?
32 | },
33 | homepage: 'http://json5.org/',
34 | license: 'MIT',
35 | repository: {
36 | type: 'git',
37 | url: 'https://github.com/aseemk/json5.git',
38 | },
39 | }
40 |
--------------------------------------------------------------------------------
/test/repository-syntax.json5:
--------------------------------------------------------------------------------
1 | {
2 | foo: 'bar',
3 | while: true,
4 |
5 | this: 'is a \
6 | multi-line string',
7 |
8 | // this is an inline comment
9 | here: 'is another', // inline comment
10 |
11 | /* this is a block comment
12 | that continues on another line */
13 |
14 | hex: 0xDEADbeef,
15 | half: .5,
16 | delta: +10,
17 | to: Infinity, // and beyond!
18 |
19 | finally: 'a trailing comma',
20 | oh: [
21 | "we shouldn't forget",
22 | 'arrays can have',
23 | 'trailing commas too',
24 | ],
25 | }
26 |
--------------------------------------------------------------------------------