changeset 517:14b645f67f7c

Update vim-syntax.
author edogawaconan <me@myconan.net>
date Thu, 22 May 2014 15:22:53 +0900
parents 6ef4bbc171eb
children 5b06950f7d45
files vendor/vim-syntax/json.vim
diffstat 1 files changed, 43 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/vendor/vim-syntax/json.vim	Thu May 22 15:22:00 2014 +0900
+++ b/vendor/vim-syntax/json.vim	Thu May 22 15:22:53 2014 +0900
@@ -18,22 +18,24 @@
 " 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
@@ -41,28 +43,32 @@
 syn match   jsonEscape    "\\u\x\{4}" contained
 
 " Syntax: Numbers
-syn match   jsonNumber    "-\=\<\%(0\|[1-9]\d*\)\%(\.\d\+\)\=\%([eE][-+]\=\d\+\)\=\>"
+syn match   jsonNumber    "-\=\<\%(0\|[1-9]\d*\)\%(\.\d\+\)\=\%([eE][-+]\=\d\+\)\=\>\ze[[:blank:]\r\n]*[,}\]]"
 
 " ERROR WARNINGS **********************************************
-"
-" Syntax: Strings should always be enclosed with quotes.
-syn match   jsonNoQuotes  "\<[[:alpha:]]\+\>"
+if (g:vim_json_warnings == 1)
+	" Syntax: Strings should always be enclosed with quotes.
+	syn match   jsonNoQuotesError  "\<[[:alpha:]]\+\>"
 
-" Syntax: An integer part of 0 followed by other digits is not allowed.
-syn match   jsonNumError  "-\=\<0\d\.\d*\>"
+	" Syntax: An integer part of 0 followed by other digits is not allowed.
+	syn match   jsonNumError  "-\=\<0\d\.\d*\>"
 
-" Syntax: Decimals smaller than one should begin with 0 (so .1 should be 0.1).
-syn match   jsonNumError  "\:\@<=[[:blank:]\r\n]*\zs\.\d\+"
+	" Syntax: Decimals smaller than one should begin with 0 (so .1 should be 0.1).
+	syn match   jsonNumError  "\:\@<=[[:blank:]\r\n]*\zs\.\d\+"
 
-" Syntax: No comments in JSON, see http://stackoverflow.com/questions/244777/can-i-comment-a-json-file
-syn match   jsonCommentError  "//.*"
-syn match   jsonCommentError  "\(/\*\)\|\(\*/\)"
+	" Syntax: No comments in JSON, see http://stackoverflow.com/questions/244777/can-i-comment-a-json-file
+	syn match   jsonCommentError  "//.*"
+	syn match   jsonCommentError  "\(/\*\)\|\(\*/\)"
+
+	" Syntax: No semicolons in JSON
+	syn match   jsonSemicolonError  ";"
 
-" Syntax: No semicolons in JSON
-syn match   jsonSemicolonError  ";"
+	" Syntax: No trailing comma after the last element of arrays or objects
+	syn match   jsonTrailingCommaError  ",\_s*[}\]]"
 
-" Syntax: No trailing comma after the last element of arrays or objects
-syn match   jsonCommaError  ",\_s*[}\]]"
+	" Syntax: Watch out for missing commas between elements
+	syn match   jsonMissingCommaError /\("\|\d\)\zs\_s\+\ze"/
+endif
 
 " ********************************************** END OF ERROR WARNINGS
 " Allowances for JSONP: function call at the beginning of the file,
@@ -73,7 +79,8 @@
 syn match  jsonPadding ");[[:blank:]\r\n]*\%$"
 
 " Syntax: Boolean
-syn keyword  jsonBoolean   true false
+syn keyword  jsonBooleanTrue true
+syn keyword  jsonBooleanFalse false
 
 " Syntax: Null
 syn keyword  jsonNull      null
@@ -94,19 +101,25 @@
   endif
   HiLink jsonPadding         Operator
   HiLink jsonString          String
+  HiLink jsonTest          Label
   HiLink jsonEscape          Special
   HiLink jsonNumber          Number
-  HiLink jsonBraces          Operator
+  HiLink jsonBraces          Delimiter
   HiLink jsonNull            Function
+  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
+	if (g:vim_json_warnings == 1)
+	  HiLink jsonNumError        Error
+	  HiLink jsonCommentError    Error
+	  HiLink jsonSemicolonError  Error
+	  HiLink jsonTrailingCommaError     Error
+	  HiLink jsonMissingCommaError      Error
+	  HiLink jsonStringSQError        	Error
+	  HiLink jsonNoQuotesError        	Error
+  endif
   HiLink jsonQuote           Quote
   HiLink jsonNoise           Noise
   delcommand HiLink