comparison vendor/vim-syntax/json.vim @ 537:351bd965bc1f

Update some syntax files.
author edogawaconan <me@myconan.net>
date Mon, 05 Jan 2015 21:47:44 +0900
parents a198065ff6e8
children 6f57f959cc0b
comparison
equal deleted inserted replaced
536:d4e874f04bc6 537:351bd965bc1f
1 " Vim syntax file 1 " Vim syntax file
2 " Language: JSON 2 " Language: JSON
3 " Maintainer: Eli Parra <eli@elzr.com> 3 " Maintainer: Eli Parra <eli@elzr.com> https://github.com/elzr/vim-json
4 " Last Change: 2013-02-01 4 " Last Change: 2014-12-20 Load ftplugin/json.vim
5 " Version: 0.12 5
6 " Reload the definition of g:vim_json_syntax_conceal
7 " see https://github.com/elzr/vim-json/issues/42
8 runtime! ftplugin/json.vim
6 9
7 if !exists("main_syntax") 10 if !exists("main_syntax")
8 if version < 600 11 if version < 600
9 syntax clear 12 syntax clear
10 elseif exists("b:current_syntax") 13 elseif exists("b:current_syntax")
17 20
18 " NOTE that for the concealing to work your conceallevel should be set to 2 21 " NOTE that for the concealing to work your conceallevel should be set to 2
19 22
20 " Syntax: Strings 23 " Syntax: Strings
21 " Separated into a match and region because a region by itself is always greedy 24 " Separated into a match and region because a region by itself is always greedy
22 syn match jsonStringMatch /"[^\"]\+"\ze[[:blank:]\r\n]*[,}\]]/ contains=jsonString 25 syn match jsonStringMatch /"\([^"]\|\\\"\)\+"\ze[[:blank:]\r\n]*[,}\]]/ contains=jsonString
23 if has('conceal') 26 if has('conceal') && g:vim_json_syntax_conceal == 1
24 syn region jsonString oneline matchgroup=jsonQuote start=/"/ skip=/\\\\\|\\"/ end=/"/ concealends contains=jsonEscape contained 27 syn region jsonString oneline matchgroup=jsonQuote start=/"/ skip=/\\\\\|\\"/ end=/"/ concealends contains=jsonEscape contained
25 else 28 else
26 syn region jsonString oneline matchgroup=jsonQuote start=/"/ skip=/\\\\\|\\"/ end=/"/ contains=jsonEscape contained 29 syn region jsonString oneline matchgroup=jsonQuote start=/"/ skip=/\\\\\|\\"/ end=/"/ contains=jsonEscape contained
27 endif 30 endif
28 31
29 " Syntax: JSON does not allow strings with single quotes, unlike JavaScript. 32 " Syntax: JSON does not allow strings with single quotes, unlike JavaScript.
30 syn region jsonStringSQError oneline start=+'+ skip=+\\\\\|\\"+ end=+'+ 33 syn region jsonStringSQError oneline start=+'+ skip=+\\\\\|\\"+ end=+'+
31 34
32 " Syntax: JSON Keywords 35 " Syntax: JSON Keywords
33 " Separated into a match and region because a region by itself is always greedy 36 " Separated into a match and region because a region by itself is always greedy
34 syn match jsonKeywordMatch /"[^\"]\+"[[:blank:]\r\n]*\:/ contains=jsonKeyword 37 syn match jsonKeywordMatch /"\([^"]\|\\\"\)\+"[[:blank:]\r\n]*\:/ contains=jsonKeyword
35 if has('conceal') 38 if has('conceal') && g:vim_json_syntax_conceal == 1
36 syn region jsonKeyword matchgroup=jsonQuote start=/"/ end=/"\ze[[:blank:]\r\n]*\:/ concealends contained 39 syn region jsonKeyword matchgroup=jsonQuote start=/"/ end=/"\ze[[:blank:]\r\n]*\:/ concealends contained
37 else 40 else
38 syn region jsonKeyword matchgroup=jsonQuote start=/"/ end=/"\ze[[:blank:]\r\n]*\:/ contained 41 syn region jsonKeyword matchgroup=jsonQuote start=/"/ end=/"\ze[[:blank:]\r\n]*\:/ contained
39 endif 42 endif
40 43
46 syn match jsonNumber "-\=\<\%(0\|[1-9]\d*\)\%(\.\d\+\)\=\%([eE][-+]\=\d\+\)\=\>\ze[[:blank:]\r\n]*[,}\]]" 49 syn match jsonNumber "-\=\<\%(0\|[1-9]\d*\)\%(\.\d\+\)\=\%([eE][-+]\=\d\+\)\=\>\ze[[:blank:]\r\n]*[,}\]]"
47 50
48 " ERROR WARNINGS ********************************************** 51 " ERROR WARNINGS **********************************************
49 if (!exists("g:vim_json_warnings") || g:vim_json_warnings==1) 52 if (!exists("g:vim_json_warnings") || g:vim_json_warnings==1)
50 " Syntax: Strings should always be enclosed with quotes. 53 " Syntax: Strings should always be enclosed with quotes.
51 syn match jsonNoQuotesError "\<[[:alpha:]]\+\>" 54 syn match jsonNoQuotesError "\<[[:alpha:]][[:alnum:]]*\>"
55 syn match jsonTripleQuotesError /"""/
52 56
53 " Syntax: An integer part of 0 followed by other digits is not allowed. 57 " Syntax: An integer part of 0 followed by other digits is not allowed.
54 syn match jsonNumError "-\=\<0\d\.\d*\>" 58 syn match jsonNumError "-\=\<0\d\.\d*\>"
55 59
56 " Syntax: Decimals smaller than one should begin with 0 (so .1 should be 0.1). 60 " Syntax: Decimals smaller than one should begin with 0 (so .1 should be 0.1).
65 69
66 " Syntax: No trailing comma after the last element of arrays or objects 70 " Syntax: No trailing comma after the last element of arrays or objects
67 syn match jsonTrailingCommaError ",\_s*[}\]]" 71 syn match jsonTrailingCommaError ",\_s*[}\]]"
68 72
69 " Syntax: Watch out for missing commas between elements 73 " Syntax: Watch out for missing commas between elements
70 syn match jsonMissingCommaError /\("\|\d\)\zs\_s\+\ze"/ 74 syn match jsonMissingCommaError /\("\|\]\|\d\)\zs\_s\+\ze"/
75 syn match jsonMissingCommaError /\(\]\|\}\)\_s\+\ze"/ "arrays/objects as values
76 syn match jsonMissingCommaError /}\_s\+\ze{/ "objects as elements in an array
77 syn match jsonMissingCommaError /\(true\|false\)\_s\+\ze"/ "true/false as value
71 endif 78 endif
72 79
73 " ********************************************** END OF ERROR WARNINGS 80 " ********************************************** END OF ERROR WARNINGS
74 " Allowances for JSONP: function call at the beginning of the file, 81 " Allowances for JSONP: function call at the beginning of the file,
75 " parenthesis and semicolon at the end. 82 " parenthesis and semicolon at the end.
77 " http://stackoverflow.com/questions/2008279/validate-a-javascript-function-name/2008444#2008444 84 " http://stackoverflow.com/questions/2008279/validate-a-javascript-function-name/2008444#2008444
78 syn match jsonPadding "\%^[[:blank:]\r\n]*[_$[:alpha:]][_$[:alnum:]]*[[:blank:]\r\n]*(" 85 syn match jsonPadding "\%^[[:blank:]\r\n]*[_$[:alpha:]][_$[:alnum:]]*[[:blank:]\r\n]*("
79 syn match jsonPadding ");[[:blank:]\r\n]*\%$" 86 syn match jsonPadding ");[[:blank:]\r\n]*\%$"
80 87
81 " Syntax: Boolean 88 " Syntax: Boolean
82 syn keyword jsonBooleanTrue true 89 syn match jsonBoolean /\(true\|false\)\(\_s\+\ze"\)\@!/
83 syn keyword jsonBooleanFalse false
84 90
85 " Syntax: Null 91 " Syntax: Null
86 syn keyword jsonNull null 92 syn keyword jsonNull null
87 93
88 " Syntax: Braces 94 " Syntax: Braces
89 syn region jsonFold matchgroup=jsonBraces start="{" end="}" transparent fold 95 syn region jsonFold matchgroup=jsonBraces start="{" end=/}\(\_s\+\ze\("\|{\)\)\@!/ transparent fold
90 syn region jsonFold matchgroup=jsonBraces start="\[" end="]" transparent fold 96 syn region jsonFold matchgroup=jsonBraces start="\[" end=/]\(\_s\+\ze"\)\@!/ transparent fold
91 97
92 " Define the default highlighting. 98 " Define the default highlighting.
93 " For version 5.7 and earlier: only when not done already
94 " For version 5.8 and later: only when an item doesn't have highlighting yet
95 if version >= 508 || !exists("did_json_syn_inits") 99 if version >= 508 || !exists("did_json_syn_inits")
96 if version < 508 100 hi def link jsonPadding Operator
97 let did_json_syn_inits = 1 101 hi def link jsonString String
98 command -nargs=+ HiLink hi link <args> 102 hi def link jsonTest Label
99 else 103 hi def link jsonEscape Special
100 command -nargs=+ HiLink hi def link <args> 104 hi def link jsonNumber Number
101 endif 105 hi def link jsonBraces Delimiter
102 HiLink jsonPadding Operator 106 hi def link jsonNull Function
103 HiLink jsonString String 107 hi def link jsonBoolean Boolean
104 HiLink jsonTest Label 108 hi def link jsonKeyword Label
105 HiLink jsonEscape Special
106 HiLink jsonNumber Number
107 HiLink jsonBraces Delimiter
108 HiLink jsonNull Function
109 HiLink jsonBooleanTrue jsonBoolean
110 HiLink jsonBooleanFalse jsonBoolean
111 HiLink jsonBoolean Boolean
112 HiLink jsonKeyword Label
113 109
114 if (!exists("g:vim_json_warnings") || g:vim_json_warnings==1) 110 if (!exists("g:vim_json_warnings") || g:vim_json_warnings==1)
115 HiLink jsonNumError Error 111 hi def link jsonNumError Error
116 HiLink jsonCommentError Error 112 hi def link jsonCommentError Error
117 HiLink jsonSemicolonError Error 113 hi def link jsonSemicolonError Error
118 HiLink jsonTrailingCommaError Error 114 hi def link jsonTrailingCommaError Error
119 HiLink jsonMissingCommaError Error 115 hi def link jsonMissingCommaError Error
120 HiLink jsonStringSQError Error 116 hi def link jsonStringSQError Error
121 HiLink jsonNoQuotesError Error 117 hi def link jsonNoQuotesError Error
118 hi def link jsonTripleQuotesError Error
122 endif 119 endif
123 HiLink jsonQuote Quote 120 hi def link jsonQuote Quote
124 HiLink jsonNoise Noise 121 hi def link jsonNoise Noise
125 delcommand HiLink
126 endif 122 endif
127 123
128 let b:current_syntax = "json" 124 let b:current_syntax = "json"
129 if main_syntax == 'json' 125 if main_syntax == 'json'
130 unlet main_syntax 126 unlet main_syntax