Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1 | " Vim syntax file |
Bram Moolenaar | 40962ec | 2018-01-28 22:47:25 +0100 | [diff] [blame] | 2 | " Language: Pike |
| 3 | " Maintainer: Stephen R. van den Berg <srb@cuci.nl> |
| 4 | " Maintainer of previous implementation: Francesco Chemolli <kinkie@kame.usr.dsi.unimi.it> |
| 5 | " Last Change: 2018 Jan 28 |
| 6 | " Version: 2.9 |
| 7 | " Remark: Derived from the C-syntax; fixed several bugs in the C-syntax |
| 8 | " Remark: and extended it with the Pike syntax. |
| 9 | " Remark: Includes a highlighter for all Pike types of parenthesis errors. |
| 10 | " Remark: Includes a highlighter for SQL on multiline strings. |
| 11 | " Remark: Includes a highlighter for any embedded Autodoc format. |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 12 | |
Bram Moolenaar | 40962ec | 2018-01-28 22:47:25 +0100 | [diff] [blame] | 13 | " Quit when a (custom) syntax file was already loaded |
Bram Moolenaar | 89bcfda | 2016-08-30 23:26:57 +0200 | [diff] [blame] | 14 | if exists("b:current_syntax") |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 15 | finish |
| 16 | endif |
| 17 | |
Bram Moolenaar | 40962ec | 2018-01-28 22:47:25 +0100 | [diff] [blame] | 18 | let s:cpo_save = &cpo |
| 19 | set cpo&vim |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 20 | |
Bram Moolenaar | 40962ec | 2018-01-28 22:47:25 +0100 | [diff] [blame] | 21 | " For multiline strings, try formatting them as SQL |
| 22 | syn include @pikeSQL <sfile>:p:h/sqloracle.vim |
| 23 | unlet b:current_syntax |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 24 | |
Bram Moolenaar | 40962ec | 2018-01-28 22:47:25 +0100 | [diff] [blame] | 25 | " For embedded Autodoc documentation (WIP) |
| 26 | syn include @pikeAutodoc <sfile>:p:h/autodoc.vim |
| 27 | unlet b:current_syntax |
| 28 | |
| 29 | syn case match |
| 30 | |
| 31 | " Supports array, multiset, mapping multi-character delimiter matching |
| 32 | " Supports rotating amongst several same-level preprocessor conditionals |
| 33 | packadd! matchit |
| 34 | let b:match_words = "({:}\\@1<=),(\\[:]\\@1<=),(<:>\\@1<=),^\s*#\s*\%(if\%(n\?def\)\|else\|el\%(se\)\?if\|endif\)\>" |
| 35 | |
| 36 | " A bunch of useful Pike keywords |
| 37 | syn keyword pikeDebug gauge backtrace describe_backtrace werror _Static_assert static_assert |
| 38 | syn keyword pikeException error catch throw |
| 39 | syn keyword pikeLabel case default break return continue |
| 40 | syn keyword pikeConditional if else switch |
| 41 | syn keyword pikeRepeat while for foreach do |
| 42 | |
| 43 | syn keyword pikePredef RegGetKeyNames RegGetValue RegGetValues |
| 44 | syn keyword pikePredef __automap__ __empty_program |
| 45 | syn keyword pikePredef __handle_sprintf_format __parse_pike_type _disable_threads |
| 46 | syn keyword pikePredef _do_call_outs _exit _gdb_breakpoint |
| 47 | syn keyword pikePredef abs access acos acosh add_constant alarm all_constants |
| 48 | syn keyword pikePredef array_sscanf asin asinh atan atan2 atanh atexit |
| 49 | syn keyword pikePredef basetype call_function call_out call_out_info cd ceil |
| 50 | syn keyword pikePredef combine_path combine_path_nt |
| 51 | syn keyword pikePredef combine_path_unix compile copy_value cos cosh cpp crypt |
| 52 | syn keyword pikePredef ctime decode_value delay encode_value encode_value_canonic |
| 53 | syn keyword pikePredef enumerate errno exece exit exp file_stat file_truncate |
| 54 | syn keyword pikePredef filesystem_stat find_call_out floor fork function_name |
| 55 | syn keyword pikePredef function_object function_program gc |
| 56 | syn keyword pikePredef get_active_compilation_handler get_active_error_handler |
| 57 | syn keyword pikePredef get_all_groups get_all_users get_dir get_groups_for_user |
| 58 | syn keyword pikePredef get_iterator get_profiling_info get_weak_flag getcwd |
| 59 | syn keyword pikePredef getgrgid getgrnam gethrdtime gethrtime gethrvtime getpid |
| 60 | syn keyword pikePredef getpwnam getpwuid getxattr glob gmtime has_index has_prefix |
| 61 | syn keyword pikePredef has_suffix has_value hash hash_7_0 hash_7_4 hash_8_0 |
| 62 | syn keyword pikePredef hash_value kill limit listxattr load_module localtime |
| 63 | syn keyword pikePredef log lower_case master max min mkdir mktime mv |
| 64 | syn keyword pikePredef object_program pow query_num_arg random_seed |
| 65 | syn keyword pikePredef remove_call_out removexattr replace_master rm round |
| 66 | syn keyword pikePredef set_priority set_weak_flag setxattr sgn signal signame |
| 67 | syn keyword pikePredef signum sin sinh sleep sort sprintf sqrt sscanf strerror |
| 68 | syn keyword pikePredef string_filter_non_unicode string_to_unicode string_to_utf8 |
| 69 | syn keyword pikePredef tan tanh time trace types ualarm unicode_to_string |
| 70 | syn keyword pikePredef upper_case utf8_to_string version |
| 71 | |
| 72 | syn keyword pikePredef write lock try_lock |
| 73 | syn keyword pikePredef MutexKey Timestamp Date Time TimeTZ Interval Inet Range |
| 74 | syn keyword pikePredef Null null inf nan |
| 75 | |
| 76 | syn keyword pikeTodo contained TODO FIXME XXX |
| 77 | |
| 78 | " Match parengroups: allows for highlighting indices of mappings and |
| 79 | " highlighting semicolons that are out of place due to a paren imbalance |
| 80 | syn cluster pikePreShort contains=pikeDefine,pikePreProc,pikeCppOutWrapper,pikeCppInWrapper,pikePreCondit,pikePreConditMatch |
| 81 | syn cluster pikeExprGroup contains=pikeMappIndex,@pikeStmt,pikeNest,@pikeBadGroup,pikeSoftCast |
| 82 | syn match pikeWord transparent contained /[^()'"[\]{},;:]\+/ contains=ALLBUT,@pikePreProcGroup,@pikeExprGroup |
| 83 | syn match pikeFirstWord transparent display contained /^\s*#[^()'"[\]{},;:]\+/ contains=@pikePreShort |
| 84 | syn cluster pikeMappElm contains=pikeMappIndex,@pikeStmt |
| 85 | syn cluster pikeStmt contains=pikeFirstWord,pikeCharacter,pikeString,pikeMlString,pikeWord,pikeNest |
| 86 | syn cluster pikeBadGroup contains=pikeBadPClose,pikeBadAClose,pikeBadBClose,pikeBadSPClose,pikeBadSAClose,pikeBadSBClose,pikeBadSClose,pikeBadSPAClose,pikeBadSBAClose |
| 87 | syn match pikeBadPClose display contained "[}\]]" |
| 88 | syn match pikeBadAClose display contained "[)\]]" |
| 89 | syn match pikeBadBClose display contained "[)}]" |
| 90 | syn match pikeBadSPClose display contained "[;}\]]" |
| 91 | syn match pikeBadSAClose display contained "[;)\]]" |
| 92 | syn match pikeBadSPAClose display contained "[;\]]" |
| 93 | syn match pikeBadSBAClose display contained "[;}]" |
| 94 | syn match pikeBadSClose display contained "[;)}\]]" |
| 95 | syn region pikeNest transparent start="(\@1<!{" end="}" contains=@pikeStmt,pikeUserLabel,pikeBadAClose |
| 96 | syn region pikeNest transparent start="\%(\<for\%(each\)\?\s\?\)\@8<!([[{<]\@!" end=")" contains=@pikeStmt,pikeBadSPClose |
| 97 | syn region pikeNest transparent start="\%(\<for\%(each\)\?\s\?\)\@8<=(" end=")" contains=@pikeStmt,pikeBadPClose |
| 98 | syn region pikeNest transparent start="(\@1<!\[" end="]" contains=@pikeStmt,pikeBadSBClose |
| 99 | syn region pikeNest transparent start="(\zs\[" end="])" contains=@pikeMappElm,pikeBadSBAClose |
| 100 | " For some reason specifying a matchgroup on the pikeNest below makes it |
| 101 | " override the shorter variant; consider it a kludge, no idea why it works |
| 102 | syn region pikeNest transparent matchgroup=pikeSoftCast start=%(\zs\[[ \t\v\r\n.a-zA-Z0-9_():,|]\+])\@!% end=")" contains=@pikeStmt |
| 103 | syn region pikeNest transparent start="(\zs{" end="})" contains=@pikeStmt,pikeBadSPAClose |
| 104 | syn region pikeNest transparent start="(\zs<" end=">)" contains=@pikeStmt,pikeBadSPClose keepend |
| 105 | |
| 106 | " It's easy to accidentally add a space after a backslash that was intended |
| 107 | " for line continuation. Some compilers allow it, which makes it |
| 108 | " unpredictable and should be avoided. |
| 109 | syn match pikeBadContinuation contained "\\\s\+$" |
| 110 | |
| 111 | " pikeCommentGroup allows adding matches for special things in comments |
| 112 | syn cluster pikeCommentGroup contains=pikeTodo,pikeBadContinuation |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 113 | |
| 114 | " String and Character constants |
| 115 | " Highlight special characters (those which have a backslash) differently |
Bram Moolenaar | 40962ec | 2018-01-28 22:47:25 +0100 | [diff] [blame] | 116 | syn match pikeSpecial display contained "\\\%(x\x*\|d\d*\|\o\+\|u\x\{4}\|U\x\{8}\|[abefnrtv]\|$\)" |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 117 | |
Bram Moolenaar | 40962ec | 2018-01-28 22:47:25 +0100 | [diff] [blame] | 118 | " ISO C11 or ISO C++ 11 |
| 119 | if !exists("c_no_cformat") |
| 120 | " Highlight % items in strings. |
| 121 | syn match pikeFormat display "%\%(\d\+\$\)\=[-+' #0*]*\%(\d*\|\*\|\*\d\+\$\)\%(\.\%(\d*\|\*\|\*\d\+\$\)\)\=\%([hlLjzt]\|ll\|hh\)\=\%([aAbdiuoxXDOUfFeEgGcCsSpn]\|\[\^\=.[^]]*\]\)" contained |
| 122 | syn match pikeFormat display "%%" contained |
| 123 | syn region pikeString start=+"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=pikeSpecial,pikeDelimiterDQ,pikeFormat,@Spell keepend |
| 124 | syn region pikeMlString start=+#"+ skip=+\\\\\|\\"+ end=+"+ contains=pikeSpecial,pikeFormat,pikeDelimiterDQ,@Spell,pikeEmbeddedString keepend |
| 125 | else |
| 126 | syn region pikeString start=+"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=pikeSpecial,pikeDelimiterDQ,@Spell |
| 127 | syn region pikeMlString transparent start=+#"+ skip=+\\\\\|\\"+ end=+"+ contains=pikeSpecial,pikeDelimiterDQ,@Spell,pikeEmbeddedString keepend |
| 128 | endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 129 | |
Bram Moolenaar | 40962ec | 2018-01-28 22:47:25 +0100 | [diff] [blame] | 130 | " Use SQL-syntax highlighting in multiline string if it starts with |
| 131 | " a standard SQL keyword |
| 132 | syn case ignore |
| 133 | " FIXME Use explicit newline match to cover up a bug in the regexp engine |
| 134 | " If the kludge is not used, the match will only start unless at least a space |
| 135 | " follows the initial doublequote on the first line (or the keyword is on |
| 136 | " the first line). |
| 137 | syn region pikeEmbeddedString contained start=+\%(#"\n\?\)\@2<=\_s*\%(SELECT\|INSERT\|UPDATE\|DELETE\|WITH\|CREATE\|DROP\|ALTER\)\>+ skip=+\\\\\|\\"+ end=+[\\#]\@1<!"+ contains=@pikeSQL,pikeBindings keepend |
| 138 | syn case match |
| 139 | |
| 140 | syn match pikeBindings display contained ":\@1<!:\I\i*" |
| 141 | |
| 142 | syn match pikeCharacter "'[^\\']'" contains=pikeDelimiterSQ |
| 143 | syn match pikeCharacter "'[^']*'" contains=pikeSpecial,pikeDelimiterSQ |
| 144 | syn match pikeSpecialError "'\\[^'\"?\\abefnrtv]'" |
| 145 | syn match pikeDelimiterDQ display +"+ contained |
| 146 | syn match pikeDelimiterSQ display +'+ contained |
| 147 | |
| 148 | "when wanted, highlight trailing white space |
| 149 | if exists("c_space_errors") |
| 150 | if !exists("c_no_trail_space_error") |
| 151 | syn match pikeSpaceError display excludenl "\s\+$" |
| 152 | endif |
| 153 | if !exists("c_no_tab_space_error") |
| 154 | syn match pikeSpaceError display " \+\ze\t" |
| 155 | endif |
| 156 | endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 157 | |
| 158 | "integer number, or floating point number without a dot and with "f". |
| 159 | syn case ignore |
Bram Moolenaar | 40962ec | 2018-01-28 22:47:25 +0100 | [diff] [blame] | 160 | syn match pikeNumbers display transparent "\<\d\|\.\d" contains=pikeNumber,pikeFloat,pikeOctalError,pikeOctal |
| 161 | " Same, but without octal error (for comments) |
| 162 | syn match pikeNumbersCom display contained transparent "\<\d\|\.\d" contains=pikeNumber,pikeFloat,pikeOctal |
| 163 | syn match pikeNumber display contained "\<\d\+\%(u\=l\{0,2}\|ll\=u\)\>" |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 164 | "hex number |
Bram Moolenaar | 40962ec | 2018-01-28 22:47:25 +0100 | [diff] [blame] | 165 | syn match pikeNumber display contained "\<0x\x\+\%(u\=l\{0,2}\|ll\=u\)\>" |
| 166 | " Flag the first zero of an octal number as something special |
| 167 | syn match pikeOctal display contained "\<0\o\+\%(u\=l\{0,2}\|ll\=u\)\>" contains=pikeOctalZero |
| 168 | syn match pikeOctalZero display contained "\<0" |
| 169 | "floating point number, with dot, optional exponent |
| 170 | syn match pikeFloat display contained "\<\d\+\%(f\|\.[0-9.]\@!\d*\%(e[-+]\=\d\+\)\=[fl]\=\)" |
| 171 | "floating point number, starting with a dot, optional exponent |
| 172 | syn match pikeFloat display contained "[0-9.]\@1<!\.\d\+\%(e[-+]\=\d\+\)\=[fl]\=\>" |
| 173 | "floating point number, without dot, with exponent |
| 174 | syn match pikeFloat display contained "\<\d\+e[-+]\=\d\+[fl]\=\>" |
| 175 | |
| 176 | "hexadecimal floating point number, two variants, with exponent |
| 177 | syn match pikeFloat display contained "\<0x\%(\x\+\.\?\|\x*\.\x\+\)p[-+]\=\d\+[fl]\=\>" |
| 178 | |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 179 | " flag an octal number with wrong digits |
Bram Moolenaar | 40962ec | 2018-01-28 22:47:25 +0100 | [diff] [blame] | 180 | syn match pikeOctalError display contained "\<0\o*[89]\d*" |
| 181 | syn case match |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 182 | |
| 183 | if exists("c_comment_strings") |
| 184 | " A comment can contain pikeString, pikeCharacter and pikeNumber. |
| 185 | " But a "*/" inside a pikeString in a pikeComment DOES end the comment! So we |
| 186 | " need to use a special type of pikeString: pikeCommentString, which also ends on |
| 187 | " "*/", and sees a "*" at the start of the line as comment again. |
| 188 | " Unfortunately this doesn't very well work for // type of comments :-( |
Bram Moolenaar | 40962ec | 2018-01-28 22:47:25 +0100 | [diff] [blame] | 189 | syn match pikeCommentSkip contained "^\s*\*\%($\|\s\+\)" |
| 190 | syn region pikeCommentString contained start=+\\\@<!"+ skip=+\\\\\|\\"+ end=+"+ end=+\ze\*/+ contains=pikeSpecial,pikeCommentSkip |
| 191 | syn region pikeComment2String contained start=+\\\@<!"+ skip=+\\\\\|\\"+ end=+"+ end="$" contains=pikeSpecial |
| 192 | syn region pikeCommentL start="//" skip="\\$" end="$" keepend contains=@pikeCommentGroup,pikeComment2String,pikeCharacter,pikeNumbersCom,pikeSpaceError,@Spell containedin=pikeWord,pikeFirstWord |
| 193 | if exists("c_no_comment_fold") |
| 194 | " Use "extend" here to have preprocessor lines not terminate halfway a |
| 195 | " comment. |
| 196 | syn region pikeComment matchgroup=pikeCommentStart start="/\*" end="\*/" contains=@pikeCommentGroup,pikeCommentStartError,pikeCommentString,pikeCharacter,pikeNumbersCom,pikeSpaceError,@Spell extend containedin=pikeWord,pikeFirstWord |
| 197 | else |
| 198 | syn region pikeComment matchgroup=pikeCommentStart start="/\*" end="\*/" contains=@pikeCommentGroup,pikeCommentStartError,pikeCommentString,pikeCharacter,pikeNumbersCom,pikeSpaceError,@Spell fold extend containedin=pikeWord,pikeFirstWord |
| 199 | endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 200 | else |
Bram Moolenaar | 40962ec | 2018-01-28 22:47:25 +0100 | [diff] [blame] | 201 | syn region pikeCommentL start="//" skip="\\$" end="$" keepend contains=@pikeCommentGroup,pikeSpaceError,@Spell containedin=pikeWord,pikeFirstWord |
| 202 | if exists("c_no_comment_fold") |
| 203 | syn region pikeComment matchgroup=pikeCommentStart start="/\*" end="\*/" contains=@pikeCommentGroup,pikeCommentStartError,pikeSpaceError,@Spell extend containedin=pikeWord,pikeFirstWord |
| 204 | else |
| 205 | syn region pikeComment matchgroup=pikeCommentStart start="/\*" end="\*/" contains=@pikeCommentGroup,pikeCommentStartError,pikeSpaceError,@Spell fold extend containedin=pikeWord,pikeFirstWord |
| 206 | endif |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 207 | endif |
Bram Moolenaar | 40962ec | 2018-01-28 22:47:25 +0100 | [diff] [blame] | 208 | " keep a // comment separately, it terminates a preproc. conditional |
| 209 | syn match pikeCommentError display "\*/" |
| 210 | syn match pikeCommentStartError display "/\ze\*" contained |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 211 | |
Bram Moolenaar | 40962ec | 2018-01-28 22:47:25 +0100 | [diff] [blame] | 212 | syn keyword pikeOperator sizeof |
| 213 | syn keyword pikeOperator typeof _typeof _refs |
| 214 | syn keyword pikeOperator zero_type intp stringp arrayp mappingp multisetp |
| 215 | syn keyword pikeOperator objectp functionp programp callablep destructedp |
| 216 | syn keyword pikeOperator object_variablep undefinedp |
| 217 | syn keyword pikeOperator allocate equal |
| 218 | syn keyword pikeOperator aggregate aggregate_mapping aggregate_multiset |
| 219 | syn keyword pikeOperator map filter search replace reverse column rows |
| 220 | syn keyword pikeOperator indices values mkmapping mkmultiset m_delete sort |
| 221 | syn keyword pikeOperator m_delete destruct |
| 222 | syn keyword pikeOperator create _destruct _sprintf cast _encode _decode |
| 223 | syn keyword pikeOperator __hash _sizeof _values _indices __INIT _equal |
| 224 | syn keyword pikeOperator _is_type _m_delete _get_iterator _search |
| 225 | syn keyword pikeOperator _serialize _deserialize _sqrt _types _random |
| 226 | syn keyword pikeOperator _size_object |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 227 | |
Bram Moolenaar | 40962ec | 2018-01-28 22:47:25 +0100 | [diff] [blame] | 228 | syn keyword pikeType int void |
| 229 | syn keyword pikeType float |
| 230 | syn keyword pikeType bool string array mapping multiset mixed |
| 231 | syn keyword pikeType object function program auto |
| 232 | |
| 233 | syn keyword pikeType this this_object this_program |
| 234 | syn keyword pikeType sprintf_args sprintf_format sprintf_result |
| 235 | syn keyword pikeType strict_sprintf_format |
| 236 | |
| 237 | syn keyword pikeStructure class enum typedef inherit import |
| 238 | syn keyword pikeTypedef typedef |
| 239 | syn keyword pikeStorageClass private protected public constant final variant |
| 240 | syn keyword pikeStorageClass optional inline extern static __deprecated__ lambda |
| 241 | |
| 242 | syn keyword pikeConstant __LINE__ __FILE__ __DIR__ __DATE__ __TIME__ |
| 243 | syn keyword pikeConstant __AUTO_BIGNUM__ __NT__ |
| 244 | syn keyword pikeConstant __BUILD__ __COUNTER__ _MAJOR__ __MINOR__ __VERSION__ |
| 245 | syn keyword pikeConstant __REAL_BUILD__ _REAL_MAJOR__ __REAL_MINOR__ |
| 246 | syn keyword pikeConstant __REAL_VERSION__ __PIKE__ UNDEFINED |
| 247 | |
| 248 | " These should actually only be parsed in preprocessor conditionals |
| 249 | syn keyword pikeCppOperator contained defined constant efun _Pragma |
| 250 | |
| 251 | syn keyword pikeBoolean true false |
| 252 | |
| 253 | syn match pikeCppPrefix display "^\s*\zs#\s*[a-z]\+" contained |
| 254 | syn region pikePreCondit start="^\s*#\s*\%(if\%(n\?def\)\?\|el\%(se\)\?if\)\>" skip="\\$" end="$" transparent keepend contains=pikeString,pikeCharacter,pikeNumbers,pikeCommentError,pikeSpaceError,pikeCppOperator,pikeCppPrefix |
| 255 | syn match pikePreConditMatch display "^\s*\zs#\s*\%(else\|endif\)\>" |
| 256 | if !exists("c_no_if0") |
| 257 | syn cluster pikeCppOutInGroup contains=pikeCppInIf,pikeCppInElse,pikeCppInElse2,pikeCppOutIf,pikeCppOutIf2,pikeCppOutElse,pikeCppInSkip,pikeCppOutSkip |
| 258 | syn region pikeCppOutWrapper start="^\s*\zs#\s*if\s\+0\+\s*\%($\|//\|/\*\|&\)" end=".\@=\|$" contains=pikeCppOutIf,pikeCppOutElse,@NoSpell fold |
| 259 | syn region pikeCppOutIf contained start="0\+" matchgroup=pikeCppOutWrapper end="^\s*#\s*endif\>" contains=pikeCppOutIf2,pikeCppOutElse |
| 260 | if !exists("c_no_if0_fold") |
| 261 | syn region pikeCppOutIf2 contained matchgroup=pikeCppOutWrapper start="0\+" end="^\ze\s*#\s*\%(else\>\|el\%(se\)\?if\s\+\%(0\+\s*\%($\|//\|/\*\|&\)\)\@!\|endif\>\)" contains=pikeSpaceError,pikeCppOutSkip,@Spell fold |
| 262 | else |
| 263 | syn region pikeCppOutIf2 contained matchgroup=pikeCppOutWrapper start="0\+" end="^\ze\s*#\s*\%(else\>\|el\%(se\)\?if\s\+\%(0\+\s*\%($\|//\|/\*\|&\)\)\@!\|endif\>\)" contains=pikeSpaceError,pikeCppOutSkip,@Spell |
| 264 | endif |
| 265 | syn region pikeCppOutElse contained matchgroup=pikeCppOutWrapper start="^\s*#\s*\%(else\|el\%(se\)\?if\)" end="^\s*#\s*endif\>" contains=TOP,pikePreCondit |
| 266 | syn region pikeCppInWrapper start="^\s*\zs#\s*if\s\+0*[1-9]\d*\s*\%($\|//\|/\*\||\)" end=".\@=\|$" contains=pikeCppInIf,pikeCppInElse fold |
| 267 | syn region pikeCppInIf contained matchgroup=pikeCppInWrapper start="\d\+" end="^\s*#\s*endif\>" contains=TOP,pikePreCondit |
| 268 | if !exists("c_no_if0_fold") |
| 269 | syn region pikeCppInElse contained start="^\s*#\s*\%(else\>\|el\%(se\)\?if\s\+\%(0*[1-9]\d*\s*\%($\|//\|/\*\||\)\)\@!\)" end=".\@=\|$" containedin=pikeCppInIf contains=pikeCppInElse2 fold |
| 270 | else |
| 271 | syn region pikeCppInElse contained start="^\s*#\s*\%(else\>\|el\%(se\)\?if\s\+\%(0*[1-9]\d*\s*\%($\|//\|/\*\||\)\)\@!\)" end=".\@=\|$" containedin=pikeCppInIf contains=pikeCppInElse2 |
| 272 | endif |
| 273 | syn region pikeCppInElse2 contained matchgroup=pikeCppInWrapper start="^\s*#\s*\%(else\|el\%(se\)\?if\)\%([^/]\|/[^/*]\)*" end="^\ze\s*#\s*endif\>" contains=pikeSpaceError,pikeCppOutSkip,@Spell |
| 274 | syn region pikeCppOutSkip contained start="^\s*#\s*if\%(n\?def\)\?\>" skip="\\$" end="^\s*#\s*endif\>" contains=pikeSpaceError,pikeCppOutSkip |
| 275 | syn region pikeCppInSkip contained matchgroup=pikeCppInWrapper start="^\s*#\s*\%(if\s\+\%(\d\+\s*\%($\|//\|/\*\||\|&\)\)\@!\|ifn\?def\>\)" skip="\\$" end="^\s*#\s*endif\>" containedin=pikeCppOutElse,pikeCppInIf,pikeCppInSkip contains=TOP,pikePreProc |
| 276 | endif |
| 277 | syn region pikeIncluded display contained start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=pikeDelimiterDQ keepend |
| 278 | syn match pikeIncluded display contained "<[^>]*>" |
| 279 | syn match pikeInclude display "^\s*\zs#\s*include\>\s*["<]" contains=pikeIncluded |
| 280 | syn cluster pikePreProcGroup contains=pikeIncluded,pikeInclude,pikeEmbeddedString,pikeCppOutWrapper,pikeCppInWrapper,@pikeCppOutInGroup,pikeFormat,pikeMlString,pikeCommentStartError,@pikeBadGroup,pikeWord |
| 281 | syn region pikeDefine start="^\s*\zs#\s*\%(define\|undef\)\>" skip="\\$" end="$" keepend contains=@pikeStmt,@pikeBadGroup |
| 282 | syn region pikePreProc start="^\s*\zs#\s*\%(pragma\|charset\|pike\|require\|string\|line\|warning\|error\)\>" skip="\\$" end="$" transparent keepend contains=pikeString,pikeCharacter,pikeNumbers,pikeCommentError,pikeSpaceError,pikeCppOperator,pikeCppPrefix,@Spell,pikeConstant |
| 283 | |
| 284 | syn match pikeAutodocReal display contained "\%(//\|[/ \t\v]\*\|^\*\)\@2<=!.*" contains=@pikeAutodoc containedin=pikeComment,pikeCommentL |
| 285 | syn cluster pikeCommentGroup add=pikeAutodocReal |
| 286 | syn cluster pikePreProcGroup add=pikeAutodocReal |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 287 | |
| 288 | " Highlight User Labels |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 289 | " Avoid matching foo::bar() in C++ by requiring that the next char is not ':' |
Bram Moolenaar | 40962ec | 2018-01-28 22:47:25 +0100 | [diff] [blame] | 290 | syn match pikeUserLabel display "\%(^\|[{};]\)\zs\I\i*\s*\ze:\%([^:]\|$\)" contained contains=NONE |
| 291 | syn match pikeUserLabel display "\%(\<\%(break\|continue\)\_s\+\)\@10<=\I\i*" contained contains=NONE |
| 292 | syn match pikeUserLabel display "\%(\<case\)\@5<=\s\+[^<()[\]{},;:]\+\ze::\@!" contained contains=pikeDelimiterDQ,pikeDelimiterSQ |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 293 | |
Bram Moolenaar | 40962ec | 2018-01-28 22:47:25 +0100 | [diff] [blame] | 294 | syn match pikeMappIndex display contained "[^<()[\]{},;:]\+\ze::\@!" contains=pikeDelimiterDQ,pikeDelimiterSQ |
| 295 | syn match pikeSoftCast display contained "\[[ \t\v\r\n.a-zA-Z0-9_():,|\+]" contains=NONE |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 296 | |
Bram Moolenaar | 40962ec | 2018-01-28 22:47:25 +0100 | [diff] [blame] | 297 | if exists("c_minlines") |
| 298 | let b:c_minlines = c_minlines |
| 299 | else |
| 300 | if !exists("c_no_if0") |
| 301 | let b:c_minlines = 400 " #if 0 constructs can be long |
| 302 | else |
| 303 | let b:c_minlines = 200 " mostly for multiline strings |
| 304 | endif |
| 305 | endif |
| 306 | exec "syn sync ccomment pikeComment minlines=" . b:c_minlines |
| 307 | syn sync match pikeMlStringSync grouphere pikeMlString +^[^"#]\+#\"+ |
| 308 | syn sync match pikeAutodocSync grouphere pikeCommentL "^\s*//!" |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 309 | |
| 310 | " Define the default highlighting. |
Bram Moolenaar | 40962ec | 2018-01-28 22:47:25 +0100 | [diff] [blame] | 311 | " Only used when an item doesn't have highlighting yet |
| 312 | hi def link pikeFormat SpecialChar |
| 313 | hi def link pikeMlString String |
| 314 | hi def link pikeCommentL Comment |
| 315 | hi def link pikeCommentStart Comment |
Bram Moolenaar | f37506f | 2016-08-31 22:22:10 +0200 | [diff] [blame] | 316 | hi def link pikeLabel Label |
Bram Moolenaar | 40962ec | 2018-01-28 22:47:25 +0100 | [diff] [blame] | 317 | hi def link pikeUserLabel Identifier |
Bram Moolenaar | f37506f | 2016-08-31 22:22:10 +0200 | [diff] [blame] | 318 | hi def link pikeConditional Conditional |
| 319 | hi def link pikeRepeat Repeat |
Bram Moolenaar | 40962ec | 2018-01-28 22:47:25 +0100 | [diff] [blame] | 320 | hi def link pikeCharacter Character |
| 321 | hi def link pikeDelimiterDQ Delimiter |
| 322 | hi def link pikeDelimiterSQ Delimiter |
Bram Moolenaar | f37506f | 2016-08-31 22:22:10 +0200 | [diff] [blame] | 323 | hi def link pikeNumber Number |
Bram Moolenaar | 40962ec | 2018-01-28 22:47:25 +0100 | [diff] [blame] | 324 | hi def link pikeOctal Number |
| 325 | hi def link pikeOctalZero PreProc " link this to Error if you want |
Bram Moolenaar | f37506f | 2016-08-31 22:22:10 +0200 | [diff] [blame] | 326 | hi def link pikeFloat Float |
Bram Moolenaar | 40962ec | 2018-01-28 22:47:25 +0100 | [diff] [blame] | 327 | hi def link pikeOctalError Error |
| 328 | hi def link pikeCommentError Error |
| 329 | hi def link pikeCommentStartError Error |
| 330 | hi def link pikeSpaceError Error |
| 331 | hi def link pikeSpecialError Error |
| 332 | hi def link pikeOperator Operator |
| 333 | hi def link pikeCppOperator Operator |
| 334 | hi def link pikeStructure Structure |
| 335 | hi def link pikeTypedef Typedef |
| 336 | hi def link pikeStorageClass StorageClass |
Bram Moolenaar | f37506f | 2016-08-31 22:22:10 +0200 | [diff] [blame] | 337 | hi def link pikeInclude Include |
Bram Moolenaar | 40962ec | 2018-01-28 22:47:25 +0100 | [diff] [blame] | 338 | hi def link pikeCppPrefix PreCondit |
Bram Moolenaar | f37506f | 2016-08-31 22:22:10 +0200 | [diff] [blame] | 339 | hi def link pikePreProc PreProc |
| 340 | hi def link pikeDefine Macro |
Bram Moolenaar | 40962ec | 2018-01-28 22:47:25 +0100 | [diff] [blame] | 341 | hi def link pikeIncluded String |
Bram Moolenaar | f37506f | 2016-08-31 22:22:10 +0200 | [diff] [blame] | 342 | hi def link pikeError Error |
Bram Moolenaar | 40962ec | 2018-01-28 22:47:25 +0100 | [diff] [blame] | 343 | hi def link pikeDebug Debug |
| 344 | hi def link pikeException Exception |
| 345 | hi def link pikeStatement Statement |
Bram Moolenaar | f37506f | 2016-08-31 22:22:10 +0200 | [diff] [blame] | 346 | hi def link pikeType Type |
Bram Moolenaar | 40962ec | 2018-01-28 22:47:25 +0100 | [diff] [blame] | 347 | hi def link pikeConstant Constant |
| 348 | hi def link pikeBoolean Boolean |
| 349 | hi def link pikeCommentString String |
| 350 | hi def link pikeComment2String String |
| 351 | hi def link pikeCommentSkip Comment |
Bram Moolenaar | f37506f | 2016-08-31 22:22:10 +0200 | [diff] [blame] | 352 | hi def link pikeString String |
| 353 | hi def link pikeComment Comment |
| 354 | hi def link pikeSpecial SpecialChar |
| 355 | hi def link pikeTodo Todo |
Bram Moolenaar | 40962ec | 2018-01-28 22:47:25 +0100 | [diff] [blame] | 356 | hi def link pikeBadContinuation Error |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 357 | |
Bram Moolenaar | 40962ec | 2018-01-28 22:47:25 +0100 | [diff] [blame] | 358 | hi def link pikeCppInWrapper PreCondit |
| 359 | hi def link pikeCppOutWrapper PreCondit |
| 360 | hi def link pikePreConditMatch PreCondit |
| 361 | |
| 362 | hi def link pikeCppOutSkip Comment |
| 363 | hi def link pikeCppInElse2 Comment |
| 364 | hi def link pikeCppOutIf2 Comment |
| 365 | hi def link pikeCppOut Comment |
| 366 | |
| 367 | hi def link pikePredef Statement |
| 368 | hi def link pikeBindings Identifier |
| 369 | hi def link pikeMappIndex Identifier |
| 370 | hi def link pikeSoftCast Type |
| 371 | hi def link pikeBadGroup Error |
| 372 | hi def link pikeBadPClose Error |
| 373 | hi def link pikeBadAClose Error |
| 374 | hi def link pikeBadBClose Error |
| 375 | hi def link pikeBadSPClose Error |
| 376 | hi def link pikeBadSAClose Error |
| 377 | hi def link pikeBadSBClose Error |
| 378 | hi def link pikeBadSPAClose Error |
| 379 | hi def link pikeBadSBAClose Error |
| 380 | hi def link pikeBadSClose Error |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 381 | |
| 382 | let b:current_syntax = "pike" |
| 383 | |
Bram Moolenaar | 40962ec | 2018-01-28 22:47:25 +0100 | [diff] [blame] | 384 | let &cpo = s:cpo_save |
| 385 | unlet s:cpo_save |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 386 | " vim: ts=8 |