blob: 04ba39203df0e90a60dc95179e51c682710198b8 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim syntax file
2" Language: OCaml
3" Filenames: *.ml *.mli *.mll *.mly
Bram Moolenaar202795b2005-10-11 20:29:39 +00004" Maintainers: Markus Mottl <markus.mottl@gmail.com>
Bram Moolenaar5eb86f92004-07-26 12:53:41 +00005" Karl-Heinz Sylla <Karl-Heinz.Sylla@gmd.de>
6" Issac Trotts <ijtrotts@ucdavis.edu>
Bram Moolenaar7e6a5152021-01-02 16:39:53 +01007" URL: https://github.com/ocaml/vim-ocaml
Bram Moolenaar773a97c2019-06-06 20:39:55 +02008" Last Change:
Yinzuo Jiang700cf8c2024-07-14 17:02:33 +02009" 2019 Nov 05 - Accurate type highlighting (Maëlan)
Bram Moolenaar773a97c2019-06-06 20:39:55 +020010" 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)
Bram Moolenaar202795b2005-10-11 20:29:39 +000017
18" A minor patch was applied to the official version so that object/end
19" can be distinguished from begin/end, which is used for indentation,
20" and folding. (David Baelde)
Bram Moolenaar071d4272004-06-13 20:20:40 +000021
Bram Moolenaar7e6a5152021-01-02 16:39:53 +010022" Quit when a syntax file was already loaded
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020023if exists("b:current_syntax") && b:current_syntax == "ocaml"
Bram Moolenaar071d4272004-06-13 20:20:40 +000024 finish
25endif
26
Bram Moolenaar7e6a5152021-01-02 16:39:53 +010027let s:keepcpo = &cpo
28set cpo&vim
29
Bram Moolenaar773a97c2019-06-06 20:39:55 +020030" ' can be used in OCaml identifiers
31setlocal iskeyword+='
32
Bram Moolenaar7e6a5152021-01-02 16:39:53 +010033" ` is part of the name of polymorphic variants
34setlocal iskeyword+=`
35
Bram Moolenaar071d4272004-06-13 20:20:40 +000036" OCaml is case sensitive.
37syn case match
38
Bram Moolenaar20f90cf2011-05-19 12:22:51 +020039" Access to the method of an object
40syn match ocamlMethod "#"
41
Bram Moolenaar071d4272004-06-13 20:20:40 +000042" Scripting directives
Bram Moolenaar773a97c2019-06-06 20:39:55 +020043syn 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\)\>"
Bram Moolenaar9964e462007-05-05 17:54:07 +000044
Bram Moolenaar071d4272004-06-13 20:20:40 +000045" lowercase identifier - the standard way to match
46syn match ocamlLCIdentifier /\<\(\l\|_\)\(\w\|'\)*\>/
47
Bram Moolenaar071d4272004-06-13 20:20:40 +000048" Errors
49syn match ocamlBraceErr "}"
50syn match ocamlBrackErr "\]"
51syn match ocamlParenErr ")"
52syn match ocamlArrErr "|]"
53
Bram Moolenaar071d4272004-06-13 20:20:40 +000054syn match ocamlCountErr "\<downto\>"
55syn match ocamlCountErr "\<to\>"
56
57if !exists("ocaml_revised")
58 syn match ocamlDoErr "\<do\>"
59endif
60
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\>"
68else
69 syn match ocamlEndErr "\<end\>"
70endif
71
Yinzuo Jiang700cf8c2024-07-14 17:02:33 +020072" These keywords are only expected nested in constructions that are handled by
73" the type linter, so outside of type contexts we highlight them as errors:
74syn match ocamlKwErr "\<\(mutable\|nonrec\|of\|private\)\>"
75
Bram Moolenaar071d4272004-06-13 20:20:40 +000076" Some convenient clusters
Yinzuo Jiang700cf8c2024-07-14 17:02:33 +020077syn cluster ocamlAllErrs contains=@ocamlAENoParen,ocamlParenErr
78syn cluster ocamlAENoParen contains=ocamlBraceErr,ocamlBrackErr,ocamlCountErr,ocamlDoErr,ocamlDoneErr,ocamlEndErr,ocamlThenErr,ocamlKwErr
Bram Moolenaar071d4272004-06-13 20:20:40 +000079
Yinzuo Jiang700cf8c2024-07-14 17:02:33 +020080syn cluster ocamlContained contains=ocamlTodo,ocamlPreDef,ocamlModParam,ocamlModParam1,ocamlModTypePre,ocamlModRHS,ocamlFuncWith,ocamlModTypeRestr,ocamlModTRWith,ocamlWith,ocamlWithRest,ocamlFullMod,ocamlVal
Bram Moolenaar071d4272004-06-13 20:20:40 +000081
82
83" Enclosing delimiters
Yinzuo Jiang700cf8c2024-07-14 17:02:33 +020084syn region ocamlNone transparent matchgroup=ocamlEncl start="(" matchgroup=ocamlEncl end=")" contains=ALLBUT,@ocamlContained,ocamlParenErr
85syn region ocamlNone transparent matchgroup=ocamlEncl start="{" matchgroup=ocamlEncl end="}" contains=ALLBUT,@ocamlContained,ocamlBraceErr
86syn region ocamlNone transparent matchgroup=ocamlEncl start="\[" matchgroup=ocamlEncl end="\]" contains=ALLBUT,@ocamlContained,ocamlBrackErr
87syn region ocamlNone transparent matchgroup=ocamlEncl start="\[|" matchgroup=ocamlEncl end="|\]" contains=ALLBUT,@ocamlContained,ocamlArrErr
Bram Moolenaar071d4272004-06-13 20:20:40 +000088
89
90" Comments
Bram Moolenaar16ea3672013-07-28 16:02:18 +020091syn region ocamlComment start="(\*" end="\*)" contains=@Spell,ocamlComment,ocamlTodo
Bram Moolenaar202795b2005-10-11 20:29:39 +000092syn keyword ocamlTodo contained TODO FIXME XXX NOTE
Bram Moolenaar071d4272004-06-13 20:20:40 +000093
94
95" Objects
Bram Moolenaar202795b2005-10-11 20:29:39 +000096syn region ocamlEnd matchgroup=ocamlObject start="\<object\>" matchgroup=ocamlObject end="\<end\>" contains=ALLBUT,@ocamlContained,ocamlEndErr
Bram Moolenaar071d4272004-06-13 20:20:40 +000097
98
99" Blocks
100if !exists("ocaml_revised")
101 syn region ocamlEnd matchgroup=ocamlKeyword start="\<begin\>" matchgroup=ocamlKeyword end="\<end\>" contains=ALLBUT,@ocamlContained,ocamlEndErr
102endif
103
104
105" "for"
106syn region ocamlNone matchgroup=ocamlKeyword start="\<for\>" matchgroup=ocamlKeyword end="\<\(to\|downto\)\>" contains=ALLBUT,@ocamlContained,ocamlCountErr
107
108
109" "do"
110if !exists("ocaml_revised")
111 syn region ocamlDo matchgroup=ocamlKeyword start="\<do\>" matchgroup=ocamlKeyword end="\<done\>" contains=ALLBUT,@ocamlContained,ocamlDoneErr
112endif
113
114" "if"
115syn region ocamlNone matchgroup=ocamlKeyword start="\<if\>" matchgroup=ocamlKeyword end="\<then\>" contains=ALLBUT,@ocamlContained,ocamlThenErr
116
Bram Moolenaar773a97c2019-06-06 20:39:55 +0200117"" PPX nodes
118
119syn match ocamlPpxIdentifier /\(\[@\{1,3\}\)\@<=\w\+\(\.\w\+\)*/
120syn region ocamlPpx matchgroup=ocamlPpxEncl start="\[@\{1,3\}" contains=TOP end="\]"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000121
122"" Modules
123
Bram Moolenaar071d4272004-06-13 20:20:40 +0000124" "open"
Bram Moolenaar7e6a5152021-01-02 16:39:53 +0100125syn match ocamlKeyword "\<open\>" skipwhite skipempty nextgroup=ocamlFullMod
Bram Moolenaar071d4272004-06-13 20:20:40 +0000126
127" "include"
Bram Moolenaar202795b2005-10-11 20:29:39 +0000128syn match ocamlKeyword "\<include\>" skipwhite skipempty nextgroup=ocamlModParam,ocamlFullMod
Bram Moolenaar071d4272004-06-13 20:20:40 +0000129
130" "module" - somewhat complicated stuff ;-)
Yinzuo Jiang700cf8c2024-07-14 17:02:33 +0200131" 2022-10: please document it?
132syn region ocamlModule matchgroup=ocamlKeyword start="\<module\>" matchgroup=ocamlModule end="\<_\|\u\(\w\|'\)*\>" contains=@ocamlAllErrs,ocamlComment skipwhite skipempty nextgroup=ocamlPreDef
133syn region ocamlPreDef start="."me=e-1 end="[a-z:=)]\@=" contained contains=@ocamlAllErrs,ocamlComment,ocamlModParam,ocamlGenMod,ocamlModTypeRestr nextgroup=ocamlModTypePre,ocamlModPreRHS
134syn region ocamlModParam start="(\*\@!" end=")" contained contains=ocamlGenMod,ocamlModParam,ocamlModParam1,ocamlSig,ocamlVal
Bram Moolenaar773a97c2019-06-06 20:39:55 +0200135syn match ocamlModParam1 "\<\u\(\w\|'\)*\>" contained skipwhite skipempty
136syn match ocamlGenMod "()" contained skipwhite skipempty
Bram Moolenaar071d4272004-06-13 20:20:40 +0000137
Yinzuo Jiang700cf8c2024-07-14 17:02:33 +0200138syn match ocamlModTypePre ":" contained skipwhite skipempty nextgroup=ocamlModTRWith,ocamlSig,ocamlFunctor,ocamlModTypeRestr,ocamlModTypeOf
139syn match ocamlModTypeRestr "\<\w\(\w\|'\)*\( *\. *\w\(\w\|'\)*\)*\>" contained
140
Bram Moolenaar071d4272004-06-13 20:20:40 +0000141syn match ocamlModPreRHS "=" contained skipwhite skipempty nextgroup=ocamlModParam,ocamlFullMod
Bram Moolenaar20f90cf2011-05-19 12:22:51 +0200142syn keyword ocamlKeyword val
Yinzuo Jiang700cf8c2024-07-14 17:02:33 +0200143syn region ocamlVal matchgroup=ocamlKeyword start="\<val\>" matchgroup=ocamlLCIdentifier end="\<\l\(\w\|'\)*\>" contains=@ocamlAllErrs,ocamlComment,ocamlFullMod skipwhite skipempty nextgroup=ocamlModTypePre
Bram Moolenaar16ea3672013-07-28 16:02:18 +0200144syn region ocamlModRHS start="." end=". *\w\|([^*]"me=e-2 contained contains=ocamlComment skipwhite skipempty nextgroup=ocamlModParam,ocamlFullMod
145syn match ocamlFullMod "\<\u\(\w\|'\)*\( *\. *\u\(\w\|'\)*\)*" contained skipwhite skipempty nextgroup=ocamlFuncWith
Bram Moolenaar071d4272004-06-13 20:20:40 +0000146
Yinzuo Jiang700cf8c2024-07-14 17:02:33 +0200147syn region ocamlFuncWith start="([*)]\@!" end=")" contained contains=ocamlComment,ocamlWith,ocamlStruct skipwhite skipempty nextgroup=ocamlFuncWith
Bram Moolenaar071d4272004-06-13 20:20:40 +0000148
Yinzuo Jiang700cf8c2024-07-14 17:02:33 +0200149syn region ocamlModTRWith start="(\*\@!" end=")" contained contains=@ocamlAENoParen,ocamlWith
Bram Moolenaar16ea3672013-07-28 16:02:18 +0200150syn match ocamlWith "\<\(\u\(\w\|'\)* *\. *\)*\w\(\w\|'\)*\>" contained skipwhite skipempty nextgroup=ocamlWithRest
Bram Moolenaar071d4272004-06-13 20:20:40 +0000151syn region ocamlWithRest start="[^)]" end=")"me=e-1 contained contains=ALLBUT,@ocamlContained
152
Bram Moolenaar20f90cf2011-05-19 12:22:51 +0200153" "struct"
Bram Moolenaar773a97c2019-06-06 20:39:55 +0200154syn region ocamlStruct matchgroup=ocamlStructEncl start="\<\(module\s\+\)\=struct\>" matchgroup=ocamlStructEncl end="\<end\>" contains=ALLBUT,@ocamlContained,ocamlEndErr
Bram Moolenaar20f90cf2011-05-19 12:22:51 +0200155
Yinzuo Jiang700cf8c2024-07-14 17:02:33 +0200156" "sig"
157syn region ocamlSig matchgroup=ocamlSigEncl start="\<sig\>" matchgroup=ocamlSigEncl end="\<end\>" contains=ALLBUT,@ocamlContained,ocamlEndErr
158
159" "functor"
160syn region ocamlFunctor start="\<functor\>" matchgroup=ocamlKeyword end="->" contains=@ocamlAllErrs,ocamlComment,ocamlModParam,ocamlGenMod skipwhite skipempty nextgroup=ocamlStruct,ocamlSig,ocamlFuncWith,ocamlFunctor
161
Bram Moolenaar071d4272004-06-13 20:20:40 +0000162" "module type"
Yinzuo Jiang700cf8c2024-07-14 17:02:33 +0200163syn region ocamlModTypeOf start="\<module\s\+type\(\s\+of\)\=\>" matchgroup=ocamlModule end="\<\w\(\w\|'\)*\>" contains=ocamlComment skipwhite skipempty nextgroup=ocamlMTDef
Bram Moolenaar16ea3672013-07-28 16:02:18 +0200164syn match ocamlMTDef "=\s*\w\(\w\|'\)*\>"hs=s+1,me=s+1 skipwhite skipempty nextgroup=ocamlFullMod
Bram Moolenaar071d4272004-06-13 20:20:40 +0000165
Bram Moolenaar773a97c2019-06-06 20:39:55 +0200166" Quoted strings
167syn region ocamlString matchgroup=ocamlQuotedStringDelim start="{\z\([a-z_]*\)|" end="|\z1}" contains=@Spell
Yinzuo Jiang700cf8c2024-07-14 17:02:33 +0200168syn region ocamlString matchgroup=ocamlQuotedStringDelim start="{%[a-z_]\+\(\.[a-z_]\+\)\?\( \z\([a-z_]\+\)\)\?|" end="|\z1}" contains=@Spell
Bram Moolenaar773a97c2019-06-06 20:39:55 +0200169
Bram Moolenaar071d4272004-06-13 20:20:40 +0000170syn keyword ocamlKeyword and as assert class
Yinzuo Jiang700cf8c2024-07-14 17:02:33 +0200171syn keyword ocamlKeyword else
172syn keyword ocamlKeyword external
Bram Moolenaar071d4272004-06-13 20:20:40 +0000173syn keyword ocamlKeyword in inherit initializer
Bram Moolenaar773a97c2019-06-06 20:39:55 +0200174syn keyword ocamlKeyword lazy let match
Yinzuo Jiang700cf8c2024-07-14 17:02:33 +0200175syn keyword ocamlKeyword method new
176syn keyword ocamlKeyword parser rec
177syn keyword ocamlKeyword try
Bram Moolenaar20f90cf2011-05-19 12:22:51 +0200178syn keyword ocamlKeyword virtual when while with
Bram Moolenaar071d4272004-06-13 20:20:40 +0000179
Yinzuo Jiang700cf8c2024-07-14 17:02:33 +0200180" Keywords which are handled by the type linter:
181" as (within a type equation)
182" constraint exception mutable nonrec of private type
183
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 ocamlFunTypeAnnot
187" 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,ocamlTypeAnnot
190
Bram Moolenaar071d4272004-06-13 20:20:40 +0000191if exists("ocaml_revised")
192 syn keyword ocamlKeyword do value
193 syn keyword ocamlBoolean True False
194else
195 syn keyword ocamlKeyword function
196 syn keyword ocamlBoolean true false
Bram Moolenaar071d4272004-06-13 20:20:40 +0000197endif
198
Yinzuo Jiang700cf8c2024-07-14 17:02:33 +0200199syn match ocamlEmptyConstructor "(\s*)"
200syn match ocamlEmptyConstructor "\[\s*\]"
201syn match ocamlEmptyConstructor "\[|\s*>|]"
202syn match ocamlEmptyConstructor "\[<\s*>\]"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000203syn match ocamlConstructor "\u\(\w\|'\)*\>"
204
205" Polymorphic variants
206syn match ocamlConstructor "`\w\(\w\|'\)*\>"
207
208" Module prefix
Bram Moolenaar16ea3672013-07-28 16:02:18 +0200209syn match ocamlModPath "\u\(\w\|'\)* *\."he=e-1
Bram Moolenaar071d4272004-06-13 20:20:40 +0000210
211syn match ocamlCharacter "'\\\d\d\d'\|'\\[\'ntbr]'\|'.'"
Bram Moolenaar20f90cf2011-05-19 12:22:51 +0200212syn match ocamlCharacter "'\\x\x\x'"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000213syn match ocamlCharErr "'\\\d\d'\|'\\\d'"
214syn match ocamlCharErr "'\\[^\'ntbr]'"
Bram Moolenaar16ea3672013-07-28 16:02:18 +0200215syn region ocamlString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=@Spell
Bram Moolenaar071d4272004-06-13 20:20:40 +0000216
Bram Moolenaar071d4272004-06-13 20:20:40 +0000217syn match ocamlAnyVar "\<_\>"
Yinzuo Jiang700cf8c2024-07-14 17:02:33 +0200218syn match ocamlKeyChar "|]\@!"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000219syn match ocamlKeyChar ";"
220syn match ocamlKeyChar "\~"
221syn match ocamlKeyChar "?"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000222
Yinzuo Jiang700cf8c2024-07-14 17:02:33 +0200223" NOTE: for correct precedence, the rule for ";;" must come after that for ";"
224syn match ocamlTopStop ";;"
225
Bram Moolenaar773a97c2019-06-06 20:39:55 +0200226"" Operators
227
228" The grammar of operators is found there:
229" https://caml.inria.fr/pub/docs/manual-ocaml/names.html#operator-name
230" https://caml.inria.fr/pub/docs/manual-ocaml/extn.html#s:ext-ops
231" https://caml.inria.fr/pub/docs/manual-ocaml/extn.html#s:index-operators
Yinzuo Jiang700cf8c2024-07-14 17:02:33 +0200232" = is both an operator name and a keyword, we let the user choose how
233" to display it (has to be declared before regular infix operators):
Bram Moolenaar773a97c2019-06-06 20:39:55 +0200234syn match ocamlEqual "="
Bram Moolenaar773a97c2019-06-06 20:39:55 +0200235" Custom indexing operators:
Bram Moolenaar7e6a5152021-01-02 16:39:53 +0100236syn region ocamlIndexing matchgroup=ocamlIndexingOp
237 \ start="\.[~?!:|&$%=>@^/*+-][~?!.:|&$%<=>@^*/+-]*\_s*("
238 \ end=")\(\_s*<-\)\?"
239 \ contains=ALLBUT,@ocamlContained,ocamlParenErr
240syn region ocamlIndexing matchgroup=ocamlIndexingOp
241 \ start="\.[~?!:|&$%=>@^/*+-][~?!.:|&$%<=>@^*/+-]*\_s*\["
242 \ end="]\(\_s*<-\)\?"
243 \ contains=ALLBUT,@ocamlContained,ocamlBrackErr
244syn region ocamlIndexing matchgroup=ocamlIndexingOp
245 \ start="\.[~?!:|&$%=>@^/*+-][~?!.:|&$%<=>@^*/+-]*\_s*{"
246 \ end="}\(\_s*<-\)\?"
247 \ contains=ALLBUT,@ocamlContained,ocamlBraceErr
Bram Moolenaar773a97c2019-06-06 20:39:55 +0200248" Extension operators (has to be declared before regular infix operators):
249syn match ocamlExtensionOp "#[#~?!.:|&$%<=>@^*/+-]\+"
250" Infix and prefix operators:
251syn match ocamlPrefixOp "![~?!.:|&$%<=>@^*/+-]*"
252syn match ocamlPrefixOp "[~?][~?!.:|&$%<=>@^*/+-]\+"
Yinzuo Jiang700cf8c2024-07-14 17:02:33 +0200253syn match ocamlInfixOp "[&$%<>@^*/+-][~?!.:|&$%<=>@^*/+-]*"
254syn match ocamlInfixOp "[|=][~?!.:|&$%<=>@^*/+-]\+"
Bram Moolenaar773a97c2019-06-06 20:39:55 +0200255syn match ocamlInfixOp "#[~?!.:|&$%<=>@^*/+-]\+#\@!"
256syn match ocamlInfixOp "!=[~?!.:|&$%<=>@^*/+-]\@!"
257syn keyword ocamlInfixOpKeyword asr land lor lsl lsr lxor mod or
258" := is technically an infix operator, but we may want to show it as a keyword
259" (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 "->[~?!.:|&$%<=>@^*/+-]\@!"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000265if exists("ocaml_revised")
Bram Moolenaar773a97c2019-06-06 20:39:55 +0200266 syn match ocamlErr "<-[~?!.:|&$%<=>@^*/+-]\@!"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000267else
Bram Moolenaar773a97c2019-06-06 20:39:55 +0200268 syn match ocamlKeyChar "<-[~?!.:|&$%<=>@^*/+-]\@!"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000269endif
270
Yinzuo Jiang700cf8c2024-07-14 17:02:33 +0200271" Script shebang (has to be declared after operators)
272syn match ocamlShebang "\%1l^#!.*$"
273
Bram Moolenaar773a97c2019-06-06 20:39:55 +0200274syn 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\)*\)\=\>"
Bram Moolenaar071d4272004-06-13 20:20:40 +0000279
280" Labels
Yinzuo Jiang700cf8c2024-07-14 17:02:33 +0200281syn match ocamlLabel "[~?]\(\l\|_\)\(\w\|'\)*:\?"
Bram Moolenaar773a97c2019-06-06 20:39:55 +0200282syn region ocamlLabel transparent matchgroup=ocamlLabel start="[~?](\(\l\|_\)\(\w\|'\)*"lc=2 end=")"me=e-1 contains=ALLBUT,@ocamlContained,ocamlParenErr
Bram Moolenaar071d4272004-06-13 20:20:40 +0000283
Yinzuo Jiang700cf8c2024-07-14 17:02:33 +0200284""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
285
286"" Type contexts
287
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 expression
292" (in a loose sense, e.g. the “as” keyword and universal quantification are
293" 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 type
298" 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 main
300" linter.
301"
302" Both clusters are filled in incrementally. Every match group that is not to be
303" found at the main level must be declared as “contained” and added to either
304" 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 clusters
308" is also put in ocamlContained and thus ignored by the main linter.
309
310"syn cluster ocamlTypeExpr contains=
311syn cluster ocamlTypeContained contains=@ocamlTypeExpr
312syn cluster ocamlContained add=@ocamlTypeContained
313
314" We’ll use a “catch-all” highlighting group to show as error anything that is
315" not matched more specifically; we don’t want spaces to be reported as errors
316" (different background color), so we just catch them here:
317syn cluster ocamlTypeExpr add=ocamlTypeBlank
318syn match ocamlTypeBlank contained "\_s\+"
319hi link ocamlTypeBlank NONE
320
321" NOTE: Carefully avoid catching "(*" here.
322syn cluster ocamlTypeExpr add=ocamlTypeParen
323syn region ocamlTypeParen contained transparent
324\ matchgroup=ocamlEncl start="(\*\@!"
325\ matchgroup=ocamlEncl end=")"
326\ contains=@ocamlTypeExpr,ocamlComment,ocamlPpx
327
328syn cluster ocamlTypeExpr add=ocamlTypeKeyChar,ocamlTypeAs
329syn match ocamlTypeKeyChar contained "->"
330syn match ocamlTypeKeyChar contained "\*"
331syn match ocamlTypeKeyChar contained "#"
332syn match ocamlTypeKeyChar contained ","
333syn match ocamlTypeKeyChar contained "\."
334syn keyword ocamlTypeAs contained as
335hi link ocamlTypeAs ocamlKeyword
336
337syn cluster ocamlTypeExpr add=ocamlTypeVariance
338syn match ocamlTypeVariance contained "[-+!]\ze *\('\|\<_\>\)"
339syn match ocamlTypeVariance contained "[-+] *!\+\ze *\('\|\<_\>\)"
340syn match ocamlTypeVariance contained "! *[-+]\+\ze *\('\|\<_\>\)"
341
342syn cluster ocamlTypeContained add=ocamlTypeEq
343syn match ocamlTypeEq contained "[+:]\?="
344hi link ocamlTypeEq ocamlKeyChar
345
346syn cluster ocamlTypeExpr add=ocamlTypeVar,ocamlTypeConstr,ocamlTypeAnyVar,ocamlTypeBuiltin
347syn 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 rule
353" for type constructors (ocamlTypeConstr) but before the rule for non-optional
354" labeled arguments (ocamlTypeLabel). For the latter to take precedence over
355" 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=ocamlTypeLabel
381syn match ocamlTypeLabel contained "?\?\(\l\|_\)\(\w\|'\)*\_s*:[>=]\@!"
382hi link ocamlTypeLabel ocamlLabel
383
384" Object type
385syn cluster ocamlTypeExpr add=ocamlTypeObject
386syn region ocamlTypeObject contained
387\ matchgroup=ocamlEncl start="<"
388\ matchgroup=ocamlEncl end=">"
389\ contains=ocamlTypeObjectDots,ocamlLCIdentifier,ocamlTypeObjectAnnot,ocamlTypeBlank,ocamlComment,ocamlPpx
390hi link ocamlTypeObject ocamlTypeCatchAll
391syn cluster ocamlTypeContained add=ocamlTypeObjectDots
392syn match ocamlTypeObjectDots contained "\.\."
393hi link ocamlTypeObjectDots ocamlKeyChar
394syn cluster ocamlTypeContained add=ocamlTypeObjectAnnot
395syn region ocamlTypeObjectAnnot contained
396\ matchgroup=ocamlKeyChar start=":"
397\ matchgroup=ocamlKeyChar end=";\|>\@="
398\ contains=@ocamlTypeExpr,ocamlComment,ocamlPpx
399hi link ocamlTypeObjectAnnot ocamlTypeCatchAll
400
401" Record type definition
402syn cluster ocamlTypeContained add=ocamlTypeRecordDecl
403syn region ocamlTypeRecordDecl contained
404\ matchgroup=ocamlEncl start="{"
405\ matchgroup=ocamlEncl end="}"
406\ contains=ocamlTypeMutable,ocamlLCIdentifier,ocamlTypeRecordAnnot,ocamlTypeBlank,ocamlComment,ocamlPpx
407hi link ocamlTypeRecordDecl ocamlTypeCatchAll
408syn cluster ocamlTypeContained add=ocamlTypeMutable
409syn keyword ocamlTypeMutable contained mutable
410hi link ocamlTypeMutable ocamlKeyword
411syn cluster ocamlTypeContained add=ocamlTypeRecordAnnot
412syn region ocamlTypeRecordAnnot contained
413\ matchgroup=ocamlKeyChar start=":"
414\ matchgroup=ocamlKeyChar end=";\|}\@="
415\ contains=@ocamlTypeExpr,ocamlComment,ocamlPpx
416hi link ocamlTypeRecordAnnot ocamlTypeCatchAll
417
418" Polymorphic variant types
419" NOTE: Carefully avoid catching "[@" here.
420syn cluster ocamlTypeExpr add=ocamlTypeVariant
421syn region ocamlTypeVariant contained
422\ matchgroup=ocamlEncl start="\[>" start="\[<" start="\[@\@!"
423\ matchgroup=ocamlEncl end="\]"
424\ contains=ocamlTypeVariantKeyChar,ocamlTypeVariantConstr,ocamlTypeVariantAnnot,ocamlTypeBlank,ocamlComment,ocamlPpx
425hi link ocamlTypeVariant ocamlTypeCatchAll
426syn cluster ocamlTypeContained add=ocamlTypeVariantKeyChar
427syn match ocamlTypeVariantKeyChar contained "|"
428syn match ocamlTypeVariantKeyChar contained ">"
429hi link ocamlTypeVariantKeyChar ocamlKeyChar
430syn cluster ocamlTypeContained add=ocamlTypeVariantConstr
431syn match ocamlTypeVariantConstr contained "`\w\(\w\|'\)*\>"
432hi link ocamlTypeVariantConstr ocamlConstructor
433syn cluster ocamlTypeContained add=ocamlTypeVariantAnnot
434syn region ocamlTypeVariantAnnot contained
435\ matchgroup=ocamlKeyword start="\<of\>"
436\ matchgroup=ocamlKeyChar end="|\|>\|\]\@="
437\ contains=@ocamlTypeExpr,ocamlTypeAmp,ocamlComment,ocamlPpx
438hi link ocamlTypeVariantAnnot ocamlTypeCatchAll
439syn cluster ocamlTypeContained add=ocamlTypeAmp
440syn match ocamlTypeAmp contained "&"
441hi link ocamlTypeAmp ocamlTypeKeyChar
442
443" Sum type definition
444syn cluster ocamlTypeContained add=ocamlTypeSumDecl
445syn region ocamlTypeSumDecl contained
446\ 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,ocamlPpx
453hi link ocamlTypeSumDecl ocamlTypeCatchAll
454syn cluster ocamlTypeContained add=ocamlTypeSumBar
455syn match ocamlTypeSumBar contained "|"
456hi link ocamlTypeSumBar ocamlKeyChar
457syn cluster ocamlTypeContained add=ocamlTypeSumConstr
458syn 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 ocamlConstructor
465syn cluster ocamlTypeContained add=ocamlTypeSumAnnot
466syn region ocamlTypeSumAnnot contained
467\ 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,ocamlPpx
473hi link ocamlTypeSumAnnot ocamlTypeCatchAll
474
475" Type context opened by “type” (type definition), “constraint” (type
476" constraint) and “exception” (exception definition)
477syn region ocamlTypeDef
478\ 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,ocamlPpx
481hi link ocamlTypeDef ocamlTypeCatchAll
482syn cluster ocamlTypeContained add=ocamlTypePrivate
483syn keyword ocamlTypePrivate contained private
484hi link ocamlTypePrivate ocamlKeyword
485syn cluster ocamlTypeContained add=ocamlTypeDefAnd
486syn keyword ocamlTypeDefAnd contained and
487hi link ocamlTypeDefAnd ocamlKeyword
488syn cluster ocamlTypeContained add=ocamlTypeDefDots
489syn match ocamlTypeDefDots contained "\.\."
490hi link ocamlTypeDefDots ocamlKeyChar
491
492" When "exception" is preceded by "with", "|" or "(", that’s not an exception
493" definition but an exception pattern; we simply highlight the keyword without
494" starting a type context.
495" NOTE: These rules must occur after that for "exception".
496syn match ocamlKeyword "\<with\_s\+exception\>"lc=4
497syn match ocamlKeyword "|\_s*exception\>"lc=1
498syn match ocamlKeyword "(\_s*exception\>"lc=1
499
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,ocamlPpx
507hi link ocamlTypeAnnot ocamlTypeCatchAll
508
509" Type annotation that gives the return type of a `fun` keyword
510" (the type context is ended by `->`)
511syn cluster ocamlTypeContained add=ocamlFunTypeAnnot
512syn region ocamlFunTypeAnnot contained containedin=ocamlFun
513\ matchgroup=ocamlKeyChar start=":"
514\ matchgroup=NONE end="\(->\)\@="
515\ contains=@ocamlTypeExpr,ocamlComment,ocamlPpx
516hi link ocamlFunTypeAnnot ocamlTypeCatchAll
517
518" Module paths (including functors) in types.
519" NOTE: This rule must occur after the rule for ocamlTypeSumDecl as it must take
520" precedence over it (otherwise the module name would be mistakenly highlighted
521" as a constructor).
522" NOTE: Carefully avoid catching "(*" here.
523syn cluster ocamlTypeExpr add=ocamlTypeModPath
524syn match ocamlTypeModPath contained "\<\u\(\w\|'\)*\_s*\."
525syn region ocamlTypeModPath contained transparent
526\ matchgroup=ocamlModPath start="\<\u\(\w\|'\)*\_s*(\*\@!"
527\ matchgroup=ocamlModPath end=")\_s*\."
528\ contains=ocamlTypeDotlessModPath,ocamlTypeBlank,ocamlComment,ocamlPpx
529hi link ocamlTypeModPath ocamlModPath
530syn cluster ocamlTypeContained add=ocamlTypeDotlessModPath
531syn match ocamlTypeDotlessModPath contained "\<\u\(\w\|'\)*\_s*\.\?"
532syn region ocamlTypeDotlessModPath contained transparent
533\ matchgroup=ocamlModPath start="\<\u\(\w\|'\)*\_s*(\*\@!"
534\ matchgroup=ocamlModPath end=")\_s*\.\?"
535\ contains=ocamlTypeDotlessModPath,ocamlTypeBlank,ocamlComment,ocamlPpx
536hi link ocamlTypeDotlessModPath ocamlTypeModPath
537
538""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Bram Moolenaar071d4272004-06-13 20:20:40 +0000539
540" Synchronization
541syn sync minlines=50
542syn sync maxlines=500
543
544if !exists("ocaml_revised")
545 syn sync match ocamlDoSync grouphere ocamlDo "\<do\>"
546 syn sync match ocamlDoSync groupthere ocamlDo "\<done\>"
547endif
548
549if exists("ocaml_revised")
550 syn sync match ocamlEndSync grouphere ocamlEnd "\<\(object\)\>"
551else
552 syn sync match ocamlEndSync grouphere ocamlEnd "\<\(begin\|object\)\>"
553endif
554
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.
Bram Moolenaar071d4272004-06-13 20:20:40 +0000562
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200563hi def link ocamlBraceErr Error
564hi def link ocamlBrackErr Error
565hi def link ocamlParenErr Error
566hi def link ocamlArrErr Error
Bram Moolenaar071d4272004-06-13 20:20:40 +0000567
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200568hi def link ocamlCountErr Error
569hi def link ocamlDoErr Error
570hi def link ocamlDoneErr Error
571hi def link ocamlEndErr Error
572hi def link ocamlThenErr Error
Yinzuo Jiang700cf8c2024-07-14 17:02:33 +0200573hi def link ocamlKwErr Error
Bram Moolenaar071d4272004-06-13 20:20:40 +0000574
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200575hi def link ocamlCharErr Error
Bram Moolenaar071d4272004-06-13 20:20:40 +0000576
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200577hi def link ocamlErr Error
Bram Moolenaar071d4272004-06-13 20:20:40 +0000578
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200579hi def link ocamlComment Comment
Yinzuo Jiang700cf8c2024-07-14 17:02:33 +0200580hi def link ocamlShebang ocamlComment
Bram Moolenaar071d4272004-06-13 20:20:40 +0000581
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200582hi def link ocamlModPath Include
583hi def link ocamlObject Include
584hi def link ocamlModule Include
585hi def link ocamlModParam1 Include
Bram Moolenaar7e6a5152021-01-02 16:39:53 +0100586hi def link ocamlGenMod Include
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200587hi def link ocamlFullMod Include
Bram Moolenaar7e6a5152021-01-02 16:39:53 +0100588hi def link ocamlFuncWith Include
589hi def link ocamlModParam Include
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200590hi def link ocamlModTypeRestr Include
591hi def link ocamlWith Include
592hi def link ocamlMTDef Include
Bram Moolenaar7e6a5152021-01-02 16:39:53 +0100593hi def link ocamlSigEncl ocamlModule
594hi def link ocamlStructEncl ocamlModule
Bram Moolenaar071d4272004-06-13 20:20:40 +0000595
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200596hi def link ocamlScript Include
Bram Moolenaar071d4272004-06-13 20:20:40 +0000597
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200598hi def link ocamlConstructor Constant
Yinzuo Jiang700cf8c2024-07-14 17:02:33 +0200599hi def link ocamlEmptyConstructor ocamlConstructor
Bram Moolenaar071d4272004-06-13 20:20:40 +0000600
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200601hi def link ocamlVal Keyword
Yinzuo Jiang700cf8c2024-07-14 17:02:33 +0200602hi def link ocamlModTypePre Keyword
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200603hi def link ocamlModPreRHS Keyword
Yinzuo Jiang700cf8c2024-07-14 17:02:33 +0200604hi def link ocamlFunctor Keyword
605hi def link ocamlModTypeOf Keyword
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200606hi def link ocamlKeyword Keyword
607hi def link ocamlMethod Include
Bram Moolenaar7e6a5152021-01-02 16:39:53 +0100608hi def link ocamlArrow Keyword
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200609hi def link ocamlKeyChar Keyword
610hi def link ocamlAnyVar Keyword
611hi def link ocamlTopStop Keyword
Bram Moolenaar773a97c2019-06-06 20:39:55 +0200612
Bram Moolenaar7e6a5152021-01-02 16:39:53 +0100613hi def link ocamlRefAssign ocamlKeyChar
614hi def link ocamlEqual ocamlKeyChar
Bram Moolenaar7e6a5152021-01-02 16:39:53 +0100615hi def link ocamlCons ocamlInfixOp
Bram Moolenaar773a97c2019-06-06 20:39:55 +0200616
Bram Moolenaar7e6a5152021-01-02 16:39:53 +0100617hi def link ocamlPrefixOp ocamlOperator
618hi def link ocamlInfixOp ocamlOperator
619hi def link ocamlExtensionOp ocamlOperator
620hi def link ocamlIndexingOp ocamlOperator
Bram Moolenaar773a97c2019-06-06 20:39:55 +0200621
622if exists("ocaml_highlight_operators")
623 hi def link ocamlInfixOpKeyword ocamlOperator
Bram Moolenaar7e6a5152021-01-02 16:39:53 +0100624 hi def link ocamlOperator Operator
Bram Moolenaar773a97c2019-06-06 20:39:55 +0200625else
626 hi def link ocamlInfixOpKeyword Keyword
627endif
Bram Moolenaar071d4272004-06-13 20:20:40 +0000628
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200629hi def link ocamlBoolean Boolean
630hi def link ocamlCharacter Character
631hi def link ocamlNumber Number
632hi def link ocamlFloat Float
633hi def link ocamlString String
Bram Moolenaar7e6a5152021-01-02 16:39:53 +0100634hi def link ocamlQuotedStringDelim Identifier
Bram Moolenaar071d4272004-06-13 20:20:40 +0000635
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200636hi def link ocamlLabel Identifier
Bram Moolenaar071d4272004-06-13 20:20:40 +0000637
Yinzuo Jiang700cf8c2024-07-14 17:02:33 +0200638" Type linting groups that the user can customize:
639" - ocamlTypeCatchAll: anything in a type context that is not caught by more
640" specific rules (in principle, this should only match syntax errors)
641" - ocamlTypeConstr: type constructors
642" - 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 was
648" implemented, but now we can do better. :-)
649hi def link ocamlTypeCatchAll Error
650hi def link ocamlTypeConstr NONE
651hi def link ocamlTypeBuiltin Type
652hi def link ocamlTypeVar NONE
653hi def link ocamlTypeAnyVar NONE
654hi def link ocamlTypeVariance ocamlKeyChar
655hi def link ocamlTypeKeyChar ocamlKeyChar
Bram Moolenaar071d4272004-06-13 20:20:40 +0000656
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200657hi def link ocamlTodo Todo
Bram Moolenaar071d4272004-06-13 20:20:40 +0000658
Bram Moolenaarf37506f2016-08-31 22:22:10 +0200659hi def link ocamlEncl Keyword
Bram Moolenaar071d4272004-06-13 20:20:40 +0000660
Bram Moolenaar7e6a5152021-01-02 16:39:53 +0100661hi def link ocamlPpxEncl ocamlEncl
Bram Moolenaar071d4272004-06-13 20:20:40 +0000662
663let b:current_syntax = "ocaml"
664
Bram Moolenaar7e6a5152021-01-02 16:39:53 +0100665let &cpo = s:keepcpo
666unlet s:keepcpo
667
Bram Moolenaar071d4272004-06-13 20:20:40 +0000668" vim: ts=8