diff options
Diffstat (limited to 'base/vim/syntax')
-rw-r--r-- | base/vim/syntax/json.vim | 93 |
1 files changed, 44 insertions, 49 deletions
diff --git a/base/vim/syntax/json.vim b/base/vim/syntax/json.vim index 3423eba..e094be1 100644 --- a/base/vim/syntax/json.vim +++ b/base/vim/syntax/json.vim @@ -1,8 +1,3 @@ -" Vim syntax file -" Language: JSON -" Maintainer: Eli Parra <[email protected]> https://github.com/elzr/vim-json -" Last Change: 2014-12-20 Load ftplugin/json.vim - " Reload the definition of g:vim_json_syntax_conceal " see https://github.com/elzr/vim-json/issues/42 runtime! ftplugin/json.vim @@ -24,9 +19,9 @@ syntax match jsonNoise /\%(:\|,\)/ " 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') && g:vim_json_syntax_conceal == 1 - syn region jsonString oneline matchgroup=jsonQuote start=/"/ skip=/\\\\\|\\"/ end=/"/ concealends contains=jsonEscape contained + 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 contained + syn region jsonString oneline matchgroup=jsonQuote start=/"/ skip=/\\\\\|\\"/ end=/"/ contains=jsonEscape contained endif " Syntax: JSON does not allow strings with single quotes, unlike JavaScript. @@ -36,9 +31,9 @@ syn region jsonStringSQError oneline start=+'+ skip=+\\\\\|\\"+ end=+'+ " Separated into a match and region because a region by itself is always greedy syn match jsonKeywordMatch /"\([^"]\|\\\"\)\+"[[:blank:]\r\n]*\:/ contains=jsonKeyword if has('conceal') && g:vim_json_syntax_conceal == 1 - syn region jsonKeyword matchgroup=jsonQuote start=/"/ end=/"\ze[[:blank:]\r\n]*\:/ concealends contains=jsonEscape contained + syn region jsonKeyword matchgroup=jsonQuote start=/"/ end=/"\ze[[:blank:]\r\n]*\:/ concealends contains=jsonEscape contained else - syn region jsonKeyword matchgroup=jsonQuote start=/"/ end=/"\ze[[:blank:]\r\n]*\:/ contains=jsonEscape contained + syn region jsonKeyword matchgroup=jsonQuote start=/"/ end=/"\ze[[:blank:]\r\n]*\:/ contains=jsonEscape contained endif " Syntax: Escape sequences @@ -50,31 +45,31 @@ syn match jsonNumber "-\=\<\%(0\|[1-9]\d*\)\%(\.\d\+\)\=\%([eE][-+]\=\d\+\) " ERROR WARNINGS ********************************************** if (!exists("g:vim_json_warnings") || g:vim_json_warnings==1) - " Syntax: Strings should always be enclosed with quotes. - syn match jsonNoQuotesError "\<[[:alpha:]][[:alnum:]]*\>" - syn match jsonTripleQuotesError /"""/ + " Syntax: Strings should always be enclosed with quotes. + syn match jsonNoQuotesError "\<[[:alpha:]][[:alnum:]]*\>" + syn match jsonTripleQuotesError /"""/ - " 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 jsonTrailingCommaError ",\_s*[}\]]" - " Syntax: Watch out for missing commas between elements - syn match jsonMissingCommaError /\("\|\]\|\d\)\zs\_s\+\ze"/ - syn match jsonMissingCommaError /\(\]\|\}\)\_s\+\ze"/ "arrays/objects as values - syn match jsonMissingCommaError /}\_s\+\ze{/ "objects as elements in an array - syn match jsonMissingCommaError /\(true\|false\)\_s\+\ze"/ "true/false as value + " Syntax: Watch out for missing commas between elements + syn match jsonMissingCommaError /\("\|\]\|\d\)\zs\_s\+\ze"/ + syn match jsonMissingCommaError /\(\]\|\}\)\_s\+\ze"/ "arrays/objects as values + syn match jsonMissingCommaError /}\_s\+\ze{/ "objects as elements in an array + syn match jsonMissingCommaError /\(true\|false\)\_s\+\ze"/ "true/false as value endif " ********************************************** END OF ERROR WARNINGS @@ -97,28 +92,28 @@ syn region jsonFold matchgroup=jsonBraces start="\[" end=/]\(\_s\+\ze"\)\@!/ tr " Define the default highlighting. if version >= 508 || !exists("did_json_syn_inits") - hi def link jsonPadding Operator - hi def link jsonString String - hi def link jsonTest Label - hi def link jsonEscape Special - hi def link jsonNumber Delimiter - hi def link jsonBraces Delimiter - hi def link jsonNull Function - hi def link jsonBoolean Delimiter - hi def link jsonKeyword Label - - if (!exists("g:vim_json_warnings") || g:vim_json_warnings==1) - hi def link jsonNumError Error - hi def link jsonCommentError Error - hi def link jsonSemicolonError Error - hi def link jsonTrailingCommaError Error - hi def link jsonMissingCommaError Error - hi def link jsonStringSQError Error - hi def link jsonNoQuotesError Error - hi def link jsonTripleQuotesError Error + hi def link jsonPadding Operator + hi def link jsonString String + hi def link jsonTest Label + hi def link jsonEscape Special + hi def link jsonNumber Delimiter + hi def link jsonBraces Delimiter + hi def link jsonNull Function + hi def link jsonBoolean Delimiter + hi def link jsonKeyword Label + + if (!exists("g:vim_json_warnings") || g:vim_json_warnings==1) + hi def link jsonNumError Error + hi def link jsonCommentError Error + hi def link jsonSemicolonError Error + hi def link jsonTrailingCommaError Error + hi def link jsonMissingCommaError Error + hi def link jsonStringSQError Error + hi def link jsonNoQuotesError Error + hi def link jsonTripleQuotesError Error endif - hi def link jsonQuote Quote - hi def link jsonNoise Noise + hi def link jsonQuote Quote + hi def link jsonNoise Noise endif let b:current_syntax = "json" |