diff options
author | Bram Moolenaar <Bram@vim.org> | 2012-01-20 21:08:56 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2012-01-20 21:08:56 +0100 |
commit | 6be7f8733f34333ed75f6e39425d73a6b2644379 (patch) | |
tree | 59ae0f289e6bfaaf3ed2e8ac5dcedb69e5656c01 /runtime/syntax/erlang.vim | |
parent | 90b280059fd51790105ff2e433303be58d58c430 (diff) | |
download | vim-git-6be7f8733f34333ed75f6e39425d73a6b2644379.tar.gz |
Update runtime files.
Diffstat (limited to 'runtime/syntax/erlang.vim')
-rw-r--r-- | runtime/syntax/erlang.vim | 341 |
1 files changed, 119 insertions, 222 deletions
diff --git a/runtime/syntax/erlang.vim b/runtime/syntax/erlang.vim index 2f39d6143..28bc4a5d3 100644 --- a/runtime/syntax/erlang.vim +++ b/runtime/syntax/erlang.vim @@ -1,229 +1,126 @@ " Vim syntax file -" Language: erlang (ERicsson LANGuage) -" http://www.erlang.se -" http://www.erlang.org -" Maintainer: Csaba Hoch <csaba.hoch@gmail.com> -" Former Maintainer: KreÄ…imir Marľić (Kresimir Marzic) <kmarzic@fly.srk.fer.hr> -" Last update: 12-Mar-2008 -" Filenames: .erl - - -" There are three sets of highlighting in here: -" One is "erlang_characters", second is "erlang_functions" and third -" is "erlang_keywords". -" If you want to disable keywords highlighting, put in your .vimrc: -" let erlang_keywords=1 -" If you want to disable erlang BIF highlighting, put in your .vimrc -" this: -" let erlang_functions=1 -" If you want to disable special characters highlighting, put in -" your .vimrc: -" let erlang_characters=1 - - -" For version 5.x: Clear all syntax items -" For version 6.x: Quit when a syntax file was already loaded -if version < 600 - syntax clear -elseif exists ("b:current_syntax") - finish +" Language: Erlang +" Author: Oscar Hellström <oscar@oscarh.net> (http://oscar.hellstrom.st) +" Contributors: Ricardo Catalinas Jiménez <jimenezrick@gmail.com> +" License: Vim license +" Version: 2011/09/11 + +if exists("b:current_syntax") + finish +else + let b:current_syntax = "erlang" endif - -" Case sensitive -syn case match - - -if ! exists ("erlang_characters") - - " Basic elements - syn match erlangComment "%.*$" contains=erlangAnnotation,erlangTodo - 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 - syn match erlangAnnotation "`[^']*'" contained - syn keyword erlangTodo TODO FIXME XXX contained - syn match erlangModifier "\~\a\|\\\a\|\\\\" contained - syn match erlangSpecialCharacter ":\|_\|@\|\\\|\"\|\." - syn match erlangSeparator "(\|)\|{\|}\|\[\|]\||\|||\|;\|,\|?\|->\|#" contained - syn region erlangString start=+"+ skip=+\\.+ end=+"+ contains=erlangModifier - syn region erlangAtom start=+'+ skip=+\\'+ end=+'+ - - " Operators - syn match erlangOperator "+\|-\|\*\|\/" - syn keyword erlangOperator div rem or xor bor bxor bsl bsr - syn keyword erlangOperator and band not bnot andalso orelse - syn match erlangOperator "==\|/=\|=:=\|=/=\|<\|=<\|>\|>=" - syn match erlangOperator "++\|--\|=\|!\|<-" - - " Numbers - syn match erlangNumberInteger "\d\+" contains=erlangSeparator - syn match erlangNumberFloat1 "\d\+\.\d\+" contains=erlangSeparator - syn match erlangNumberFloat2 "\d\+\(\.\d\+\)\=[eE][+-]\=\d\+\(\.\d\+\)\=" contains=erlangSeparator - syn match erlangNumberFloat3 "\d\+[#]\x\+" contains=erlangSeparator - syn match erlangNumberHex "$\x\+" contains=erlangSeparator - - " Ignore '_' and '-' in words - syn match erlangWord "\h\+\w*" - - syn match erlangChar /\$./ +if !exists("g:erlang_highlight_bif") + let g:erlang_highlight_bif = 1 endif -if ! exists ("erlang_functions") - " Functions call - syn match erlangFCall "\%(\w\+\s*\.\s*\)*\w\+\s*[:@]\s*\w\+" - - " build-in-functions (BIFs) - syn keyword erlangBIF abs alive apply atom_to_list - syn keyword erlangBIF binary_to_list binary_to_term - syn keyword erlangBIF concat_binary - syn keyword erlangBIF date disconnect_node - syn keyword erlangBIF element erase exit - syn keyword erlangBIF float float_to_list - syn keyword erlangBIF get get_keys group_leader - syn keyword erlangBIF halt hd - syn keyword erlangBIF integer_to_list is_alive - syn keyword erlangBIF length link list_to_atom list_to_binary - syn keyword erlangBIF list_to_float list_to_integer list_to_pid - syn keyword erlangBIF list_to_tuple load_module - syn keyword erlangBIF make_ref monitor_node - syn keyword erlangBIF node nodes now - syn keyword erlangBIF open_port - syn keyword erlangBIF pid_to_list process_flag - syn keyword erlangBIF process_info process put - syn keyword erlangBIF register registered round - syn keyword erlangBIF self setelement size spawn - syn keyword erlangBIF spawn_link split_binary statistics - syn keyword erlangBIF term_to_binary throw time tl trunc - syn keyword erlangBIF tuple_to_list - syn keyword erlangBIF unlink unregister - syn keyword erlangBIF whereis - - " Other BIFs - syn keyword erlangBIF atom binary constant function integer - syn keyword erlangBIF list number pid ports port_close port_info - syn keyword erlangBIF reference record - - " erlang:BIFs - syn keyword erlangBIF check_process_code delete_module - syn keyword erlangBIF get_cookie hash math module_loaded - syn keyword erlangBIF preloaded processes purge_module set_cookie - syn keyword erlangBIF set_node - - " functions of math library - syn keyword erlangFunction acos asin atan atan2 cos cosh exp - syn keyword erlangFunction log log10 pi pow power sin sinh sqrt - syn keyword erlangFunction tan tanh - - " Other functions - syn keyword erlangFunction call module_info parse_transform - syn keyword erlangFunction undefined_function - - " Modules - syn keyword erlangModule error_handler -endif - -if ! exists ("erlang_keywords") - " Constants and Directives - syn match erlangDirective "-behaviour\|-behavior" - syn match erlangDirective "-compile\|-define\|-else\|-endif\|-export\|-file" - syn match erlangDirective "-ifdef\|-ifndef\|-import\|-include_lib\|-include" - syn match erlangDirective "-module\|-record\|-undef" - - syn match erlangConstant "-author\|-copyright\|-doc\|-vsn" - - " Keywords - syn keyword erlangKeyword after begin case catch - syn keyword erlangKeyword cond end fun if - syn keyword erlangKeyword let of query receive - syn keyword erlangKeyword when - syn keyword erlangKeyword try - - " Processes - syn keyword erlangProcess creation current_function dictionary - syn keyword erlangProcess group_leader heap_size high initial_call - syn keyword erlangProcess linked low memory_in_use message_queue - syn keyword erlangProcess net_kernel node normal priority - syn keyword erlangProcess reductions registered_name runnable - syn keyword erlangProcess running stack_trace status timer - syn keyword erlangProcess trap_exit waiting - - " Ports - syn keyword erlangPort command count_in count_out creation in - syn keyword erlangPort in_format linked node out owner packeting - - " Nodes - syn keyword erlangNode atom_tables communicating creation - syn keyword erlangNode current_gc current_reductions current_runtime - syn keyword erlangNode current_wall_clock distribution_port - syn keyword erlangNode entry_points error_handler friends - syn keyword erlangNode garbage_collection magic_cookie magic_cookies - syn keyword erlangNode module_table monitored_nodes name next_ref - syn keyword erlangNode ports preloaded processes reductions - syn keyword erlangNode ref_state registry runtime wall_clock - - " Reserved - syn keyword erlangReserved apply_lambda module_info module_lambdas - syn keyword erlangReserved record record_index record_info - - " Extras - syn keyword erlangExtra badarg nocookie false fun true - - " Signals - syn keyword erlangSignal badsig kill killed exit normal -endif - - +" Erlang is case sensitive +syn case match -" Define the default highlighting. -" 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_erlang_inits") - if version < 508 - let did_erlang_inits = 1 - command -nargs=+ HiLink hi link <args> - else - command -nargs=+ HiLink hi def link <args> - endif - - " erlang_characters - HiLink erlangComment Comment - HiLink erlangAnnotation Special - HiLink erlangTodo Todo - HiLink erlangSpecialCharacter Special - HiLink erlangSeparator Normal - HiLink erlangModifier Special - HiLink erlangOperator Operator - HiLink erlangString String - HiLink erlangAtom Type - - HiLink erlangNumberInteger Number - HiLink erlangNumberFloat1 Float - HiLink erlangNumberFloat2 Float - HiLink erlangNumberFloat3 Float - HiLink erlangNumberFloat4 Float - HiLink erlangNumberHex Number - - HiLink erlangWord Normal - - " erlang_functions - HiLink erlangFCall Function - HiLink erlangBIF Function - HiLink erlangFunction Function - HiLink erlangModuleFunction Function - - " erlang_keywords - HiLink erlangDirective Type - HiLink erlangConstant Type - HiLink erlangKeyword Keyword - HiLink erlangProcess Special - HiLink erlangPort Special - HiLink erlangNode Special - HiLink erlangReserved Statement - HiLink erlangExtra Statement - HiLink erlangSignal Statement - - delcommand HiLink +" Match groups +syn match erlangStringModifier /\\./ contained +syn match erlangStringModifier /\~\%(-\?[0-9*]\+\)\?\%(\.[0-9*]\+\..\?\)\?\%(c\|f\|e\|g\|s\|w\|p\|W\|P\|B\|X\|#\|b\|+\|n\|i\)/ contained +syn match erlangModifier /\$\\\?./ + +syn match erlangInteger /\<\%([0-9]\+#[0-9a-fA-F]\+\|[0-9]\+\)\>/ +syn match erlangFloat /\<[0-9]\+\.[0-9]\+\%(e-\?[0-9]\+\)\?\>/ + +syn keyword erlangTodo TODO FIXME XXX contained +syn match erlangComment /%.*$/ contains=@Spell,erlangTodo,erlangAnnotation +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 +syn match erlangAnnotation /`[^']\+'/ contained + +syn keyword erlangKeyword band bor bnot bsl bsr bxor div rem xor +syn keyword erlangKeyword try catch begin receive after cond fun let query + +syn keyword erlangConditional case if of end +syn keyword erlangConditional not and or andalso orelse +syn keyword erlangConditional when + +syn keyword erlangBoolean true false + +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 + +syn match erlangOperator /\/\|*\|+\|-\|++\|--/ +syn match erlangOperator /->\|<-\|||\||\|!\|=/ +syn match erlangOperator /=:=\|==\|\/=\|=\/=\|<\|>\|=<\|>=/ +syn keyword erlangOperator div rem + +syn region erlangString start=/"/ end=/"/ skip=/\\/ contains=@Spell,erlangStringModifier + +syn match erlangVariable /\<[A-Z_]\w*\>/ +syn match erlangAtom /\%(\%(^-\)\|#\)\@<!\<[a-z][A-Za-z0-9_]*\>\%(\s*[(:]\)\@!/ +syn match erlangAtom /\\\@<!'[^']*\\\@<!'/ + +syn match erlangRecord /#\w\+/ + +syn match erlangTuple /{\|}/ +syn match erlangList /\[\|\]/ + +syn match erlangAttribute /^-\%(vsn\|author\|copyright\|compile\|deprecated\|module\|export\|import\|behaviour\|behavior\|export_type\|ignore_xref\|on_load\)\s*(\@=/ +syn match erlangInclude /^-include\%(_lib\)\?\s*(\@=/ +syn match erlangRecordDef /^-record\s*(\@=/ +syn match erlangDefine /^-\%(define\|undef\)\s*(\@=/ +syn match erlangPreCondit /^-\%(ifdef\|ifndef\|else\|endif\)\%(\s*(\@=\)\?/ + +syn match erlangType /^-\%(spec\|type\)[( ]\@=/ + +syn match erlangMacro /\%(-define(\)\@<=\w\+/ +syn match erlangMacro /?\??\w\+/ + +syn match erlangBitType /\%(\/\|-\)\@<=\%(bits\|bitstring\|binary\|integer\|float\|unit\)\>/ +syn match erlangBitSize /:\@<=[0-9]\+/ + +syn match erlangBinary /<<\|>>/ + +" BIFs +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]\)\@=/ +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\)(\@=/ +syn match erlangGBIF /erlang\%(:\w\)\@=/ + +" Link Erlang stuff to Vim groups +hi link erlangTodo Todo +hi link erlangString String +hi link erlangNoSpellString String +hi link erlangModifier SpecialChar +hi link erlangStringModifier SpecialChar +hi link erlangComment Comment +hi link erlangAnnotation Special +hi link erlangVariable Identifier +hi link erlangInclude Include +hi link erlangRecordDef Keyword +hi link erlangAttribute Keyword +hi link erlangKeyword Keyword +hi link erlangMacro Macro +hi link erlangDefine Define +hi link erlangPreCondit PreCondit +hi link erlangPreProc PreProc +hi link erlangDelimiter Delimiter +hi link erlangBitDelimiter Normal +hi link erlangOperator Operator +hi link erlangConditional Conditional +hi link erlangGuard Conditional +hi link erlangBoolean Boolean +hi link erlangAtom Constant +hi link erlangRecord Structure +hi link erlangInteger Number +hi link erlangFloat Number +hi link erlangFloat Number +hi link erlangFloat Number +hi link erlangFloat Number +hi link erlangHex Number +hi link erlangFun Keyword +hi link erlangList Delimiter +hi link erlangTuple Delimiter +hi link erlangBinary Keyword +hi link erlangBitVariable Identifier +hi link erlangBitType Type +hi link erlangType Type +hi link erlangBitSize Number + +" Optional highlighting +if g:erlang_highlight_bif + hi link erlangBIF Keyword + hi link erlangGBIF Keyword endif - - -let b:current_syntax = "erlang" - |