Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
ocaml.vim669 linesDownload Raw Back to syntax
1" Vim syntax file2" Language:     OCaml3" Filenames:    *.ml *.mli *.mll *.mly4" Maintainers:  Markus Mottl      <markus.mottl@gmail.com>5"               Karl-Heinz Sylla  <Karl-Heinz.Sylla@gmd.de>6"               Issac Trotts      <ijtrotts@ucdavis.edu>7" URL:          https://github.com/ocaml/vim-ocaml8" Last Change:9"               2019 Nov 05 - Accurate type highlighting (Maëlan)10"               2018 Nov 08 - Improved highlighting of operators (Maëlan)11"               2018 Apr 22 - Improved support for PPX (Andrey Popp)12"               2018 Mar 16 - Remove raise, lnot and not from keywords (Étienne Millon, "copy")13"               2017 Apr 11 - Improved matching of negative numbers (MM)14"               2016 Mar 11 - Improved support for quoted strings (Glen Mével)15"               2015 Aug 13 - Allow apostrophes in identifiers (Jonathan Chan, Einar Lielmanis)16"               2015 Jun 17 - Added new "nonrec" keyword (MM)17 18" A minor patch was applied to the official version so that object/end19" can be distinguished from begin/end, which is used for indentation,20" and folding. (David Baelde)21 22" Quit when a syntax file was already loaded23if exists("b:current_syntax") && b:current_syntax == "ocaml"24  finish25endif26 27let s:keepcpo = &cpo28set cpo&vim29 30" ' can be used in OCaml identifiers31setlocal iskeyword+='32 33" ` is part of the name of polymorphic variants34setlocal iskeyword+=`35 36" OCaml is case sensitive.37syn case match38 39" Access to the method of an object40syn match    ocamlMethod       "#"41 42" Scripting directives43syn match    ocamlScript "^#\<\(quit\|labels\|warnings\|warn_error\|directory\|remove_directory\|cd\|load\|load_rec\|use\|mod_use\|install_printer\|remove_printer\|require\|list\|ppx\|principal\|predicates\|rectypes\|thread\|trace\|untrace\|untrace_all\|print_depth\|print_length\|camlp4o\|camlp4r\|topfind_log\|topfind_verbose\)\>"44 45" lowercase identifier - the standard way to match46syn match    ocamlLCIdentifier /\<\(\l\|_\)\(\w\|'\)*\>/47 48" Errors49syn match    ocamlBraceErr   "}"50syn match    ocamlBrackErr   "\]"51syn match    ocamlParenErr   ")"52syn match    ocamlArrErr     "|]"53 54syn match    ocamlCountErr   "\<downto\>"55syn match    ocamlCountErr   "\<to\>"56 57if !exists("ocaml_revised")58  syn match    ocamlDoErr      "\<do\>"59endif60 61syn match    ocamlDoneErr    "\<done\>"62syn match    ocamlThenErr    "\<then\>"63 64" Error-highlighting of "end" without synchronization:65" as keyword or as error (default)66if exists("ocaml_noend_error")67  syn match    ocamlKeyword    "\<end\>"68else69  syn match    ocamlEndErr     "\<end\>"70endif71 72" These keywords are only expected nested in constructions that are handled by73" the type linter, so outside of type contexts we highlight them as errors:74syn match    ocamlKwErr  "\<\(mutable\|nonrec\|of\|private\)\>"75 76" Some convenient clusters77syn cluster  ocamlAllErrs contains=@ocamlAENoParen,ocamlParenErr78syn cluster  ocamlAENoParen contains=ocamlBraceErr,ocamlBrackErr,ocamlCountErr,ocamlDoErr,ocamlDoneErr,ocamlEndErr,ocamlThenErr,ocamlKwErr79 80syn cluster  ocamlContained contains=ocamlTodo,ocamlPreDef,ocamlModParam,ocamlModParam1,ocamlModTypePre,ocamlModRHS,ocamlFuncWith,ocamlModTypeRestr,ocamlModTRWith,ocamlWith,ocamlWithRest,ocamlFullMod,ocamlVal81 82 83" Enclosing delimiters84syn region   ocamlNone transparent matchgroup=ocamlEncl start="(" matchgroup=ocamlEncl end=")" contains=ALLBUT,@ocamlContained,ocamlParenErr85syn region   ocamlNone transparent matchgroup=ocamlEncl start="{" matchgroup=ocamlEncl end="}"  contains=ALLBUT,@ocamlContained,ocamlBraceErr86syn region   ocamlNone transparent matchgroup=ocamlEncl start="\[" matchgroup=ocamlEncl end="\]" contains=ALLBUT,@ocamlContained,ocamlBrackErr87syn region   ocamlNone transparent matchgroup=ocamlEncl start="\[|" matchgroup=ocamlEncl end="|\]" contains=ALLBUT,@ocamlContained,ocamlArrErr88 89 90" Comments91syn region   ocamlComment start="(\*" end="\*)" contains=@Spell,ocamlComment,ocamlTodo92syn keyword  ocamlTodo contained TODO FIXME XXX NOTE93 94 95" Objects96syn region   ocamlEnd matchgroup=ocamlObject start="\<object\>" matchgroup=ocamlObject end="\<end\>" contains=ALLBUT,@ocamlContained,ocamlEndErr97 98 99" Blocks100if !exists("ocaml_revised")101  syn region   ocamlEnd matchgroup=ocamlKeyword start="\<begin\>" matchgroup=ocamlKeyword end="\<end\>" contains=ALLBUT,@ocamlContained,ocamlEndErr102endif103 104 105" "for"106syn region   ocamlNone matchgroup=ocamlKeyword start="\<for\>" matchgroup=ocamlKeyword end="\<\(to\|downto\)\>" contains=ALLBUT,@ocamlContained,ocamlCountErr107 108 109" "do"110if !exists("ocaml_revised")111  syn region   ocamlDo matchgroup=ocamlKeyword start="\<do\>" matchgroup=ocamlKeyword end="\<done\>" contains=ALLBUT,@ocamlContained,ocamlDoneErr112endif113 114" "if"115syn region   ocamlNone matchgroup=ocamlKeyword start="\<if\>" matchgroup=ocamlKeyword end="\<then\>" contains=ALLBUT,@ocamlContained,ocamlThenErr116 117"" PPX nodes118 119syn match ocamlPpxIdentifier /\(\[@\{1,3\}\)\@<=\w\+\(\.\w\+\)*/120syn region ocamlPpx matchgroup=ocamlPpxEncl start="\[@\{1,3\}" contains=TOP end="\]"121 122"" Modules123 124" "open"125syn match   ocamlKeyword "\<open\>" skipwhite skipempty nextgroup=ocamlFullMod126 127" "include"128syn match    ocamlKeyword "\<include\>" skipwhite skipempty nextgroup=ocamlModParam,ocamlFullMod129 130" "module" - somewhat complicated stuff ;-)131" 2022-10: please document it?132syn region   ocamlModule matchgroup=ocamlKeyword start="\<module\>" matchgroup=ocamlModule end="\<_\|\u\(\w\|'\)*\>" contains=@ocamlAllErrs,ocamlComment skipwhite skipempty nextgroup=ocamlPreDef133syn region   ocamlPreDef start="."me=e-1 end="[a-z:=)]\@=" contained contains=@ocamlAllErrs,ocamlComment,ocamlModParam,ocamlGenMod,ocamlModTypeRestr nextgroup=ocamlModTypePre,ocamlModPreRHS134syn region   ocamlModParam start="(\*\@!" end=")" contained contains=ocamlGenMod,ocamlModParam,ocamlModParam1,ocamlSig,ocamlVal135syn match    ocamlModParam1 "\<\u\(\w\|'\)*\>" contained skipwhite skipempty136syn match    ocamlGenMod "()" contained skipwhite skipempty137 138syn match    ocamlModTypePre ":" contained skipwhite skipempty nextgroup=ocamlModTRWith,ocamlSig,ocamlFunctor,ocamlModTypeRestr,ocamlModTypeOf139syn match    ocamlModTypeRestr "\<\w\(\w\|'\)*\( *\. *\w\(\w\|'\)*\)*\>" contained140 141syn match    ocamlModPreRHS "=" contained skipwhite skipempty nextgroup=ocamlModParam,ocamlFullMod142syn keyword  ocamlKeyword val143syn region   ocamlVal matchgroup=ocamlKeyword start="\<val\>" matchgroup=ocamlLCIdentifier end="\<\l\(\w\|'\)*\>" contains=@ocamlAllErrs,ocamlComment,ocamlFullMod skipwhite skipempty nextgroup=ocamlModTypePre144syn region   ocamlModRHS start="." end=". *\w\|([^*]"me=e-2 contained contains=ocamlComment skipwhite skipempty nextgroup=ocamlModParam,ocamlFullMod145syn match    ocamlFullMod "\<\u\(\w\|'\)*\( *\. *\u\(\w\|'\)*\)*" contained skipwhite skipempty nextgroup=ocamlFuncWith146 147syn region   ocamlFuncWith start="([*)]\@!" end=")" contained contains=ocamlComment,ocamlWith,ocamlStruct skipwhite skipempty nextgroup=ocamlFuncWith148 149syn region   ocamlModTRWith start="(\*\@!" end=")" contained contains=@ocamlAENoParen,ocamlWith150syn match    ocamlWith "\<\(\u\(\w\|'\)* *\. *\)*\w\(\w\|'\)*\>" contained skipwhite skipempty nextgroup=ocamlWithRest151syn region   ocamlWithRest start="[^)]" end=")"me=e-1 contained contains=ALLBUT,@ocamlContained152 153" "struct"154syn region   ocamlStruct matchgroup=ocamlStructEncl start="\<\(module\s\+\)\=struct\>" matchgroup=ocamlStructEncl end="\<end\>" contains=ALLBUT,@ocamlContained,ocamlEndErr155 156" "sig"157syn region   ocamlSig matchgroup=ocamlSigEncl start="\<sig\>" matchgroup=ocamlSigEncl end="\<end\>" contains=ALLBUT,@ocamlContained,ocamlEndErr158 159" "functor"160syn region   ocamlFunctor start="\<functor\>" matchgroup=ocamlKeyword end="->" contains=@ocamlAllErrs,ocamlComment,ocamlModParam,ocamlGenMod skipwhite skipempty nextgroup=ocamlStruct,ocamlSig,ocamlFuncWith,ocamlFunctor161 162" "module type"163syn region   ocamlModTypeOf start="\<module\s\+type\(\s\+of\)\=\>" matchgroup=ocamlModule end="\<\w\(\w\|'\)*\>" contains=ocamlComment skipwhite skipempty nextgroup=ocamlMTDef164syn match    ocamlMTDef "=\s*\w\(\w\|'\)*\>"hs=s+1,me=s+1 skipwhite skipempty nextgroup=ocamlFullMod165 166" Quoted strings167syn region ocamlString matchgroup=ocamlQuotedStringDelim start="{\z\([a-z_]*\)|" end="|\z1}" contains=@Spell168syn region ocamlString matchgroup=ocamlQuotedStringDelim start="{%[a-z_]\+\(\.[a-z_]\+\)\?\( \z\([a-z_]\+\)\)\?|" end="|\z1}" contains=@Spell169 170syn keyword  ocamlKeyword  and as assert class171syn keyword  ocamlKeyword  else172syn keyword  ocamlKeyword  external173syn keyword  ocamlKeyword  in inherit initializer174syn keyword  ocamlKeyword  lazy let match175syn keyword  ocamlKeyword  method new176syn keyword  ocamlKeyword  parser rec177syn keyword  ocamlKeyword  try178syn keyword  ocamlKeyword  virtual when while with179 180" Keywords which are handled by the type linter:181"     as (within a type equation)182"     constraint exception mutable nonrec of private type183 184" The `fun` keyword has special treatment because of the syntax `fun … : t -> e`185" where `->` ends the type context rather than being part of it; to handle that,186" we blacklist the ocamlTypeAnnot matchgroup, and we plug ocamlFunTypeAnnot187" instead (later in this file, by using containedin=ocamlFun):188syn region ocamlFun matchgroup=ocamlKeyword start='\<fun\>' matchgroup=ocamlArrow end='->'189\ contains=ALLBUT,@ocamlContained,ocamlArrow,ocamlInfixOp,ocamlTypeAnnot190 191if exists("ocaml_revised")192  syn keyword  ocamlKeyword  do value193  syn keyword  ocamlBoolean  True False194else195  syn keyword  ocamlKeyword  function196  syn keyword  ocamlBoolean  true false197endif198 199syn match    ocamlEmptyConstructor  "(\s*)"200syn match    ocamlEmptyConstructor  "\[\s*\]"201syn match    ocamlEmptyConstructor  "\[|\s*>|]"202syn match    ocamlEmptyConstructor  "\[<\s*>\]"203syn match    ocamlConstructor  "\u\(\w\|'\)*\>"204 205" Polymorphic variants206syn match    ocamlConstructor  "`\w\(\w\|'\)*\>"207 208" Module prefix209syn match    ocamlModPath      "\u\(\w\|'\)* *\."he=e-1210 211syn match    ocamlCharacter    "'\\\d\d\d'\|'\\[\'ntbr]'\|'.'"212syn match    ocamlCharacter    "'\\x\x\x'"213syn match    ocamlCharErr      "'\\\d\d'\|'\\\d'"214syn match    ocamlCharErr      "'\\[^\'ntbr]'"215syn region   ocamlString       start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=@Spell216 217syn match    ocamlAnyVar       "\<_\>"218syn match    ocamlKeyChar      "|]\@!"219syn match    ocamlKeyChar      ";"220syn match    ocamlKeyChar      "\~"221syn match    ocamlKeyChar      "?"222 223" NOTE: for correct precedence, the rule for ";;" must come after that for ";"224syn match    ocamlTopStop      ";;"225 226"" Operators227 228" The grammar of operators is found there:229"     https://caml.inria.fr/pub/docs/manual-ocaml/names.html#operator-name230"     https://caml.inria.fr/pub/docs/manual-ocaml/extn.html#s:ext-ops231"     https://caml.inria.fr/pub/docs/manual-ocaml/extn.html#s:index-operators232" = is both an operator name and a keyword, we let the user choose how233" to display it (has to be declared before regular infix operators):234syn match    ocamlEqual        "="235" Custom indexing operators:236syn region   ocamlIndexing matchgroup=ocamlIndexingOp237  \ start="\.[~?!:|&$%=>@^/*+-][~?!.:|&$%<=>@^*/+-]*\_s*("238  \ end=")\(\_s*<-\)\?"239  \ contains=ALLBUT,@ocamlContained,ocamlParenErr240syn region   ocamlIndexing matchgroup=ocamlIndexingOp241  \ start="\.[~?!:|&$%=>@^/*+-][~?!.:|&$%<=>@^*/+-]*\_s*\["242  \ end="]\(\_s*<-\)\?"243  \ contains=ALLBUT,@ocamlContained,ocamlBrackErr244syn region   ocamlIndexing matchgroup=ocamlIndexingOp245  \ start="\.[~?!:|&$%=>@^/*+-][~?!.:|&$%<=>@^*/+-]*\_s*{"246  \ end="}\(\_s*<-\)\?"247  \ contains=ALLBUT,@ocamlContained,ocamlBraceErr248" Extension operators (has to be declared before regular infix operators):249syn match    ocamlExtensionOp          "#[#~?!.:|&$%<=>@^*/+-]\+"250" Infix and prefix operators:251syn match    ocamlPrefixOp              "![~?!.:|&$%<=>@^*/+-]*"252syn match    ocamlPrefixOp           "[~?][~?!.:|&$%<=>@^*/+-]\+"253syn match    ocamlInfixOp   "[&$%<>@^*/+-][~?!.:|&$%<=>@^*/+-]*"254syn match    ocamlInfixOp            "[|=][~?!.:|&$%<=>@^*/+-]\+"255syn match    ocamlInfixOp               "#[~?!.:|&$%<=>@^*/+-]\+#\@!"256syn match    ocamlInfixOp              "!=[~?!.:|&$%<=>@^*/+-]\@!"257syn keyword  ocamlInfixOpKeyword      asr land lor lsl lsr lxor mod or258" := is technically an infix operator, but we may want to show it as a keyword259" (somewhat analogously to = for let‐bindings and <- for assignations):260syn match    ocamlRefAssign    ":="261" :: is technically not an operator, but we may want to show it as such:262syn match    ocamlCons         "::"263" -> and <- are keywords, not operators (but can appear in longer operators):264syn match    ocamlArrow        "->[~?!.:|&$%<=>@^*/+-]\@!"265if exists("ocaml_revised")266  syn match    ocamlErr        "<-[~?!.:|&$%<=>@^*/+-]\@!"267else268  syn match    ocamlKeyChar    "<-[~?!.:|&$%<=>@^*/+-]\@!"269endif270 271" Script shebang (has to be declared after operators)272syn match    ocamlShebang       "\%1l^#!.*$"273 274syn match    ocamlNumber        "-\=\<\d\(_\|\d\)*[l|L|n]\?\>"275syn match    ocamlNumber        "-\=\<0[x|X]\(\x\|_\)\+[l|L|n]\?\>"276syn match    ocamlNumber        "-\=\<0[o|O]\(\o\|_\)\+[l|L|n]\?\>"277syn match    ocamlNumber        "-\=\<0[b|B]\([01]\|_\)\+[l|L|n]\?\>"278syn match    ocamlFloat         "-\=\<\d\(_\|\d\)*\.\?\(_\|\d\)*\([eE][-+]\=\d\(_\|\d\)*\)\=\>"279 280" Labels281syn match    ocamlLabel        "[~?]\(\l\|_\)\(\w\|'\)*:\?"282syn region   ocamlLabel transparent matchgroup=ocamlLabel start="[~?](\(\l\|_\)\(\w\|'\)*"lc=2 end=")"me=e-1 contains=ALLBUT,@ocamlContained,ocamlParenErr283 284""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""285 286"" Type contexts287 288" How we recognize type contexts is explained in `type-linter-notes.md`289" and a test suite is found in `type-linter-test.ml`.290"291" ocamlTypeExpr is the cluster of things that can make up a type expression292" (in a loose sense, e.g. the “as” keyword and universal quantification are293" included). Regions containing a type expression use it like this:294"295"     contains=@ocamlTypeExpr,...296"297" ocamlTypeContained is the cluster of things that can be found in a type298" expression or a type definition. It is not expected to be used in any region,299" it exists solely for throwing things in it that should not pollute the main300" linter.301"302" Both clusters are filled in incrementally. Every match group that is not to be303" found at the main level must be declared as “contained” and added to either304" ocamlTypeExpr or ocamlTypeContained.305"306" In these clusters we don’t put generic things that can also be found elswhere,307" i.e. ocamlComment and ocamlPpx, because everything that is in these clusters308" is also put in ocamlContained and thus ignored by the main linter.309 310"syn cluster ocamlTypeExpr contains=311syn cluster ocamlTypeContained contains=@ocamlTypeExpr312syn cluster ocamlContained add=@ocamlTypeContained313 314" We’ll use a “catch-all” highlighting group to show as error anything that is315" not matched more specifically; we don’t want spaces to be reported as errors316" (different background color), so we just catch them here:317syn cluster ocamlTypeExpr add=ocamlTypeBlank318syn match    ocamlTypeBlank    contained  "\_s\+"319hi link ocamlTypeBlank NONE320 321" NOTE: Carefully avoid catching "(*" here.322syn cluster ocamlTypeExpr add=ocamlTypeParen323syn region ocamlTypeParen contained transparent324\ matchgroup=ocamlEncl start="(\*\@!"325\ matchgroup=ocamlEncl end=")"326\ contains=@ocamlTypeExpr,ocamlComment,ocamlPpx327 328syn cluster ocamlTypeExpr add=ocamlTypeKeyChar,ocamlTypeAs329syn match    ocamlTypeKeyChar  contained  "->"330syn match    ocamlTypeKeyChar  contained  "\*"331syn match    ocamlTypeKeyChar  contained  "#"332syn match    ocamlTypeKeyChar  contained  ","333syn match    ocamlTypeKeyChar  contained  "\."334syn keyword  ocamlTypeAs       contained  as335hi link ocamlTypeAs ocamlKeyword336 337syn cluster ocamlTypeExpr add=ocamlTypeVariance338syn match ocamlTypeVariance contained "[-+!]\ze *\('\|\<_\>\)"339syn match ocamlTypeVariance contained "[-+] *!\+\ze *\('\|\<_\>\)"340syn match ocamlTypeVariance contained "! *[-+]\+\ze *\('\|\<_\>\)"341 342syn cluster ocamlTypeContained add=ocamlTypeEq343syn match    ocamlTypeEq       contained  "[+:]\?="344hi link ocamlTypeEq ocamlKeyChar345 346syn cluster ocamlTypeExpr add=ocamlTypeVar,ocamlTypeConstr,ocamlTypeAnyVar,ocamlTypeBuiltin347syn match    ocamlTypeVar      contained   "'\(\l\|_\)\(\w\|'\)*\>"348syn match    ocamlTypeConstr   contained  "\<\(\l\|_\)\(\w\|'\)*\>"349" NOTE: for correct precedence, the rule for the wildcard (ocamlTypeAnyVar)350" must come after the rule for type constructors (ocamlTypeConstr).351syn match    ocamlTypeAnyVar   contained  "\<_\>"352" NOTE: For correct precedence, these builtin names must occur after the rule353" for type constructors (ocamlTypeConstr) but before the rule for non-optional354" labeled arguments (ocamlTypeLabel). For the latter to take precedence over355" these builtin names, we use “syn match” here instead of “syn keyword”.356syn match    ocamlTypeBuiltin  contained  "\<array\>"357syn match    ocamlTypeBuiltin  contained  "\<bool\>"358syn match    ocamlTypeBuiltin  contained  "\<bytes\>"359syn match    ocamlTypeBuiltin  contained  "\<char\>"360syn match    ocamlTypeBuiltin  contained  "\<exn\>"361syn match    ocamlTypeBuiltin  contained  "\<float\>"362syn match    ocamlTypeBuiltin  contained  "\<format\>"363syn match    ocamlTypeBuiltin  contained  "\<format4\>"364syn match    ocamlTypeBuiltin  contained  "\<format6\>"365syn match    ocamlTypeBuiltin  contained  "\<in_channel\>"366syn match    ocamlTypeBuiltin  contained  "\<int\>"367syn match    ocamlTypeBuiltin  contained  "\<int32\>"368syn match    ocamlTypeBuiltin  contained  "\<int64\>"369syn match    ocamlTypeBuiltin  contained  "\<lazy_t\>"370syn match    ocamlTypeBuiltin  contained  "\<list\>"371syn match    ocamlTypeBuiltin  contained  "\<nativeint\>"372syn match    ocamlTypeBuiltin  contained  "\<option\>"373syn match    ocamlTypeBuiltin  contained  "\<out_channel\>"374syn match    ocamlTypeBuiltin  contained  "\<ref\>"375syn match    ocamlTypeBuiltin  contained  "\<result\>"376syn match    ocamlTypeBuiltin  contained  "\<scanner\>"377syn match    ocamlTypeBuiltin  contained  "\<string\>"378syn match    ocamlTypeBuiltin  contained  "\<unit\>"379 380syn cluster ocamlTypeExpr add=ocamlTypeLabel381syn match    ocamlTypeLabel    contained  "?\?\(\l\|_\)\(\w\|'\)*\_s*:[>=]\@!"382hi link ocamlTypeLabel ocamlLabel383 384" Object type385syn cluster ocamlTypeExpr add=ocamlTypeObject386syn region ocamlTypeObject contained387\ matchgroup=ocamlEncl start="<"388\ matchgroup=ocamlEncl end=">"389\ contains=ocamlTypeObjectDots,ocamlLCIdentifier,ocamlTypeObjectAnnot,ocamlTypeBlank,ocamlComment,ocamlPpx390hi link ocamlTypeObject ocamlTypeCatchAll391syn cluster ocamlTypeContained add=ocamlTypeObjectDots392syn match ocamlTypeObjectDots contained "\.\."393hi link ocamlTypeObjectDots ocamlKeyChar394syn cluster ocamlTypeContained add=ocamlTypeObjectAnnot395syn region ocamlTypeObjectAnnot contained396\ matchgroup=ocamlKeyChar start=":"397\ matchgroup=ocamlKeyChar end=";\|>\@="398\ contains=@ocamlTypeExpr,ocamlComment,ocamlPpx399hi link ocamlTypeObjectAnnot ocamlTypeCatchAll400 401" Record type definition402syn cluster ocamlTypeContained add=ocamlTypeRecordDecl403syn region ocamlTypeRecordDecl contained404\ matchgroup=ocamlEncl start="{"405\ matchgroup=ocamlEncl end="}"406\ contains=ocamlTypeMutable,ocamlLCIdentifier,ocamlTypeRecordAnnot,ocamlTypeBlank,ocamlComment,ocamlPpx407hi link ocamlTypeRecordDecl ocamlTypeCatchAll408syn cluster ocamlTypeContained add=ocamlTypeMutable409syn keyword ocamlTypeMutable contained mutable410hi link ocamlTypeMutable ocamlKeyword411syn cluster ocamlTypeContained add=ocamlTypeRecordAnnot412syn region ocamlTypeRecordAnnot contained413\ matchgroup=ocamlKeyChar start=":"414\ matchgroup=ocamlKeyChar end=";\|}\@="415\ contains=@ocamlTypeExpr,ocamlComment,ocamlPpx416hi link ocamlTypeRecordAnnot ocamlTypeCatchAll417 418" Polymorphic variant types419" NOTE: Carefully avoid catching "[@" here.420syn cluster ocamlTypeExpr add=ocamlTypeVariant421syn region ocamlTypeVariant contained422\ matchgroup=ocamlEncl start="\[>" start="\[<" start="\[@\@!"423\ matchgroup=ocamlEncl end="\]"424\ contains=ocamlTypeVariantKeyChar,ocamlTypeVariantConstr,ocamlTypeVariantAnnot,ocamlTypeBlank,ocamlComment,ocamlPpx425hi link ocamlTypeVariant ocamlTypeCatchAll426syn cluster ocamlTypeContained add=ocamlTypeVariantKeyChar427syn match ocamlTypeVariantKeyChar contained "|"428syn match ocamlTypeVariantKeyChar contained ">"429hi link ocamlTypeVariantKeyChar ocamlKeyChar430syn cluster ocamlTypeContained add=ocamlTypeVariantConstr431syn match ocamlTypeVariantConstr contained "`\w\(\w\|'\)*\>"432hi link ocamlTypeVariantConstr ocamlConstructor433syn cluster ocamlTypeContained add=ocamlTypeVariantAnnot434syn region ocamlTypeVariantAnnot contained435\ matchgroup=ocamlKeyword start="\<of\>"436\ matchgroup=ocamlKeyChar end="|\|>\|\]\@="437\ contains=@ocamlTypeExpr,ocamlTypeAmp,ocamlComment,ocamlPpx438hi link ocamlTypeVariantAnnot ocamlTypeCatchAll439syn cluster ocamlTypeContained add=ocamlTypeAmp440syn match ocamlTypeAmp contained "&"441hi link ocamlTypeAmp ocamlTypeKeyChar442 443" Sum type definition444syn cluster ocamlTypeContained add=ocamlTypeSumDecl445syn region ocamlTypeSumDecl contained446\ matchgroup=ocamlTypeSumBar    start="|"447\ matchgroup=ocamlTypeSumConstr start="\<\u\(\w\|'\)*\>"448\ matchgroup=ocamlTypeSumConstr start="\<false\>" start="\<true\>"449\ matchgroup=ocamlTypeSumConstr start="(\_s*)" start="\[\_s*]" start="(\_s*::\_s*)"450\ matchgroup=NONE end="\(\<type\>\|\<exception\>\|\<val\>\|\<module\>\|\<class\>\|\<method\>\|\<constraint\>\|\<inherit\>\|\<object\>\|\<struct\>\|\<open\>\|\<include\>\|\<let\>\|\<external\>\|\<in\>\|\<end\>\|)\|]\|}\|;\|;;\|=\)\@="451\ matchgroup=NONE end="\(\<and\>\)\@="452\ contains=ocamlTypeSumBar,ocamlTypeSumConstr,ocamlTypeSumAnnot,ocamlTypeBlank,ocamlComment,ocamlPpx453hi link ocamlTypeSumDecl ocamlTypeCatchAll454syn cluster ocamlTypeContained add=ocamlTypeSumBar455syn match ocamlTypeSumBar contained "|"456hi link ocamlTypeSumBar ocamlKeyChar457syn cluster ocamlTypeContained add=ocamlTypeSumConstr458syn match ocamlTypeSumConstr contained "\<\u\(\w\|'\)*\>"459syn match ocamlTypeSumConstr contained "\<false\>"460syn match ocamlTypeSumConstr contained "\<true\>"461syn match ocamlTypeSumConstr contained "(\_s*)"462syn match ocamlTypeSumConstr contained "\[\_s*]"463syn match ocamlTypeSumConstr contained "(\_s*::\_s*)"464hi link ocamlTypeSumConstr ocamlConstructor465syn cluster ocamlTypeContained add=ocamlTypeSumAnnot466syn region ocamlTypeSumAnnot contained467\ matchgroup=ocamlKeyword start="\<of\>"468\ matchgroup=ocamlKeyChar start=":"469\ matchgroup=NONE end="|\@="470\ matchgroup=NONE end="\(\<type\>\|\<exception\>\|\<val\>\|\<module\>\|\<class\>\|\<method\>\|\<constraint\>\|\<inherit\>\|\<object\>\|\<struct\>\|\<open\>\|\<include\>\|\<let\>\|\<external\>\|\<in\>\|\<end\>\|)\|]\|}\|;\|;;\)\@="471\ matchgroup=NONE end="\(\<and\>\)\@="472\ contains=@ocamlTypeExpr,ocamlTypeRecordDecl,ocamlComment,ocamlPpx473hi link ocamlTypeSumAnnot ocamlTypeCatchAll474 475" Type context opened by “type” (type definition), “constraint” (type476" constraint) and “exception” (exception definition)477syn region ocamlTypeDef478\ matchgroup=ocamlKeyword start="\<type\>\(\_s\+\<nonrec\>\)\?\|\<constraint\>\|\<exception\>"479\ matchgroup=NONE end="\(\<type\>\|\<exception\>\|\<val\>\|\<module\>\|\<class\>\|\<method\>\|\<constraint\>\|\<inherit\>\|\<object\>\|\<struct\>\|\<open\>\|\<include\>\|\<let\>\|\<external\>\|\<in\>\|\<end\>\|)\|]\|}\|;\|;;\)\@="480\ contains=@ocamlTypeExpr,ocamlTypeEq,ocamlTypePrivate,ocamlTypeDefDots,ocamlTypeRecordDecl,ocamlTypeSumDecl,ocamlTypeDefAnd,ocamlComment,ocamlPpx481hi link ocamlTypeDef ocamlTypeCatchAll482syn cluster ocamlTypeContained add=ocamlTypePrivate483syn keyword ocamlTypePrivate contained private484hi link ocamlTypePrivate ocamlKeyword485syn cluster ocamlTypeContained add=ocamlTypeDefAnd486syn keyword ocamlTypeDefAnd contained and487hi link ocamlTypeDefAnd ocamlKeyword488syn cluster ocamlTypeContained add=ocamlTypeDefDots489syn match ocamlTypeDefDots contained "\.\."490hi link ocamlTypeDefDots ocamlKeyChar491 492" When "exception" is preceded by "with", "|" or "(", that’s not an exception493" definition but an exception pattern; we simply highlight the keyword without494" starting a type context.495" NOTE: These rules must occur after that for "exception".496syn match ocamlKeyword "\<with\_s\+exception\>"lc=4497syn match ocamlKeyword "|\_s*exception\>"lc=1498syn match ocamlKeyword "(\_s*exception\>"lc=1499 500" Type context opened by “:” (countless kinds of type annotations) and “:>”501" (type coercions)502syn region ocamlTypeAnnot matchgroup=ocamlKeyChar start=":\(>\|\_s*type\>\|[>:=]\@!\)"503\ matchgroup=NONE end="\(\<type\>\|\<exception\>\|\<val\>\|\<module\>\|\<class\>\|\<method\>\|\<constraint\>\|\<inherit\>\|\<object\>\|\<struct\>\|\<open\>\|\<include\>\|\<let\>\|\<external\>\|\<in\>\|\<end\>\|)\|]\|}\|;\|;;\)\@="504\ matchgroup=NONE end="\(;\|}\)\@="505\ matchgroup=NONE end="\(=\|:>\)\@="506\ contains=@ocamlTypeExpr,ocamlComment,ocamlPpx507hi link ocamlTypeAnnot ocamlTypeCatchAll508 509" Type annotation that gives the return type of a `fun` keyword510" (the type context is ended by `->`)511syn cluster ocamlTypeContained add=ocamlFunTypeAnnot512syn region ocamlFunTypeAnnot contained containedin=ocamlFun513\ matchgroup=ocamlKeyChar start=":"514\ matchgroup=NONE end="\(->\)\@="515\ contains=@ocamlTypeExpr,ocamlComment,ocamlPpx516hi link ocamlFunTypeAnnot ocamlTypeCatchAll517 518" Module paths (including functors) in types.519" NOTE: This rule must occur after the rule for ocamlTypeSumDecl as it must take520" precedence over it (otherwise the module name would be mistakenly highlighted521" as a constructor).522" NOTE: Carefully avoid catching "(*" here.523syn cluster ocamlTypeExpr add=ocamlTypeModPath524syn match ocamlTypeModPath contained "\<\u\(\w\|'\)*\_s*\."525syn region ocamlTypeModPath contained transparent526\ matchgroup=ocamlModPath start="\<\u\(\w\|'\)*\_s*(\*\@!"527\ matchgroup=ocamlModPath end=")\_s*\."528\ contains=ocamlTypeDotlessModPath,ocamlTypeBlank,ocamlComment,ocamlPpx529hi link ocamlTypeModPath ocamlModPath530syn cluster ocamlTypeContained add=ocamlTypeDotlessModPath531syn match ocamlTypeDotlessModPath contained "\<\u\(\w\|'\)*\_s*\.\?"532syn region ocamlTypeDotlessModPath contained transparent533\ matchgroup=ocamlModPath start="\<\u\(\w\|'\)*\_s*(\*\@!"534\ matchgroup=ocamlModPath end=")\_s*\.\?"535\ contains=ocamlTypeDotlessModPath,ocamlTypeBlank,ocamlComment,ocamlPpx536hi link ocamlTypeDotlessModPath ocamlTypeModPath537 538""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""539 540" Synchronization541syn sync minlines=50542syn sync maxlines=500543 544if !exists("ocaml_revised")545  syn sync match ocamlDoSync      grouphere  ocamlDo      "\<do\>"546  syn sync match ocamlDoSync      groupthere ocamlDo      "\<done\>"547endif548 549if exists("ocaml_revised")550  syn sync match ocamlEndSync     grouphere  ocamlEnd     "\<\(object\)\>"551else552  syn sync match ocamlEndSync     grouphere  ocamlEnd     "\<\(begin\|object\)\>"553endif554 555syn sync match ocamlEndSync     groupthere ocamlEnd     "\<end\>"556syn sync match ocamlStructSync  grouphere  ocamlStruct  "\<struct\>"557syn sync match ocamlStructSync  groupthere ocamlStruct  "\<end\>"558syn sync match ocamlSigSync     grouphere  ocamlSig     "\<sig\>"559syn sync match ocamlSigSync     groupthere ocamlSig     "\<end\>"560 561" Define the default highlighting.562 563hi def link ocamlBraceErr	   Error564hi def link ocamlBrackErr	   Error565hi def link ocamlParenErr	   Error566hi def link ocamlArrErr	   Error567 568hi def link ocamlCountErr	   Error569hi def link ocamlDoErr	   Error570hi def link ocamlDoneErr	   Error571hi def link ocamlEndErr	   Error572hi def link ocamlThenErr	   Error573hi def link ocamlKwErr	   Error574 575hi def link ocamlCharErr	   Error576 577hi def link ocamlErr	   Error578 579hi def link ocamlComment	   Comment580hi def link ocamlShebang    ocamlComment581 582hi def link ocamlModPath	   Include583hi def link ocamlObject	   Include584hi def link ocamlModule	   Include585hi def link ocamlModParam1    Include586hi def link ocamlGenMod       Include587hi def link ocamlFullMod	   Include588hi def link ocamlFuncWith	   Include589hi def link ocamlModParam     Include590hi def link ocamlModTypeRestr Include591hi def link ocamlWith	   Include592hi def link ocamlMTDef	   Include593hi def link ocamlSigEncl	   ocamlModule594hi def link ocamlStructEncl	   ocamlModule595 596hi def link ocamlScript	   Include597 598hi def link ocamlConstructor  Constant599hi def link ocamlEmptyConstructor  ocamlConstructor600 601hi def link ocamlVal          Keyword602hi def link ocamlModTypePre   Keyword603hi def link ocamlModPreRHS    Keyword604hi def link ocamlFunctor	   Keyword605hi def link ocamlModTypeOf  Keyword606hi def link ocamlKeyword	   Keyword607hi def link ocamlMethod	   Include608hi def link ocamlArrow	   Keyword609hi def link ocamlKeyChar	   Keyword610hi def link ocamlAnyVar	   Keyword611hi def link ocamlTopStop	   Keyword612 613hi def link ocamlRefAssign    ocamlKeyChar614hi def link ocamlEqual        ocamlKeyChar615hi def link ocamlCons         ocamlInfixOp616 617hi def link ocamlPrefixOp       ocamlOperator618hi def link ocamlInfixOp        ocamlOperator619hi def link ocamlExtensionOp    ocamlOperator620hi def link ocamlIndexingOp     ocamlOperator621 622if exists("ocaml_highlight_operators")623    hi def link ocamlInfixOpKeyword ocamlOperator624    hi def link ocamlOperator       Operator625else626    hi def link ocamlInfixOpKeyword Keyword627endif628 629hi def link ocamlBoolean	   Boolean630hi def link ocamlCharacter    Character631hi def link ocamlNumber	   Number632hi def link ocamlFloat	   Float633hi def link ocamlString	   String634hi def link ocamlQuotedStringDelim Identifier635 636hi def link ocamlLabel	   Identifier637 638" Type linting groups that the user can customize:639" - ocamlTypeCatchAll: anything in a type context that is not caught by more640"   specific rules (in principle, this should only match syntax errors)641" - ocamlTypeConstr: type constructors642" - ocamlTypeBuiltin: builtin type constructors (like int or list)643" - ocamlTypeVar: type variables ('a)644" - ocamlTypeAnyVar: wildcard (_)645" - ocamlTypeVariance: variance and injectivity indications (+'a, !'a)646" - ocamlTypeKeyChar: symbols such as -> and *647" Default values below mimick the behavior before the type linter was648" implemented, but now we can do better. :-)649hi def link ocamlTypeCatchAll Error650hi def link ocamlTypeConstr   NONE651hi def link ocamlTypeBuiltin  Type652hi def link ocamlTypeVar      NONE653hi def link ocamlTypeAnyVar   NONE654hi def link ocamlTypeVariance ocamlKeyChar655hi def link ocamlTypeKeyChar  ocamlKeyChar656 657hi def link ocamlTodo	   Todo658 659hi def link ocamlEncl	   Keyword660 661hi def link ocamlPpxEncl       ocamlEncl662 663let b:current_syntax = "ocaml"664 665let &cpo = s:keepcpo666unlet s:keepcpo667 668" vim: ts=8669 
codekingpro/portable-devtools · Team Ai