Mercurial > vim
comparison runtime/syntax/erlang.vim @ 3281:af1e8a1714c2
Update runtime files.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Fri, 20 Jan 2012 21:08:56 +0100 |
parents | 7bc41231fbc7 |
children | eb6ab7e78925 |
comparison
equal
deleted
inserted
replaced
3280:aa265b7165cc | 3281:af1e8a1714c2 |
---|---|
1 " Vim syntax file | 1 " Vim syntax file |
2 " Language: erlang (ERicsson LANGuage) | 2 " Language: Erlang |
3 " http://www.erlang.se | 3 " Author: Oscar Hellström <oscar@oscarh.net> (http://oscar.hellstrom.st) |
4 " http://www.erlang.org | 4 " Contributors: Ricardo Catalinas Jiménez <jimenezrick@gmail.com> |
5 " Maintainer: Csaba Hoch <csaba.hoch@gmail.com> | 5 " License: Vim license |
6 " Former Maintainer: Kreąimir Marľić (Kresimir Marzic) <kmarzic@fly.srk.fer.hr> | 6 " Version: 2011/09/11 |
7 " Last update: 12-Mar-2008 | |
8 " Filenames: .erl | |
9 | 7 |
10 | 8 if exists("b:current_syntax") |
11 " There are three sets of highlighting in here: | 9 finish |
12 " One is "erlang_characters", second is "erlang_functions" and third | 10 else |
13 " is "erlang_keywords". | 11 let b:current_syntax = "erlang" |
14 " If you want to disable keywords highlighting, put in your .vimrc: | |
15 " let erlang_keywords=1 | |
16 " If you want to disable erlang BIF highlighting, put in your .vimrc | |
17 " this: | |
18 " let erlang_functions=1 | |
19 " If you want to disable special characters highlighting, put in | |
20 " your .vimrc: | |
21 " let erlang_characters=1 | |
22 | |
23 | |
24 " For version 5.x: Clear all syntax items | |
25 " For version 6.x: Quit when a syntax file was already loaded | |
26 if version < 600 | |
27 syntax clear | |
28 elseif exists ("b:current_syntax") | |
29 finish | |
30 endif | 12 endif |
31 | 13 |
14 if !exists("g:erlang_highlight_bif") | |
15 let g:erlang_highlight_bif = 1 | |
16 endif | |
32 | 17 |
33 " Case sensitive | 18 " Erlang is case sensitive |
34 syn case match | 19 syn case match |
35 | 20 |
21 " Match groups | |
22 syn match erlangStringModifier /\\./ contained | |
23 syn match erlangStringModifier /\~\%(-\?[0-9*]\+\)\?\%(\.[0-9*]\+\..\?\)\?\%(c\|f\|e\|g\|s\|w\|p\|W\|P\|B\|X\|#\|b\|+\|n\|i\)/ contained | |
24 syn match erlangModifier /\$\\\?./ | |
36 | 25 |
37 if ! exists ("erlang_characters") | 26 syn match erlangInteger /\<\%([0-9]\+#[0-9a-fA-F]\+\|[0-9]\+\)\>/ |
27 syn match erlangFloat /\<[0-9]\+\.[0-9]\+\%(e-\?[0-9]\+\)\?\>/ | |
38 | 28 |
39 " Basic elements | 29 syn keyword erlangTodo TODO FIXME XXX contained |
40 syn match erlangComment "%.*$" contains=erlangAnnotation,erlangTodo | 30 syn match erlangComment /%.*$/ contains=@Spell,erlangTodo,erlangAnnotation |
41 syn match erlangAnnotation " \@<=@\%(clear\|docfile\|end\|headerfile\|todo\|TODO\|type\|author\|copyright\|doc\|reference\|see\|since\|title\|version\|deprecated\|hidden\|private\|equiv\|spec\|throws\)" contained | 31 syn match erlangAnnotation /\%(%\s\)\@<=@\%(author\|clear\|copyright\|deprecated\|doc\|docfile\|end\|equiv\|headerfile\|hidden\|private\|reference\|see\|since\|spec\|throws\|title\|todo\|TODO\|type\|version\)/ contained |
42 syn match erlangAnnotation "`[^']*'" contained | 32 syn match erlangAnnotation /`[^']\+'/ contained |
43 syn keyword erlangTodo TODO FIXME XXX contained | |
44 syn match erlangModifier "\~\a\|\\\a\|\\\\" contained | |
45 syn match erlangSpecialCharacter ":\|_\|@\|\\\|\"\|\." | |
46 syn match erlangSeparator "(\|)\|{\|}\|\[\|]\||\|||\|;\|,\|?\|->\|#" contained | |
47 syn region erlangString start=+"+ skip=+\\.+ end=+"+ contains=erlangModifier | |
48 syn region erlangAtom start=+'+ skip=+\\'+ end=+'+ | |
49 | 33 |
50 " Operators | 34 syn keyword erlangKeyword band bor bnot bsl bsr bxor div rem xor |
51 syn match erlangOperator "+\|-\|\*\|\/" | 35 syn keyword erlangKeyword try catch begin receive after cond fun let query |
52 syn keyword erlangOperator div rem or xor bor bxor bsl bsr | |
53 syn keyword erlangOperator and band not bnot andalso orelse | |
54 syn match erlangOperator "==\|/=\|=:=\|=/=\|<\|=<\|>\|>=" | |
55 syn match erlangOperator "++\|--\|=\|!\|<-" | |
56 | 36 |
57 " Numbers | 37 syn keyword erlangConditional case if of end |
58 syn match erlangNumberInteger "\d\+" contains=erlangSeparator | 38 syn keyword erlangConditional not and or andalso orelse |
59 syn match erlangNumberFloat1 "\d\+\.\d\+" contains=erlangSeparator | 39 syn keyword erlangConditional when |
60 syn match erlangNumberFloat2 "\d\+\(\.\d\+\)\=[eE][+-]\=\d\+\(\.\d\+\)\=" contains=erlangSeparator | |
61 syn match erlangNumberFloat3 "\d\+[#]\x\+" contains=erlangSeparator | |
62 syn match erlangNumberHex "$\x\+" contains=erlangSeparator | |
63 | 40 |
64 " Ignore '_' and '-' in words | 41 syn keyword erlangBoolean true false |
65 syn match erlangWord "\h\+\w*" | |
66 | 42 |
67 syn match erlangChar /\$./ | 43 syn keyword erlangGuard is_list is_alive is_atom is_binary is_bitstring is_boolean is_tuple is_number is_integer is_float is_function is_constant is_pid is_port is_reference is_record is_process_alive |
44 | |
45 syn match erlangOperator /\/\|*\|+\|-\|++\|--/ | |
46 syn match erlangOperator /->\|<-\|||\||\|!\|=/ | |
47 syn match erlangOperator /=:=\|==\|\/=\|=\/=\|<\|>\|=<\|>=/ | |
48 syn keyword erlangOperator div rem | |
49 | |
50 syn region erlangString start=/"/ end=/"/ skip=/\\/ contains=@Spell,erlangStringModifier | |
51 | |
52 syn match erlangVariable /\<[A-Z_]\w*\>/ | |
53 syn match erlangAtom /\%(\%(^-\)\|#\)\@<!\<[a-z][A-Za-z0-9_]*\>\%(\s*[(:]\)\@!/ | |
54 syn match erlangAtom /\\\@<!'[^']*\\\@<!'/ | |
55 | |
56 syn match erlangRecord /#\w\+/ | |
57 | |
58 syn match erlangTuple /{\|}/ | |
59 syn match erlangList /\[\|\]/ | |
60 | |
61 syn match erlangAttribute /^-\%(vsn\|author\|copyright\|compile\|deprecated\|module\|export\|import\|behaviour\|behavior\|export_type\|ignore_xref\|on_load\)\s*(\@=/ | |
62 syn match erlangInclude /^-include\%(_lib\)\?\s*(\@=/ | |
63 syn match erlangRecordDef /^-record\s*(\@=/ | |
64 syn match erlangDefine /^-\%(define\|undef\)\s*(\@=/ | |
65 syn match erlangPreCondit /^-\%(ifdef\|ifndef\|else\|endif\)\%(\s*(\@=\)\?/ | |
66 | |
67 syn match erlangType /^-\%(spec\|type\)[( ]\@=/ | |
68 | |
69 syn match erlangMacro /\%(-define(\)\@<=\w\+/ | |
70 syn match erlangMacro /?\??\w\+/ | |
71 | |
72 syn match erlangBitType /\%(\/\|-\)\@<=\%(bits\|bitstring\|binary\|integer\|float\|unit\)\>/ | |
73 syn match erlangBitSize /:\@<=[0-9]\+/ | |
74 | |
75 syn match erlangBinary /<<\|>>/ | |
76 | |
77 " BIFs | |
78 syn match erlangBIF /\%([^:0-9A-Za-z_]\|\<erlang:\)\@<=\%(abs\|apply\|atom_to_binary\|atom_to_list\|binary_part\|binary_to_atom\|binary_to_existing_atom\|binary_to_list\|binary_to_term\|bit_size\|bitstring_to_list\|byte_size\|check_process_code\|date\|delete_module\|demonitor\|disconnect_node\|element\|erase\|exit\|float\|float_to_list\|garbage_collect\|get\|get_keys\|group_leader\|hd\|integer_to_list\|iolist_size\|iolist_to_binary\|is_alive\|is_atom\|is_binary\|is_bitstring\|is_boolean\|is_float\|is_function\|is_integer\|is_list\|is_number\|is_pid\|is_port\|is_process_alive\|is_record\|is_reference\|is_tuple\|length\|link\|list_to_atom\|list_to_binary\|list_to_bitstring\|list_to_existing_atom\|list_to_float\|list_to_integer\|list_to_pid\|list_to_tuple\|load_module\|make_ref\|max\|min\|module_loaded\|monitor\|monitor_node\|node\|nodes\|now\|open_port\|pid_to_list\|port_close\|port_command\|port_connect\|port_control\|pre_loaded\|processes\|process_flag\|process_info\|purge_module\|put\|register\|registered\|round\|self\|setelement\|size\|spawn\|spawn_link\|spawn_monitor\|spawn_opt\|split_binary\|statistics\|term_to_binary\|time\|tl\|trunc\|tuple_size\|tuple_to_list\|unlink\|unregister\|whereis\)\%((\|\/[0-9]\)\@=/ | |
79 syn match erlangBIF /\<\%(erlang:\)\@<=\%(append_element\|bump_reductions\|cancel_timer\|decode_packet\|display\|function_exported\|fun_info\|fun_to_list\|get_cookie\|get_stacktrace\|hash\|is_builtin\|loaded\|load_nif\|localtime\|localtime_to_universaltime\|make_tuple\|memory\|monitor_node\|phash\|port_call\|port_info\|ports\|port_to_list\|process_display\|read_timer\|ref_to_list\|resume_process\|send\|send_after\|send_nosuspend\|set_cookie\|start_timer\|suspend_process\|system_flag\|system_info\|system_monitor\|system_profile\|trace\|trace_delivered\|trace_info\|trace_pattern\|universaltime\|universaltime_to_localtime\|yield\)(\@=/ | |
80 syn match erlangGBIF /erlang\%(:\w\)\@=/ | |
81 | |
82 " Link Erlang stuff to Vim groups | |
83 hi link erlangTodo Todo | |
84 hi link erlangString String | |
85 hi link erlangNoSpellString String | |
86 hi link erlangModifier SpecialChar | |
87 hi link erlangStringModifier SpecialChar | |
88 hi link erlangComment Comment | |
89 hi link erlangAnnotation Special | |
90 hi link erlangVariable Identifier | |
91 hi link erlangInclude Include | |
92 hi link erlangRecordDef Keyword | |
93 hi link erlangAttribute Keyword | |
94 hi link erlangKeyword Keyword | |
95 hi link erlangMacro Macro | |
96 hi link erlangDefine Define | |
97 hi link erlangPreCondit PreCondit | |
98 hi link erlangPreProc PreProc | |
99 hi link erlangDelimiter Delimiter | |
100 hi link erlangBitDelimiter Normal | |
101 hi link erlangOperator Operator | |
102 hi link erlangConditional Conditional | |
103 hi link erlangGuard Conditional | |
104 hi link erlangBoolean Boolean | |
105 hi link erlangAtom Constant | |
106 hi link erlangRecord Structure | |
107 hi link erlangInteger Number | |
108 hi link erlangFloat Number | |
109 hi link erlangFloat Number | |
110 hi link erlangFloat Number | |
111 hi link erlangFloat Number | |
112 hi link erlangHex Number | |
113 hi link erlangFun Keyword | |
114 hi link erlangList Delimiter | |
115 hi link erlangTuple Delimiter | |
116 hi link erlangBinary Keyword | |
117 hi link erlangBitVariable Identifier | |
118 hi link erlangBitType Type | |
119 hi link erlangType Type | |
120 hi link erlangBitSize Number | |
121 | |
122 " Optional highlighting | |
123 if g:erlang_highlight_bif | |
124 hi link erlangBIF Keyword | |
125 hi link erlangGBIF Keyword | |
68 endif | 126 endif |
69 | |
70 if ! exists ("erlang_functions") | |
71 " Functions call | |
72 syn match erlangFCall "\%(\w\+\s*\.\s*\)*\w\+\s*[:@]\s*\w\+" | |
73 | |
74 " build-in-functions (BIFs) | |
75 syn keyword erlangBIF abs alive apply atom_to_list | |
76 syn keyword erlangBIF binary_to_list binary_to_term | |
77 syn keyword erlangBIF concat_binary | |
78 syn keyword erlangBIF date disconnect_node | |
79 syn keyword erlangBIF element erase exit | |
80 syn keyword erlangBIF float float_to_list | |
81 syn keyword erlangBIF get get_keys group_leader | |
82 syn keyword erlangBIF halt hd | |
83 syn keyword erlangBIF integer_to_list is_alive | |
84 syn keyword erlangBIF length link list_to_atom list_to_binary | |
85 syn keyword erlangBIF list_to_float list_to_integer list_to_pid | |
86 syn keyword erlangBIF list_to_tuple load_module | |
87 syn keyword erlangBIF make_ref monitor_node | |
88 syn keyword erlangBIF node nodes now | |
89 syn keyword erlangBIF open_port | |
90 syn keyword erlangBIF pid_to_list process_flag | |
91 syn keyword erlangBIF process_info process put | |
92 syn keyword erlangBIF register registered round | |
93 syn keyword erlangBIF self setelement size spawn | |
94 syn keyword erlangBIF spawn_link split_binary statistics | |
95 syn keyword erlangBIF term_to_binary throw time tl trunc | |
96 syn keyword erlangBIF tuple_to_list | |
97 syn keyword erlangBIF unlink unregister | |
98 syn keyword erlangBIF whereis | |
99 | |
100 " Other BIFs | |
101 syn keyword erlangBIF atom binary constant function integer | |
102 syn keyword erlangBIF list number pid ports port_close port_info | |
103 syn keyword erlangBIF reference record | |
104 | |
105 " erlang:BIFs | |
106 syn keyword erlangBIF check_process_code delete_module | |
107 syn keyword erlangBIF get_cookie hash math module_loaded | |
108 syn keyword erlangBIF preloaded processes purge_module set_cookie | |
109 syn keyword erlangBIF set_node | |
110 | |
111 " functions of math library | |
112 syn keyword erlangFunction acos asin atan atan2 cos cosh exp | |
113 syn keyword erlangFunction log log10 pi pow power sin sinh sqrt | |
114 syn keyword erlangFunction tan tanh | |
115 | |
116 " Other functions | |
117 syn keyword erlangFunction call module_info parse_transform | |
118 syn keyword erlangFunction undefined_function | |
119 | |
120 " Modules | |
121 syn keyword erlangModule error_handler | |
122 endif | |
123 | |
124 if ! exists ("erlang_keywords") | |
125 " Constants and Directives | |
126 syn match erlangDirective "-behaviour\|-behavior" | |
127 syn match erlangDirective "-compile\|-define\|-else\|-endif\|-export\|-file" | |
128 syn match erlangDirective "-ifdef\|-ifndef\|-import\|-include_lib\|-include" | |
129 syn match erlangDirective "-module\|-record\|-undef" | |
130 | |
131 syn match erlangConstant "-author\|-copyright\|-doc\|-vsn" | |
132 | |
133 " Keywords | |
134 syn keyword erlangKeyword after begin case catch | |
135 syn keyword erlangKeyword cond end fun if | |
136 syn keyword erlangKeyword let of query receive | |
137 syn keyword erlangKeyword when | |
138 syn keyword erlangKeyword try | |
139 | |
140 " Processes | |
141 syn keyword erlangProcess creation current_function dictionary | |
142 syn keyword erlangProcess group_leader heap_size high initial_call | |
143 syn keyword erlangProcess linked low memory_in_use message_queue | |
144 syn keyword erlangProcess net_kernel node normal priority | |
145 syn keyword erlangProcess reductions registered_name runnable | |
146 syn keyword erlangProcess running stack_trace status timer | |
147 syn keyword erlangProcess trap_exit waiting | |
148 | |
149 " Ports | |
150 syn keyword erlangPort command count_in count_out creation in | |
151 syn keyword erlangPort in_format linked node out owner packeting | |
152 | |
153 " Nodes | |
154 syn keyword erlangNode atom_tables communicating creation | |
155 syn keyword erlangNode current_gc current_reductions current_runtime | |
156 syn keyword erlangNode current_wall_clock distribution_port | |
157 syn keyword erlangNode entry_points error_handler friends | |
158 syn keyword erlangNode garbage_collection magic_cookie magic_cookies | |
159 syn keyword erlangNode module_table monitored_nodes name next_ref | |
160 syn keyword erlangNode ports preloaded processes reductions | |
161 syn keyword erlangNode ref_state registry runtime wall_clock | |
162 | |
163 " Reserved | |
164 syn keyword erlangReserved apply_lambda module_info module_lambdas | |
165 syn keyword erlangReserved record record_index record_info | |
166 | |
167 " Extras | |
168 syn keyword erlangExtra badarg nocookie false fun true | |
169 | |
170 " Signals | |
171 syn keyword erlangSignal badsig kill killed exit normal | |
172 endif | |
173 | |
174 | |
175 | |
176 " Define the default highlighting. | |
177 " For version 5.7 and earlier: only when not done already | |
178 " For version 5.8 and later: only when an item doesn't have highlighting yet | |
179 if version >= 508 || !exists ("did_erlang_inits") | |
180 if version < 508 | |
181 let did_erlang_inits = 1 | |
182 command -nargs=+ HiLink hi link <args> | |
183 else | |
184 command -nargs=+ HiLink hi def link <args> | |
185 endif | |
186 | |
187 " erlang_characters | |
188 HiLink erlangComment Comment | |
189 HiLink erlangAnnotation Special | |
190 HiLink erlangTodo Todo | |
191 HiLink erlangSpecialCharacter Special | |
192 HiLink erlangSeparator Normal | |
193 HiLink erlangModifier Special | |
194 HiLink erlangOperator Operator | |
195 HiLink erlangString String | |
196 HiLink erlangAtom Type | |
197 | |
198 HiLink erlangNumberInteger Number | |
199 HiLink erlangNumberFloat1 Float | |
200 HiLink erlangNumberFloat2 Float | |
201 HiLink erlangNumberFloat3 Float | |
202 HiLink erlangNumberFloat4 Float | |
203 HiLink erlangNumberHex Number | |
204 | |
205 HiLink erlangWord Normal | |
206 | |
207 " erlang_functions | |
208 HiLink erlangFCall Function | |
209 HiLink erlangBIF Function | |
210 HiLink erlangFunction Function | |
211 HiLink erlangModuleFunction Function | |
212 | |
213 " erlang_keywords | |
214 HiLink erlangDirective Type | |
215 HiLink erlangConstant Type | |
216 HiLink erlangKeyword Keyword | |
217 HiLink erlangProcess Special | |
218 HiLink erlangPort Special | |
219 HiLink erlangNode Special | |
220 HiLink erlangReserved Statement | |
221 HiLink erlangExtra Statement | |
222 HiLink erlangSignal Statement | |
223 | |
224 delcommand HiLink | |
225 endif | |
226 | |
227 | |
228 let b:current_syntax = "erlang" | |
229 |