Mercurial > vim
annotate runtime/syntax/json5.vim @ 33593:0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Commit: https://github.com/vim/vim/commit/5a33ce2a661fb836d4c5c489f2a850172a23e0b0
Author: Rolf Vidar Mazunki Hoksaas <32819373+mazunki@users.noreply.github.com>
Date: Tue Oct 17 11:13:06 2023 +0200
runtime(json5): include syntax script for json5 (https://github.com/vim/vim/issues/13356)
Merging syntax file from gutenye/json5.vim, modified to include proper
vim header.
See: https://github.com/vim/vim/issues/8499
Signed-off-by: Mazunki Hoksaas <rolferen@gmail.com>
Co-authored-by: Guten Ye <ywzhaifei@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 17 Oct 2023 11:15:11 +0200 |
parents | |
children | b1f32ec709ae |
rev | line source |
---|---|
33593
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
1 " Vim syntax file |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
2 " Language: JSON5 |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
3 " Maintainer: Mazunki Hoksaas rolferen@gmail.com |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
4 " Previous Maintainer: Guten Ye <ywzhaifei@gmail.com> |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
5 " Last Change: 2019 Apr 1 |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
6 " Version: vim9.0-1 |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
7 " URL: https://github.com/json5/json5 |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
8 |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
9 " Syntax setup |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
10 if exists('b:current_syntax') && b:current_syntax == 'json5' |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
11 finish |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
12 endif |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
13 |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
14 " Numbers |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
15 syn match json5Number "[-+]\=\%(0\|[1-9]\d*\)\%(\.\d*\)\=\%([eE][-+]\=\d\+\)\=" |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
16 syn match json5Number "[-+]\=\%(\.\d\+\)\%([eE][-+]\=\d\+\)\=" |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
17 syn match json5Number "[-+]\=0[xX]\x*" |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
18 syn match json5Number "[-+]\=Infinity\|NaN" |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
19 |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
20 " An integer part of 0 followed by other digits is not allowed |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
21 syn match json5NumError "[-+]\=0\d\(\d\|\.\)*" |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
22 |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
23 " A hexadecimal number cannot have a fractional part |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
24 syn match json5NumError "[-+]\=0x\x*\.\x*" |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
25 |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
26 " Strings |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
27 syn region json5String start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=json5Escape,@Spell |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
28 syn region json5String start=+'+ skip=+\\\\\|\\'+ end=+'+ contains=json5Escape,@Spell |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
29 |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
30 " Escape sequences |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
31 syn match json5Escape "\\['\"\\bfnrtv]" contained |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
32 syn match json5Escape "\\u\x\{4}" contained |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
33 |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
34 " Boolean |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
35 syn keyword json5Boolean true false |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
36 |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
37 " Null |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
38 syn keyword json5Null null |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
39 |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
40 " Delimiters and Operators |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
41 syn match json5Delimiter "," |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
42 syn match json5Operator ":" |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
43 |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
44 " Braces |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
45 syn match json5Braces "[{}\[\]]" |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
46 |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
47 " Keys |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
48 syn match json5Key /@\?\%(\I\|\$\)\%(\i\|\$\)*\s*\ze::\@!/ contains=@Spell |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
49 syn match json5Key /"\([^"]\|\\"\)\{-}"\ze\s*:/ contains=json5Escape,@Spell |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
50 |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
51 " Comment |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
52 syn region json5LineComment start=+\/\/+ end=+$+ keepend contains=@Spell |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
53 syn region json5LineComment start=+^\s*\/\/+ skip=+\n\s*\/\/+ end=+$+ keepend fold contains=@Spell |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
54 syn region json5Comment start="/\*" end="\*/" fold contains=@Spell |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
55 |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
56 " Define the default highlighting |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
57 hi def link json5String String |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
58 hi def link json5Key Identifier |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
59 hi def link json5Escape Special |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
60 hi def link json5Number Number |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
61 hi def link json5Delimiter Delimiter |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
62 hi def link json5Operator Operator |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
63 hi def link json5Braces Delimiter |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
64 hi def link json5Null Keyword |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
65 hi def link json5Boolean Boolean |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
66 hi def link json5LineComment Comment |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
67 hi def link json5Comment Comment |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
68 hi def link json5NumError Error |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
69 |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
70 if !exists('b:current_syntax') |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
71 let b:current_syntax = 'json5' |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
72 endif |
0234f91bc590
runtime(json5): include syntax script for json5 (#13356)
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
73 |