Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Showing with 27 additions and 13 deletions.
  1. +7 −1 json-test.json
  2. +20 −12 syntax/json.vim
View
8 json-test.json
@@ -3,9 +3,15 @@
{
unquotedKeyword:'singleQuotedString',
'singleQuotedKeyword':true,
- "decimalCantStartWithPeriod":.1,
+ "decimalCantStartWithPeriod":.1
+ "semicolonAtEndOfThisObject":"trailingComma",
};
+{
+ "object1": "missingComma"
+ "object2": "value"
+}
+
// normative JSON examples from http://json.org/example.html
{"menu": {
View
32 syntax/json.vim
@@ -18,22 +18,24 @@ syntax match jsonNoise /\%(:\|,\)/
" NOTE that for the concealing to work your conceallevel should be set to 2
" Syntax: Strings
+" Separated into a match and region because a region by itself is always greedy
+syn match jsonStringMatch /"[^\"]\+"\ze[[:blank:]\r\n]*[,}\]]/ contains=jsonString
if has('conceal')
- syn region jsonString oneline matchgroup=jsonQuote start=/"/ skip=/\\\\\|\\"/ end=/"/ concealends contains=jsonEscape
+ syn region jsonString oneline matchgroup=jsonQuote start=/"/ skip=/\\\\\|\\"/ end=/"/ concealends contains=jsonEscape contained
else
- syn region jsonString oneline matchgroup=jsonQuote start=/"/ skip=/\\\\\|\\"/ end=/"/ contains=jsonEscape
+ syn region jsonString oneline matchgroup=jsonQuote start=/"/ skip=/\\\\\|\\"/ end=/"/ contains=jsonEscape contained
endif
" Syntax: JSON does not allow strings with single quotes, unlike JavaScript.
-syn region jsonStringSQ oneline start=+'+ skip=+\\\\\|\\"+ end=+'+
+syn region jsonStringSQError oneline start=+'+ skip=+\\\\\|\\"+ end=+'+
" Syntax: JSON Keywords
" Separated into a match and region because a region by itself is always greedy
-syn match jsonKeywordMatch /"[^\"\:]\+"[[:blank:]\r\n]*\:/ contains=jsonKeywordRegion
+syn match jsonKeywordMatch /"[^\"\:]\+"[[:blank:]\r\n]*\:/ contains=jsonKeyword
if has('conceal')
- syn region jsonKeywordRegion matchgroup=jsonQuote start=/"/ end=/"\ze[[:blank:]\r\n]*\:/ concealends contained
+ syn region jsonKeyword matchgroup=jsonQuote start=/"/ end=/"\ze[[:blank:]\r\n]*\:/ concealends contained
else
- syn region jsonKeywordRegion matchgroup=jsonQuote start=/"/ end=/"\ze[[:blank:]\r\n]*\:/ contained
+ syn region jsonKeyword matchgroup=jsonQuote start=/"/ end=/"\ze[[:blank:]\r\n]*\:/ contained
endif
" Syntax: Escape sequences
@@ -46,7 +48,7 @@ syn match jsonNumber "-\=\<\%(0\|[1-9]\d*\)\%(\.\d\+\)\=\%([eE][-+]\=\d\+\)
" ERROR WARNINGS **********************************************
"
" Syntax: Strings should always be enclosed with quotes.
-syn match jsonNoQuotes "\<[[:alpha:]]\+\>"
+syn match jsonNoQuotesError "\<[[:alpha:]]\+\>"
" Syntax: An integer part of 0 followed by other digits is not allowed.
syn match jsonNumError "-\=\<0\d\.\d*\>"
@@ -62,7 +64,11 @@ syn match jsonCommentError "\(/\*\)\|\(\*/\)"
syn match jsonSemicolonError ";"
" Syntax: No trailing comma after the last element of arrays or objects
-syn match jsonCommaError ",\_s*[}\]]"
+syn match jsonTrailingCommaError ",\_s*[}\]]"
+
+" Syntax: Watch out for missing commas between elements
+syn match jsonMissingCommaError /"\zs\_s\+\ze"/
+
" ********************************************** END OF ERROR WARNINGS
" Allowances for JSONP: function call at the beginning of the file,
@@ -95,6 +101,7 @@ if version >= 508 || !exists("did_json_syn_inits")
endif
HiLink jsonPadding Operator
HiLink jsonString String
+ HiLink jsonTest Label
HiLink jsonEscape Special
HiLink jsonNumber Number
HiLink jsonBraces Delimiter
@@ -102,14 +109,15 @@ if version >= 508 || !exists("did_json_syn_inits")
HiLink jsonBooleanTrue jsonBoolean
HiLink jsonBooleanFalse jsonBoolean
HiLink jsonBoolean Boolean
- HiLink jsonKeywordRegion Label
+ HiLink jsonKeyword Label
HiLink jsonNumError Error
HiLink jsonCommentError Error
HiLink jsonSemicolonError Error
- HiLink jsonCommaError Error
- HiLink jsonStringSQ Error
- HiLink jsonNoQuotes Error
+ HiLink jsonTrailingCommaError Error
+ HiLink jsonMissingCommaError Error
+ HiLink jsonStringSQError Error
+ HiLink jsonNoQuotesError Error
HiLink jsonQuote Quote
HiLink jsonNoise Noise
delcommand HiLink

No commit comments for this range

Something went wrong with that request. Please try again.