Mercurial > vim
annotate runtime/syntax/yaml.vim @ 4831:b8eabb6a9687 v7.3.1162
updated for version 7.3.1162
Problem: Python: Memory leaks
Solution: Add more Py_DECREF(). (ZyX)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Mon, 10 Jun 2013 20:47:36 +0200 |
parents | 7d8af31066c8 |
children | 22da5ab9aaa1 |
rev | line source |
---|---|
7 | 1 " Vim syntax file |
2581 | 2 " Language: YAML (YAML Ain't Markup Language) 1.2 |
3 " Maintainer: Nikolai Pavlov <zyx.vim@gmail.com> | |
4 " First author: Nikolai Weibull <now@bitwi.se> | |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2581
diff
changeset
|
5 " Latest Revision: 2010-10-08 |
7 | 6 |
2581 | 7 if exists('b:current_syntax') |
8 finish | |
7 | 9 endif |
10 | |
375 | 11 let s:cpo_save = &cpo |
12 set cpo&vim | |
7 | 13 |
2581 | 14 let s:ns_char = '\%(\%([\n\r\uFEFF \t]\)\@!\p\)' |
15 let s:ns_word_char = '\%(\w\|-\)' | |
16 let s:ns_uri_char = '\%(%\x\x\|'.s:ns_word_char.'\|[#/;?:@&=+$,.!~*''()\[\]]\)' | |
17 let s:ns_tag_char = '\%(%\x\x\|'.s:ns_word_char.'\|[#/;?:@&=+$.~*''()]\)' | |
18 let s:c_ns_anchor_char = '\%(\%([\n\r\uFEFF \t,\[\]{}]\)\@!\p\)' | |
19 let s:c_indicator = '[\-?:,\[\]{}#&*!|>''"%@`]' | |
20 let s:c_flow_indicator = '[,\[\]{}]' | |
21 | |
22 let s:c_verbatim_tag = '!<'.s:ns_uri_char.'\+>' | |
23 let s:c_named_tag_handle = '!'.s:ns_word_char.'\+!' | |
24 let s:c_secondary_tag_handle = '!!' | |
25 let s:c_primary_tag_handle = '!' | |
26 let s:c_tag_handle = '\%('.s:c_named_tag_handle. | |
27 \ '\|'.s:c_secondary_tag_handle. | |
28 \ '\|'.s:c_primary_tag_handle.'\)' | |
29 let s:c_ns_shorthand_tag = s:c_tag_handle . s:ns_tag_char.'\+' | |
30 let s:c_non_specific_tag = '!' | |
31 let s:c_ns_tag_property = s:c_verbatim_tag. | |
32 \ '\|'.s:c_ns_shorthand_tag. | |
33 \ '\|'.s:c_non_specific_tag | |
34 | |
35 let s:c_ns_anchor_name = s:c_ns_anchor_char.'\+' | |
36 let s:c_ns_anchor_property = '&'.s:c_ns_anchor_name | |
37 let s:c_ns_alias_node = '\*'.s:c_ns_anchor_name | |
38 | |
39 let s:ns_directive_name = s:ns_char.'\+' | |
40 | |
41 let s:ns_local_tag_prefix = '!'.s:ns_uri_char.'*' | |
42 let s:ns_global_tag_prefix = s:ns_tag_char.s:ns_uri_char.'*' | |
43 let s:ns_tag_prefix = s:ns_local_tag_prefix. | |
44 \ '\|'.s:ns_global_tag_prefix | |
45 | |
46 let s:ns_plain_safe_out = s:ns_char | |
47 let s:ns_plain_safe_in = '\%('.s:c_flow_indicator.'\@!'.s:ns_char.'\)' | |
48 | |
49 let s:ns_plain_first_in = '\%('.s:c_indicator.'\@!'.s:ns_char.'\|[?:\-]\%('.s:ns_plain_safe_in.'\)\@=\)' | |
50 let s:ns_plain_first_out = '\%('.s:c_indicator.'\@!'.s:ns_char.'\|[?:\-]\%('.s:ns_plain_safe_out.'\)\@=\)' | |
51 | |
52 let s:ns_plain_char_in = '\%('.s:ns_char.'#\|:'.s:ns_plain_safe_in.'\|[:#]\@!'.s:ns_plain_safe_in.'\)' | |
53 let s:ns_plain_char_out = '\%('.s:ns_char.'#\|:'.s:ns_plain_safe_out.'\|[:#]\@!'.s:ns_plain_safe_out.'\)' | |
54 | |
55 let s:ns_plain_out = s:ns_plain_first_out . s:ns_plain_char_out.'*' | |
56 let s:ns_plain_in = s:ns_plain_first_in . s:ns_plain_char_in.'*' | |
57 | |
58 | |
1698 | 59 syn keyword yamlTodo contained TODO FIXME XXX NOTE |
7 | 60 |
2581 | 61 syn region yamlComment display oneline start='\%\(^\|\s\)#' end='$' |
62 \ contains=yamlTodo | |
7 | 63 |
2581 | 64 execute 'syn region yamlDirective oneline start='.string('^\ze%'.s:ns_directive_name.'\s\+').' '. |
65 \ 'end="$" '. | |
66 \ 'contains=yamlTAGDirective,'. | |
67 \ 'yamlYAMLDirective,'. | |
68 \ 'yamlReservedDirective '. | |
69 \ 'keepend' | |
1698 | 70 |
2581 | 71 syn match yamlTAGDirective '%TAG\s\+' contained nextgroup=yamlTagHandle |
72 execute 'syn match yamlTagHandle contained nextgroup=yamlTagPrefix '.string(s:c_tag_handle.'\s\+') | |
73 execute 'syn match yamlTagPrefix contained nextgroup=yamlComment ' . string(s:ns_tag_prefix) | |
7 | 74 |
2581 | 75 syn match yamlYAMLDirective '%YAML\s\+' contained nextgroup=yamlYAMLVersion |
76 syn match yamlYAMLVersion '\d\+\.\d\+' contained nextgroup=yamlComment | |
77 | |
78 execute 'syn match yamlReservedDirective contained nextgroup=yamlComment '. | |
79 \string('%\%(\%(TAG\|YAML\)\s\)\@!'.s:ns_directive_name) | |
7 | 80 |
2581 | 81 syn region yamlFlowString matchgroup=yamlFlowStringDelimiter start='"' skip='\\"' end='"' |
82 \ contains=yamlEscape | |
83 \ nextgroup=yamlKeyValueDelimiter | |
84 syn region yamlFlowString matchgroup=yamlFlowStringDelimiter start="'" skip="''" end="'" | |
85 \ contains=yamlSingleEscape | |
86 \ nextgroup=yamlKeyValueDelimiter | |
87 syn match yamlEscape contained '\\\%([\\"abefnrtv\^0_ NLP\n]\|x\x\x\|u\x\{4}\|U\x\{8}\)' | |
88 syn match yamlSingleEscape contained "''" | |
89 | |
90 syn match yamlBlockScalarHeader contained '\s\+\zs[|>]\%([+-]\=[1-9]\|[1-9]\=[+-]\)\=' | |
91 | |
92 syn cluster yamlFlow contains=yamlFlowString,yamlFlowMapping,yamlFlowCollection | |
93 syn cluster yamlFlow add=yamlFlowMappingKey,yamlFlowMappingMerge | |
94 syn cluster yamlFlow add=yamlConstant,yamlPlainScalar,yamlFloat | |
95 syn cluster yamlFlow add=yamlTimestamp,yamlInteger,yamlMappingKeyStart | |
96 syn cluster yamlFlow add=yamlComment | |
97 syn region yamlFlowMapping matchgroup=yamlFlowIndicator start='{' end='}' contains=@yamlFlow | |
98 syn region yamlFlowCollection matchgroup=yamlFlowIndicator start='\[' end='\]' contains=@yamlFlow | |
99 | |
100 execute 'syn match yamlPlainScalar /'.s:ns_plain_out.'/' | |
101 execute 'syn match yamlPlainScalar contained /'.s:ns_plain_in.'/' | |
102 | |
103 syn match yamlMappingKeyStart '?\ze\s' | |
104 syn match yamlMappingKeyStart '?' contained | |
105 | |
106 execute 'syn match yamlFlowMappingKey /'.s:ns_plain_in.'\ze\s*:/ contained '. | |
107 \'nextgroup=yamlKeyValueDelimiter' | |
108 syn match yamlFlowMappingMerge /<<\ze\s*:/ contained nextgroup=yamlKeyValueDelimiter | |
109 | |
110 syn match yamlBlockCollectionItemStart '^\s*\zs-\%(\s\+-\)*\s' nextgroup=yamlBlockMappingKey,yamlBlockMappingMerge | |
111 execute 'syn match yamlBlockMappingKey /^\s*\zs'.s:ns_plain_out.'\ze\s*:\%(\s\|$\)/ '. | |
112 \'nextgroup=yamlKeyValueDelimiter' | |
113 execute 'syn match yamlBlockMappingKey /\s*\zs'.s:ns_plain_out.'\ze\s*:\%(\s\|$\)/ contained '. | |
114 \'nextgroup=yamlKeyValueDelimiter' | |
115 syn match yamlBlockMappingMerge /^\s*\zs<<\ze:\%(\s\|$\)/ nextgroup=yamlKeyValueDelimiter | |
116 syn match yamlBlockMappingMerge /<<\ze\s*:\%(\s\|$\)/ nextgroup=yamlKeyValueDelimiter contained | |
7 | 117 |
2581 | 118 syn match yamlKeyValueDelimiter /\s*:/ contained |
119 syn match yamlKeyValueDelimiter /\s*:/ contained | |
120 | |
121 syn keyword yamlConstant true True TRUE false False FALSE | |
122 syn keyword yamlConstant null Null NULL | |
123 syn match yamlConstant '\<\~\>' | |
124 | |
125 syn match yamlTimestamp /\%([\[\]{}, \t]\@!\p\)\@<!\%(\d\{4}-\d\d\=-\d\d\=\%(\%([Tt]\|\s\+\)\%(\d\d\=\):\%(\d\d\):\%(\d\d\)\%(\.\%(\d*\)\)\=\%(\s*\%(Z\|[+-]\d\d\=\%(:\d\d\)\=\)\)\=\)\=\)\%([\[\]{}, \t]\@!\p\)\@!/ | |
126 | |
2608
7d8af31066c8
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2581
diff
changeset
|
127 syn match yamlInteger /\%([\[\]{}, \t]\@!\p\)\@<!\%([+-]\=\%(0\%(b[0-1_]\+\|[0-7_]\+\|x[0-9a-fA-F_]\+\)\=\|\%([1-9][0-9_]*\%(:[0-5]\=\d\)\+\)\)\|[1-9][0-9_]*\)\%([\[\]{}, \t]\@!\p\)\@!/ |
2581 | 128 syn match yamlFloat /\%([\[\]{}, \t]\@!\p\)\@<!\%([+-]\=\%(\%(\d[0-9_]*\)\.[0-9_]*\%([eE][+-]\d\+\)\=\|\.[0-9_]\+\%([eE][-+][0-9]\+\)\=\|\d[0-9_]*\%(:[0-5]\=\d\)\+\.[0-9_]*\|\.\%(inf\|Inf\|INF\)\)\|\%(\.\%(nan\|NaN\|NAN\)\)\)\%([\[\]{}, \t]\@!\p\)\@!/ |
7 | 129 |
2581 | 130 execute 'syn match yamlNodeTag '.string(s:c_ns_tag_property) |
131 execute 'syn match yamlAnchor '.string(s:c_ns_anchor_property) | |
132 execute 'syn match yamlAlias '.string(s:c_ns_alias_node) | |
133 | |
134 syn match yamlDocumentStart '^---\ze\%(\s\|$\)' | |
135 syn match yamlDocumentEnd '^\.\.\.\ze\%(\s\|$\)' | |
7 | 136 |
2581 | 137 hi def link yamlTodo Todo |
138 hi def link yamlComment Comment | |
139 | |
140 hi def link yamlDocumentStart PreProc | |
141 hi def link yamlDocumentEnd PreProc | |
7 | 142 |
2581 | 143 hi def link yamlDirectiveName Keyword |
7 | 144 |
2581 | 145 hi def link yamlTAGDirective yamlDirectiveName |
146 hi def link yamlTagHandle String | |
147 hi def link yamlTagPrefix String | |
7 | 148 |
2581 | 149 hi def link yamlYAMLDirective yamlDirectiveName |
150 hi def link yamlReservedDirective Error | |
151 hi def link yamlYAMLVersion Number | |
152 | |
153 hi def link yamlString String | |
154 hi def link yamlFlowString yamlString | |
155 hi def link yamlFlowStringDelimiter yamlString | |
156 hi def link yamlEscape SpecialChar | |
157 hi def link yamlSingleEscape SpecialChar | |
158 | |
159 hi def link yamlBlockCollectionItemStart Label | |
160 hi def link yamlBlockMappingKey Identifier | |
161 hi def link yamlBlockMappingMerge Special | |
162 | |
163 hi def link yamlFlowMappingKey Identifier | |
164 hi def link yamlFlowMappingMerge Special | |
165 | |
166 hi def link yamlMappingKeyStart Special | |
167 hi def link yamlFlowIndicator Special | |
168 hi def link yamlKeyValueDelimiter Special | |
169 | |
170 hi def link yamlConstant Constant | |
171 | |
172 hi def link yamlAnchor Type | |
173 hi def link yamlAlias Type | |
174 hi def link yamlNodeTag Type | |
175 | |
176 hi def link yamlInteger Number | |
177 hi def link yamlFloat Float | |
178 hi def link yamlTimestamp Number | |
7 | 179 |
180 let b:current_syntax = "yaml" | |
181 | |
2581 | 182 unlet s:ns_word_char s:ns_uri_char s:c_verbatim_tag s:c_named_tag_handle s:c_secondary_tag_handle s:c_primary_tag_handle s:c_tag_handle s:ns_tag_char s:c_ns_shorthand_tag s:c_non_specific_tag s:c_ns_tag_property s:c_ns_anchor_char s:c_ns_anchor_name s:c_ns_anchor_property s:c_ns_alias_node s:ns_char s:ns_directive_name s:ns_local_tag_prefix s:ns_global_tag_prefix s:ns_tag_prefix s:c_indicator s:ns_plain_safe_out s:c_flow_indicator s:ns_plain_safe_in s:ns_plain_first_in s:ns_plain_first_out s:ns_plain_char_in s:ns_plain_char_out s:ns_plain_out s:ns_plain_in |
183 | |
375 | 184 let &cpo = s:cpo_save |
185 unlet s:cpo_save | |
2581 | 186 |