From 4c9cc78aef8a1876ff96b963064f1f71a68b9b4b Mon Sep 17 00:00:00 2001 From: Buddy Sandidge Date: Wed, 19 Feb 2014 22:00:55 -0800 Subject: [PATCH] Squashed 'vim/bundle/json/' content from commit 479460939 git-subtree-dir: vim/bundle/json git-subtree-split: 47946093993aecbd6d96a95e45ccc09a091b02eb --- README.md | 8 +++++ ftdetect/json.vim | 1 + syntax/json.vim | 77 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+) create mode 100644 README.md create mode 100644 ftdetect/json.vim create mode 100644 syntax/json.vim diff --git a/README.md b/README.md new file mode 100644 index 0000000..de7b231 --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +# vim-json + +This is a simple wrapper around the JSON syntax hightlighting file by +Jeroen Ruigrok van der Werven to make it easier to bundle with +[Vundle](https://github.com/gmarik/vundle) + +The original syntax file can be found at +http://www.vim.org/scripts/script.php?script_id=1945 \ No newline at end of file diff --git a/ftdetect/json.vim b/ftdetect/json.vim new file mode 100644 index 0000000..21d2d56 --- /dev/null +++ b/ftdetect/json.vim @@ -0,0 +1 @@ +au BufRead,BufNewFile *.json set filetype=json diff --git a/syntax/json.vim b/syntax/json.vim new file mode 100644 index 0000000..f3e27ba --- /dev/null +++ b/syntax/json.vim @@ -0,0 +1,77 @@ +" Vim syntax file +" Language: JSON +" Maintainer: Jeroen Ruigrok van der Werven +" Last Change: 2009-06-16 +" Version: 0.4 +" {{{1 + +" Syntax setup {{{2 +" For version 5.x: Clear all syntax items +" For version 6.x: Quit when a syntax file was already loaded + +if !exists("main_syntax") + if version < 600 + syntax clear + elseif exists("b:current_syntax") + finish + endif + let main_syntax = 'json' +endif + +" Syntax: Strings {{{2 +syn region jsonString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=jsonEscape +" Syntax: JSON does not allow strings with single quotes, unlike JavaScript. +syn region jsonStringSQ start=+'+ skip=+\\\\\|\\"+ end=+'+ + +" Syntax: Escape sequences {{{3 +syn match jsonEscape "\\["\\/bfnrt]" contained +syn match jsonEscape "\\u\x\{4}" contained + +" Syntax: Strings should always be enclosed with quotes. +syn match jsonNoQuotes "\<\a\+\>" + +" Syntax: Numbers {{{2 +syn match jsonNumber "-\=\<\%(0\|[1-9]\d*\)\%(\.\d\+\)\=\%([eE][-+]\=\d\+\)\=\>" + +" Syntax: An integer part of 0 followed by other digits is not allowed. +syn match jsonNumError "-\=\<0\d\.\d*\>" + +" Syntax: Boolean {{{2 +syn keyword jsonBoolean true false + +" Syntax: Null {{{2 +syn keyword jsonNull null + +" Syntax: Braces {{{2 +syn match jsonBraces "[{}\[\]]" + +" Define the default highlighting. {{{1 +" For version 5.7 and earlier: only when not done already +" For version 5.8 and later: only when an item doesn't have highlighting yet +if version >= 508 || !exists("did_json_syn_inits") + if version < 508 + let did_json_syn_inits = 1 + command -nargs=+ HiLink hi link + else + command -nargs=+ HiLink hi def link + endif + HiLink jsonString String + HiLink jsonEscape Special + HiLink jsonNumber Number + HiLink jsonBraces Operator + HiLink jsonNull Function + HiLink jsonBoolean Boolean + + HiLink jsonNumError Error + HiLink jsonStringSQ Error + HiLink jsonNoQuotes Error + delcommand HiLink +endif + +let b:current_syntax = "json" +if main_syntax == 'json' + unlet main_syntax +endif + +" Vim settings {{{2 +" vim: ts=8 fdm=marker