6
6
" Issac Trotts <[email protected] >
7
7
" URL: https://github.com/ocaml/vim-ocaml
8
8
" Last Change:
9
+ " 2022 Jul 20 - Improved highlighting of type decl (Jules Aguillon)
9
10
" 2019 Nov 05 - Accurate type highlighting (Maëlan)
10
11
" 2018 Nov 08 - Improved highlighting of operators (Maëlan)
11
12
" 2018 Apr 22 - Improved support for PPX (Andrey Popp)
@@ -332,10 +333,6 @@ syn match ocamlTypeVariance contained "[-+!]\ze *\('\|\<_\>\)"
332
333
syn match ocamlTypeVariance contained " [-+] *!\+\z e *\( '\|\< _\>\) "
333
334
syn match ocamlTypeVariance contained " ! *[-+]\+\z e *\( '\|\< _\>\) "
334
335
335
- syn cluster ocamlTypeContained add =ocamlTypeEq
336
- syn match ocamlTypeEq contained " [+:]\? ="
337
- hi link ocamlTypeEq ocamlKeyChar
338
-
339
336
syn cluster ocamlTypeExpr add =ocamlTypeVar,ocamlTypeConstr,ocamlTypeAnyVar,ocamlTypeBuiltin
340
337
syn match ocamlTypeVar contained " '\(\l\| _\)\(\w\| '\) *\> "
341
338
syn match ocamlTypeConstr contained " \<\(\l\| _\)\(\w\| '\) *\> "
@@ -467,10 +464,15 @@ hi link ocamlTypeSumAnnot ocamlTypeCatchAll
467
464
468
465
" RHS of a ocamlTypeDef
469
466
syn region ocamlTypeDefImpl
470
- \ matchgroup= ocamlKeyword start = " \( =\| :\| of\) "
467
+ \ matchgroup= ocamlKeyword start = " \< of\> "
468
+ \ matchgroup= ocamlKeyChar start = " :="
469
+ \ matchgroup= ocamlKeyChar start = " :"
470
+ \ matchgroup= ocamlKeyChar start = " ="
471
471
\ matchgroup= NONE end = " \(\< type\>\|\< exception\>\|\< val\>\|\< module\>\|\< class\>\|\< method\>\|\< constraint\>\|\< inherit\>\|\< object\>\|\< struct\>\|\< open\>\|\< include\>\|\< let\>\|\< external\>\|\< in\>\|\< end\>\| )\| ]\| }\| ;\| ;;\)\@ ="
472
+ \ matchgroup= NONE end = " \(\< and\>\)\@ ="
472
473
\ contained skipwhite skipempty
473
- \ contains= @o camlTypeExpr,ocamlTypeEq,ocamlTypePrivate,ocamlTypeDefDots,ocamlTypeRecordDecl,ocamlTypeSumDecl,ocamlTypeDefAnd,ocamlComment,ocamlPpx
474
+ \ contains= @o camlTypeExpr,ocamlTypePrivate,ocamlTypeDefDots,ocamlTypeRecordDecl,ocamlTypeSumDecl,ocamlComment,ocamlPpx
475
+ \ nextgroup= ocamlTypeDefAnd
474
476
hi link ocamlTypeDefImpl ocamlTypeCatchAll
475
477
476
478
" Type context opened by “type” (type definition) and “constraint” (type
@@ -482,7 +484,18 @@ syn region ocamlTypeDef
482
484
\ matchgroup= ocamlLCIdentifier end = " \<\l\(\w\| '\) *\> "
483
485
\ contains= @o camlAllErrs,ocamlComment,ocamlTypeVariance,ocamlTypeVar
484
486
\ skipwhite skipempty
485
- \ nextgroup= ocamlTypeDefImpl
487
+ \ nextgroup= ocamlTypeDefImpl,ocamlTypeDefAnd
488
+
489
+ " Type context opened by “type” (type definition) and “constraint” (type
490
+ " constraint).
491
+ " Match the opening keyword and the identifier then jump into
492
+ " ocamlTypeDefImpl.
493
+ syn region ocamlTypeDefAnd
494
+ \ matchgroup= ocamlKeyword start = " \< and\> "
495
+ \ matchgroup= ocamlLCIdentifier end = " \<\l\(\w\| '\) *\> "
496
+ \ contains= @o camlAllErrs,ocamlComment,ocamlTypeVariance,ocamlTypeVar
497
+ \ skipwhite skipempty
498
+ \ nextgroup= ocamlTypeDefImpl,ocamlTypeDefAnd
486
499
487
500
" Exception definitions. Like ocamlTypeDef, jump into ocamlTypeDefImpl.
488
501
syn region ocamlExceptionDef
@@ -495,9 +508,6 @@ syn region ocamlExceptionDef
495
508
syn cluster ocamlTypeContained add =ocamlTypePrivate
496
509
syn keyword ocamlTypePrivate contained private
497
510
hi link ocamlTypePrivate ocamlKeyword
498
- syn cluster ocamlTypeContained add =ocamlTypeDefAnd
499
- syn keyword ocamlTypeDefAnd contained and
500
- hi link ocamlTypeDefAnd ocamlKeyword
501
511
syn cluster ocamlTypeContained add =ocamlTypeDefDots
502
512
syn match ocamlTypeDefDots contained " \.\. "
503
513
hi link ocamlTypeDefDots ocamlKeyChar
@@ -513,7 +523,7 @@ syn match ocamlKeyword "(\_s*exception\>"lc=1
513
523
" Type context opened by “:” (countless kinds of type annotations) and “:>”
514
524
" (type coercions)
515
525
syn region ocamlTypeAnnot matchgroup =ocamlKeyChar start =" :\( >\|\_ s*type\>\| [>:=]\@ !\) "
516
- \ matchgroup= NONE end = " \(\< type\>\|\< exception\>\|\< val\>\|\< module\>\|\< class\>\|\< method\>\|\< constraint\>\|\< inherit\>\|\< object\>\|\< struct\>\|\< open\>\|\< include\>\|\< let\>\|\< external\>\|\< in\>\|\< end\>\| )\| ]\| }\| ;\| ;;\)\@ ="
526
+ \ matchgroup= NONE end = " \(\< type\>\|\< exception\>\|\< val\>\|\< module\>\|\< class\>\|\< method\>\|\< constraint\>\|\< inherit\>\|\< object\>\|\< struct\>\|\< open\>\|\< include\>\|\< let\>\|\< external\>\|\< in\>\|\< end\>\|\< and \>\| )\| ]\| }\| ;\| ;;\)\@ ="
517
527
\ matchgroup= NONE end = " \( ;\| }\)\@ ="
518
528
\ matchgroup= NONE end = " \( =\| :>\)\@ ="
519
529
\ contains= @o camlTypeExpr,ocamlComment,ocamlPpx
0 commit comments