Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1 | " Vim syntax file |
| 2 | " Language: MOO |
| 3 | " Maintainer: Timo Frenay <timo@frenay.net> |
Bram Moolenaar | cb80aa2 | 2020-10-26 21:12:46 +0100 | [diff] [blame] | 4 | " Last Change: 2020 Oct 19 |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 5 | " Note: Requires Vim 6.0 or above |
| 6 | |
Bram Moolenaar | 89bcfda | 2016-08-30 23:26:57 +0200 | [diff] [blame] | 7 | " quit when a syntax file was already loaded |
| 8 | if exists("b:current_syntax") |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 9 | finish |
| 10 | endif |
| 11 | |
| 12 | " Initializations |
| 13 | syn case ignore |
| 14 | |
| 15 | " C-style comments |
| 16 | syn match mooUncommentedError display ~\*/~ |
| 17 | syn match mooCStyleCommentError display ~/\ze\*~ contained |
| 18 | syn region mooCStyleComment matchgroup=mooComment start=~/\*~ end=~\*/~ contains=mooCStyleCommentError |
| 19 | |
| 20 | " Statements |
| 21 | if exists("moo_extended_cstyle_comments") |
| 22 | syn match mooIdentifier display ~\%(\%(/\*.\{-}\*/\s*\)*\)\@>\<\h\w*\>~ contained transparent contains=mooCStyleComment,@mooKeyword,mooType,mooVariable |
| 23 | else |
| 24 | syn match mooIdentifier display ~\<\h\w*\>~ contained transparent contains=@mooKeyword,mooType,mooVariable |
| 25 | endif |
| 26 | syn keyword mooStatement break continue else elseif endfor endfork endif endtry endwhile finally for if try |
| 27 | syn keyword mooStatement except fork while nextgroup=mooIdentifier skipwhite |
| 28 | syn keyword mooStatement return nextgroup=mooString skipwhite |
| 29 | |
| 30 | " Operators |
| 31 | syn keyword mooOperatorIn in |
| 32 | |
| 33 | " Error constants |
| 34 | syn keyword mooAny ANY |
| 35 | syn keyword mooErrorConstant E_ARGS E_INVARG E_DIV E_FLOAT E_INVIND E_MAXREC E_NACC E_NONE E_PERM E_PROPNF E_QUOTA E_RANGE E_RECMOVE E_TYPE E_VARNF E_VERBNF |
| 36 | |
| 37 | " Builtin variables |
| 38 | syn match mooType display ~\<\%(ERR\|FLOAT\|INT\|LIST\|NUM\|OBJ\|STR\)\>~ |
| 39 | syn match mooVariable display ~\<\%(args\%(tr\)\=\|caller\|dobj\%(str\)\=\|iobj\%(str\)\=\|player\|prepstr\|this\|verb\)\>~ |
| 40 | |
| 41 | " Strings |
| 42 | syn match mooStringError display ~[^\t -[\]-~]~ contained |
| 43 | syn match mooStringSpecialChar display ~\\["\\]~ contained |
| 44 | if !exists("moo_no_regexp") |
| 45 | " Regular expressions |
| 46 | syn match mooRegexp display ~%%~ contained containedin=mooString,mooRegexpParentheses transparent contains=NONE |
| 47 | syn region mooRegexpParentheses display matchgroup=mooRegexpOr start=~%(~ skip=~%%~ end=~%)~ contained containedin=mooString,mooRegexpParentheses transparent oneline |
| 48 | syn match mooRegexpOr display ~%|~ contained containedin=mooString,mooRegexpParentheses |
| 49 | endif |
| 50 | if !exists("moo_no_pronoun_sub") |
| 51 | " Pronoun substitutions |
| 52 | syn match mooPronounSub display ~%%~ contained containedin=mooString transparent contains=NONE |
| 53 | syn match mooPronounSub display ~%[#dilnopqrst]~ contained containedin=mooString |
| 54 | syn match mooPronounSub display ~%\[#[dilnt]\]~ contained containedin=mooString |
| 55 | syn match mooPronounSub display ~%(\h\w*)~ contained containedin=mooString |
| 56 | syn match mooPronounSub display ~%\[[dilnt]\h\w*\]~ contained containedin=mooString |
| 57 | syn match mooPronounSub display ~%<\%([dilnt]:\)\=\a\+>~ contained containedin=mooString |
| 58 | endif |
| 59 | if exists("moo_unmatched_quotes") |
| 60 | syn region mooString matchgroup=mooStringError start=~"~ end=~$~ contains=@mooStringContents keepend |
| 61 | syn region mooString start=~"~ skip=~\\.~ end=~"~ contains=@mooStringContents oneline keepend |
| 62 | else |
| 63 | syn region mooString start=~"~ skip=~\\.~ end=~"\|$~ contains=@mooStringContents keepend |
| 64 | endif |
| 65 | |
| 66 | " Numbers and object numbers |
| 67 | syn match mooNumber display ~\%(\%(\<\d\+\)\=\.\d\+\|\<\d\+\)\%(e[+\-]\=\d\+\)\=\>~ |
| 68 | syn match mooObject display ~#-\=\d\+\>~ |
| 69 | |
| 70 | " Properties and verbs |
| 71 | if exists("moo_builtin_properties") |
| 72 | "Builtin properties |
| 73 | syn keyword mooBuiltinProperty contents f location name owner programmer r w wizard contained containedin=mooPropRef |
| 74 | endif |
| 75 | if exists("moo_extended_cstyle_comments") |
| 76 | syn match mooPropRef display ~\.\s*\%(\%(/\*.\{-}\*/\s*\)*\)\@>\h\w*\>~ transparent contains=mooCStyleComment,@mooKeyword |
| 77 | syn match mooVerbRef display ~:\s*\%(\%(/\*.\{-}\*/\s*\)*\)\@>\h\w*\>~ transparent contains=mooCStyleComment,@mooKeyword |
| 78 | else |
| 79 | syn match mooPropRef display ~\.\s*\h\w*\>~ transparent contains=@mooKeyword |
| 80 | syn match mooVerbRef display ~:\s*\h\w*\>~ transparent contains=@mooKeyword |
| 81 | endif |
| 82 | |
| 83 | " Builtin functions, core properties and core verbs |
| 84 | if exists("moo_extended_cstyle_comments") |
| 85 | syn match mooBuiltinFunction display ~\<\h\w*\s*\%(\%(/\*.\{-}\*/\s*\)*\)\@>\ze(~ contains=mooCStyleComment |
| 86 | syn match mooCorePropOrVerb display ~\$\s*\%(\%(/\*.\{-}\*/\s*\)*\)\@>\%(in\>\)\@!\h\w*\>~ contains=mooCStyleComment,@mooKeyword |
| 87 | else |
| 88 | syn match mooBuiltinFunction display ~\<\h\w*\s*\ze(~ contains=NONE |
| 89 | syn match mooCorePropOrVerb display ~\$\s*\%(in\>\)\@!\h\w*\>~ contains=@mooKeyword |
| 90 | endif |
| 91 | if exists("moo_unknown_builtin_functions") |
| 92 | syn match mooUnknownBuiltinFunction ~\<\h\w*\>~ contained containedin=mooBuiltinFunction contains=mooKnownBuiltinFunction |
| 93 | " Known builtin functions as of version 1.8.1 of the server |
| 94 | " Add your own extensions to this group if you like |
| 95 | syn keyword mooKnownBuiltinFunction abs acos add_property add_verb asin atan binary_hash boot_player buffered_output_length callers caller_perms call_function ceil children chparent clear_property connected_players connected_seconds connection_name connection_option connection_options cos cosh create crypt ctime db_disk_size decode_binary delete_property delete_verb disassemble dump_database encode_binary equal eval exp floatstr floor flush_input force_input function_info idle_seconds index is_clear_property is_member is_player kill_task length listappend listdelete listen listeners listinsert listset log log10 match max max_object memory_usage min move notify object_bytes open_network_connection output_delimiters parent pass players properties property_info queued_tasks queue_info raise random read recycle renumber reset_max_object resume rindex rmatch seconds_left server_log server_version setadd setremove set_connection_option set_player_flag set_property_info set_task_perms set_verb_args set_verb_code set_verb_info shutdown sin sinh sqrt strcmp string_hash strsub substitute suspend tan tanh task_id task_stack ticks_left time tofloat toint toliteral tonum toobj tostr trunc typeof unlisten valid value_bytes value_hash verbs verb_args verb_code verb_info contained |
| 96 | endif |
| 97 | |
Bram Moolenaar | cb80aa2 | 2020-10-26 21:12:46 +0100 | [diff] [blame] | 98 | " Enclosed expressions |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 99 | syn match mooUnenclosedError display ~[')\]|}]~ |
| 100 | syn match mooParenthesesError display ~[';\]|}]~ contained |
| 101 | syn region mooParentheses start=~(~ end=~)~ transparent contains=@mooEnclosedContents,mooParenthesesError |
| 102 | syn match mooBracketsError display ~[');|}]~ contained |
| 103 | syn region mooBrackets start=~\[~ end=~\]~ transparent contains=@mooEnclosedContents,mooBracketsError |
| 104 | syn match mooBracesError display ~[');\]|]~ contained |
| 105 | syn region mooBraces start=~{~ end=~}~ transparent contains=@mooEnclosedContents,mooBracesError |
| 106 | syn match mooQuestionError display ~[');\]}]~ contained |
| 107 | syn region mooQuestion start=~?~ end=~|~ transparent contains=@mooEnclosedContents,mooQuestionError |
| 108 | syn match mooCatchError display ~[);\]|}]~ contained |
| 109 | syn region mooCatch matchgroup=mooExclamation start=~`~ end=~'~ transparent contains=@mooEnclosedContents,mooCatchError,mooExclamation |
| 110 | if exists("moo_extended_cstyle_comments") |
| 111 | syn match mooExclamation display ~[\t !%&(*+,\-/<=>?@[^`{|]\@<!\s*\%(\%(/\*.\{-}\*/\s*\)*\)\@>!=\@!~ contained contains=mooCStyleComment |
| 112 | else |
| 113 | syn match mooExclamation display ~[\t !%&(*+,\-/<=>?@[^`{|]\@<!\s*!=\@!~ contained |
| 114 | endif |
| 115 | |
| 116 | " Comments |
| 117 | syn match mooCommentSpecialChar display ~\\["\\]~ contained transparent contains=NONE |
| 118 | syn match mooComment ~[\t !%&*+,\-/<=>?@^|]\@<!\s*"\([^\"]\|\\.\)*"\s*;~ contains=mooStringError,mooCommentSpecialChar |
| 119 | |
| 120 | " Non-code |
| 121 | syn region mooNonCode start=~^\s*@\<~ end=~$~ |
| 122 | syn match mooNonCode display ~^\.$~ |
| 123 | syn match mooNonCode display ~^\s*\d\+:~he=e-1 |
| 124 | |
| 125 | " Overriding matches |
| 126 | syn match mooRangeOperator display ~\.\.~ transparent contains=NONE |
| 127 | syn match mooOrOperator display ~||~ transparent contains=NONE |
| 128 | if exists("moo_extended_cstyle_comments") |
| 129 | syn match mooScattering ~[,{]\@<=\s*\%(\%(/\*.\{-}\*/\s*\)*\)\@>?~ transparent contains=mooCStyleComment |
| 130 | else |
| 131 | syn match mooScattering ~[,{]\@<=\s*?~ transparent contains=NONE |
| 132 | endif |
| 133 | |
| 134 | " Clusters |
| 135 | syn cluster mooKeyword contains=mooStatement,mooOperatorIn,mooAny,mooErrorConstant |
| 136 | syn cluster mooStringContents contains=mooStringError,mooStringSpecialChar |
| 137 | syn cluster mooEnclosedContents contains=TOP,mooUnenclosedError,mooComment,mooNonCode |
| 138 | |
| 139 | " Define the default highlighting. |
| 140 | hi def link mooUncommentedError Error |
| 141 | hi def link mooCStyleCommentError Error |
| 142 | hi def link mooCStyleComment Comment |
| 143 | hi def link mooStatement Statement |
| 144 | hi def link mooOperatorIn Operator |
| 145 | hi def link mooAny Constant " link this to Keyword if you want |
| 146 | hi def link mooErrorConstant Constant |
| 147 | hi def link mooType Type |
| 148 | hi def link mooVariable Type |
| 149 | hi def link mooStringError Error |
| 150 | hi def link mooStringSpecialChar SpecialChar |
| 151 | hi def link mooRegexpOr SpecialChar |
| 152 | hi def link mooPronounSub SpecialChar |
| 153 | hi def link mooString String |
| 154 | hi def link mooNumber Number |
| 155 | hi def link mooObject Number |
| 156 | hi def link mooBuiltinProperty Type |
| 157 | hi def link mooBuiltinFunction Function |
| 158 | hi def link mooUnknownBuiltinFunction Error |
| 159 | hi def link mooKnownBuiltinFunction Function |
| 160 | hi def link mooCorePropOrVerb Identifier |
| 161 | hi def link mooUnenclosedError Error |
| 162 | hi def link mooParenthesesError Error |
| 163 | hi def link mooBracketsError Error |
| 164 | hi def link mooBracesError Error |
| 165 | hi def link mooQuestionError Error |
| 166 | hi def link mooCatchError Error |
| 167 | hi def link mooExclamation Exception |
| 168 | hi def link mooComment Comment |
| 169 | hi def link mooNonCode PreProc |
| 170 | |
| 171 | let b:current_syntax = "moo" |
| 172 | |
| 173 | " vim: ts=8 |