comparison vendor/vim-syntax/json.vim @ 517:14b645f67f7c

Update vim-syntax.
author edogawaconan <me@myconan.net>
date Thu, 22 May 2014 15:22:53 +0900
parents bbcffc594d1e
children a198065ff6e8
comparison
equal deleted inserted replaced
516:6ef4bbc171eb 517:14b645f67f7c
16 syntax match jsonNoise /\%(:\|,\)/ 16 syntax match jsonNoise /\%(:\|,\)/
17 17
18 " NOTE that for the concealing to work your conceallevel should be set to 2 18 " NOTE that for the concealing to work your conceallevel should be set to 2
19 19
20 " Syntax: Strings 20 " Syntax: Strings
21 " Separated into a match and region because a region by itself is always greedy
22 syn match jsonStringMatch /"[^\"]\+"\ze[[:blank:]\r\n]*[,}\]]/ contains=jsonString
21 if has('conceal') 23 if has('conceal')
22 syn region jsonString oneline matchgroup=jsonQuote start=/"/ skip=/\\\\\|\\"/ end=/"/ concealends contains=jsonEscape 24 syn region jsonString oneline matchgroup=jsonQuote start=/"/ skip=/\\\\\|\\"/ end=/"/ concealends contains=jsonEscape contained
23 else 25 else
24 syn region jsonString oneline matchgroup=jsonQuote start=/"/ skip=/\\\\\|\\"/ end=/"/ contains=jsonEscape 26 syn region jsonString oneline matchgroup=jsonQuote start=/"/ skip=/\\\\\|\\"/ end=/"/ contains=jsonEscape contained
25 endif 27 endif
26 28
27 " Syntax: JSON does not allow strings with single quotes, unlike JavaScript. 29 " Syntax: JSON does not allow strings with single quotes, unlike JavaScript.
28 syn region jsonStringSQ oneline start=+'+ skip=+\\\\\|\\"+ end=+'+ 30 syn region jsonStringSQError oneline start=+'+ skip=+\\\\\|\\"+ end=+'+
29 31
30 " Syntax: JSON Keywords 32 " Syntax: JSON Keywords
31 " Separated into a match and region because a region by itself is always greedy 33 " Separated into a match and region because a region by itself is always greedy
32 syn match jsonKeywordMatch /"[^\"\:]\+"[[:blank:]\r\n]*\:/ contains=jsonKeywordRegion 34 syn match jsonKeywordMatch /"[^\"]\+"[[:blank:]\r\n]*\:/ contains=jsonKeyword
33 if has('conceal') 35 if has('conceal')
34 syn region jsonKeywordRegion matchgroup=jsonQuote start=/"/ end=/"\ze[[:blank:]\r\n]*\:/ concealends contained 36 syn region jsonKeyword matchgroup=jsonQuote start=/"/ end=/"\ze[[:blank:]\r\n]*\:/ concealends contained
35 else 37 else
36 syn region jsonKeywordRegion matchgroup=jsonQuote start=/"/ end=/"\ze[[:blank:]\r\n]*\:/ contained 38 syn region jsonKeyword matchgroup=jsonQuote start=/"/ end=/"\ze[[:blank:]\r\n]*\:/ contained
37 endif 39 endif
38 40
39 " Syntax: Escape sequences 41 " Syntax: Escape sequences
40 syn match jsonEscape "\\["\\/bfnrt]" contained 42 syn match jsonEscape "\\["\\/bfnrt]" contained
41 syn match jsonEscape "\\u\x\{4}" contained 43 syn match jsonEscape "\\u\x\{4}" contained
42 44
43 " Syntax: Numbers 45 " Syntax: Numbers
44 syn match jsonNumber "-\=\<\%(0\|[1-9]\d*\)\%(\.\d\+\)\=\%([eE][-+]\=\d\+\)\=\>" 46 syn match jsonNumber "-\=\<\%(0\|[1-9]\d*\)\%(\.\d\+\)\=\%([eE][-+]\=\d\+\)\=\>\ze[[:blank:]\r\n]*[,}\]]"
45 47
46 " ERROR WARNINGS ********************************************** 48 " ERROR WARNINGS **********************************************
47 " 49 if (g:vim_json_warnings == 1)
48 " Syntax: Strings should always be enclosed with quotes. 50 " Syntax: Strings should always be enclosed with quotes.
49 syn match jsonNoQuotes "\<[[:alpha:]]\+\>" 51 syn match jsonNoQuotesError "\<[[:alpha:]]\+\>"
50 52
51 " Syntax: An integer part of 0 followed by other digits is not allowed. 53 " Syntax: An integer part of 0 followed by other digits is not allowed.
52 syn match jsonNumError "-\=\<0\d\.\d*\>" 54 syn match jsonNumError "-\=\<0\d\.\d*\>"
53 55
54 " Syntax: Decimals smaller than one should begin with 0 (so .1 should be 0.1). 56 " Syntax: Decimals smaller than one should begin with 0 (so .1 should be 0.1).
55 syn match jsonNumError "\:\@<=[[:blank:]\r\n]*\zs\.\d\+" 57 syn match jsonNumError "\:\@<=[[:blank:]\r\n]*\zs\.\d\+"
56 58
57 " Syntax: No comments in JSON, see http://stackoverflow.com/questions/244777/can-i-comment-a-json-file 59 " Syntax: No comments in JSON, see http://stackoverflow.com/questions/244777/can-i-comment-a-json-file
58 syn match jsonCommentError "//.*" 60 syn match jsonCommentError "//.*"
59 syn match jsonCommentError "\(/\*\)\|\(\*/\)" 61 syn match jsonCommentError "\(/\*\)\|\(\*/\)"
60 62
61 " Syntax: No semicolons in JSON 63 " Syntax: No semicolons in JSON
62 syn match jsonSemicolonError ";" 64 syn match jsonSemicolonError ";"
63 65
64 " Syntax: No trailing comma after the last element of arrays or objects 66 " Syntax: No trailing comma after the last element of arrays or objects
65 syn match jsonCommaError ",\_s*[}\]]" 67 syn match jsonTrailingCommaError ",\_s*[}\]]"
68
69 " Syntax: Watch out for missing commas between elements
70 syn match jsonMissingCommaError /\("\|\d\)\zs\_s\+\ze"/
71 endif
66 72
67 " ********************************************** END OF ERROR WARNINGS 73 " ********************************************** END OF ERROR WARNINGS
68 " Allowances for JSONP: function call at the beginning of the file, 74 " Allowances for JSONP: function call at the beginning of the file,
69 " parenthesis and semicolon at the end. 75 " parenthesis and semicolon at the end.
70 " Function name validation based on 76 " Function name validation based on
71 " http://stackoverflow.com/questions/2008279/validate-a-javascript-function-name/2008444#2008444 77 " http://stackoverflow.com/questions/2008279/validate-a-javascript-function-name/2008444#2008444
72 syn match jsonPadding "\%^[[:blank:]\r\n]*[_$[:alpha:]][_$[:alnum:]]*[[:blank:]\r\n]*(" 78 syn match jsonPadding "\%^[[:blank:]\r\n]*[_$[:alpha:]][_$[:alnum:]]*[[:blank:]\r\n]*("
73 syn match jsonPadding ");[[:blank:]\r\n]*\%$" 79 syn match jsonPadding ");[[:blank:]\r\n]*\%$"
74 80
75 " Syntax: Boolean 81 " Syntax: Boolean
76 syn keyword jsonBoolean true false 82 syn keyword jsonBooleanTrue true
83 syn keyword jsonBooleanFalse false
77 84
78 " Syntax: Null 85 " Syntax: Null
79 syn keyword jsonNull null 86 syn keyword jsonNull null
80 87
81 " Syntax: Braces 88 " Syntax: Braces
92 else 99 else
93 command -nargs=+ HiLink hi def link <args> 100 command -nargs=+ HiLink hi def link <args>
94 endif 101 endif
95 HiLink jsonPadding Operator 102 HiLink jsonPadding Operator
96 HiLink jsonString String 103 HiLink jsonString String
104 HiLink jsonTest Label
97 HiLink jsonEscape Special 105 HiLink jsonEscape Special
98 HiLink jsonNumber Number 106 HiLink jsonNumber Number
99 HiLink jsonBraces Operator 107 HiLink jsonBraces Delimiter
100 HiLink jsonNull Function 108 HiLink jsonNull Function
109 HiLink jsonBooleanTrue jsonBoolean
110 HiLink jsonBooleanFalse jsonBoolean
101 HiLink jsonBoolean Boolean 111 HiLink jsonBoolean Boolean
102 HiLink jsonKeywordRegion Label 112 HiLink jsonKeyword Label
103 113
104 HiLink jsonNumError Error 114 if (g:vim_json_warnings == 1)
105 HiLink jsonCommentError Error 115 HiLink jsonNumError Error
106 HiLink jsonSemicolonError Error 116 HiLink jsonCommentError Error
107 HiLink jsonCommaError Error 117 HiLink jsonSemicolonError Error
108 HiLink jsonStringSQ Error 118 HiLink jsonTrailingCommaError Error
109 HiLink jsonNoQuotes Error 119 HiLink jsonMissingCommaError Error
120 HiLink jsonStringSQError Error
121 HiLink jsonNoQuotesError Error
122 endif
110 HiLink jsonQuote Quote 123 HiLink jsonQuote Quote
111 HiLink jsonNoise Noise 124 HiLink jsonNoise Noise
112 delcommand HiLink 125 delcommand HiLink
113 endif 126 endif
114 127