Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Optionally allow colon in json key #28

Closed
wants to merge 1 commit into from

2 participants

@fungusakafungus

via setting g:vim_json_allow_colon_in_key to 1

TODO: document it and show it in examples

@fungusakafungus fungusakafungus Optionally allow colon in json key
via setting g:vim_json_allow_colon_in_key to 1
f4e209b
@elzr
Owner

Thanks for taking the time to optionally allow this. Unfortunately, it was just a mistake on my part so there's no need.

@elzr elzr closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 27, 2014
  1. @fungusakafungus

    Optionally allow colon in json key

    fungusakafungus authored
    via setting g:vim_json_allow_colon_in_key to 1
This page is out of date. Refresh to see the latest.
Showing with 9 additions and 1 deletion.
  1. +4 −0 ftplugin/json.vim
  2. +5 −1 syntax/json.vim
View
4 ftplugin/json.vim
@@ -26,3 +26,7 @@ if has('conceal')
"maybe g:vim_json_syntax_conceal could be settable to 0,1,2 to map
"directly to vim's conceallevels? unsure if anyone cares
endif
+
+if !exists("g:vim_json_allow_colon_in_key")
+ let g:vim_json_allow_colon_in_key = 0
+end
View
6 syntax/json.vim
@@ -31,7 +31,11 @@ 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=jsonKeyword
+let s:colon = ''
+if g:vim_json_allow_colon_in_key == 0
+ let s:colon = '\:'
+endif
+execute 'syn match jsonKeywordMatch /"[^\"' . s:colon . ']\+"[[:blank:]\r\n]*\:/ contains=jsonKeyword'
if has('conceal')
syn region jsonKeyword matchgroup=jsonQuote start=/"/ end=/"\ze[[:blank:]\r\n]*\:/ concealends contained
else
Something went wrong with that request. Please try again.