" Karl-Heinz Sylla
" Issac Trotts
" URL: http://www.ocaml.info/vim/syntax/ocaml.vim
" Last Change: 2012 May 12 - Added Dominique Pellé's spell checking patch (MM)
" 2012 Feb 01 - Improved module path highlighting (MM)
" 2010 Oct 11 - Added highlighting of lnot (MM, thanks to Erick Matsen)
" A minor patch was applied to the official version so that object/end
" can be distinguished from begin/end, which is used for indentation,
" and folding. (David Baelde)
" 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") && b:current_syntax == "ocaml"
finish
endif
" OCaml is case sensitive.
syn case match
" Access to the method of an object
syn match ocamlMethod "#"
" Script headers highlighted like comments
syn match ocamlComment "^#!.*" contains=@Spell
" Scripting directives
syn match ocamlScript "^#\<\(quit\|labels\|warnings\|directory\|cd\|load\|use\|install_printer\|remove_printer\|require\|thread\|trace\|untrace\|untrace_all\|print_depth\|print_length\|camlp4o\)\>"
" lowercase identifier - the standard way to match
syn match ocamlLCIdentifier /\<\(\l\|_\)\(\w\|'\)*\>/
syn match ocamlKeyChar "|"
" Errors
syn match ocamlBraceErr "}"
syn match ocamlBrackErr "\]"
syn match ocamlParenErr ")"
syn match ocamlArrErr "|]"
syn match ocamlCommentErr "\*)"
syn match ocamlCountErr "\"
syn match ocamlCountErr "\"
if !exists("ocaml_revised")
syn match ocamlDoErr "\"
endif
syn match ocamlDoneErr "\"
syn match ocamlThenErr "\"
" Error-highlighting of "end" without synchronization:
" as keyword or as error (default)
if exists("ocaml_noend_error")
syn match ocamlKeyword "\"
else
syn match ocamlEndErr "\"
endif
" Some convenient clusters
syn cluster ocamlAllErrs contains=ocamlBraceErr,ocamlBrackErr,ocamlParenErr,ocamlCommentErr,ocamlCountErr,ocamlDoErr,ocamlDoneErr,ocamlEndErr,ocamlThenErr
syn cluster ocamlAENoParen contains=ocamlBraceErr,ocamlBrackErr,ocamlCommentErr,ocamlCountErr,ocamlDoErr,ocamlDoneErr,ocamlEndErr,ocamlThenErr
syn cluster ocamlContained contains=ocamlTodo,ocamlPreDef,ocamlModParam,ocamlModParam1,ocamlPreMPRestr,ocamlMPRestr,ocamlMPRestr1,ocamlMPRestr2,ocamlMPRestr3,ocamlModRHS,ocamlFuncWith,ocamlFuncStruct,ocamlModTypeRestr,ocamlModTRWith,ocamlWith,ocamlWithRest,ocamlModType,ocamlFullMod,ocamlVal
" Enclosing delimiters
syn region ocamlEncl transparent matchgroup=ocamlKeyword start="(" matchgroup=ocamlKeyword end=")" contains=ALLBUT,@ocamlContained,ocamlParenErr
syn region ocamlEncl transparent matchgroup=ocamlKeyword start="{" matchgroup=ocamlKeyword end="}" contains=ALLBUT,@ocamlContained,ocamlBraceErr
syn region ocamlEncl transparent matchgroup=ocamlKeyword start="\[" matchgroup=ocamlKeyword end="\]" contains=ALLBUT,@ocamlContained,ocamlBrackErr
syn region ocamlEncl transparent matchgroup=ocamlKeyword start="\[|" matchgroup=ocamlKeyword end="|\]" contains=ALLBUT,@ocamlContained,ocamlArrErr
" Comments
syn region ocamlComment start="(\*" end="\*)" contains=@Spell,ocamlComment,ocamlTodo
syn keyword ocamlTodo contained TODO FIXME XXX NOTE
" Objects
syn region ocamlEnd matchgroup=ocamlObject start="\