Skip to content

Commit d623ae5

Browse files
committed
Match exception declaration separately
Have stricter rules for the identifiers and allow exception constructors to be highlighted as before.
1 parent af6060b commit d623ae5

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

syntax/ocaml.vim

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -473,11 +473,21 @@ syn region ocamlTypeDefImpl
473473
\ contains=@ocamlTypeExpr,ocamlTypeEq,ocamlTypePrivate,ocamlTypeDefDots,ocamlTypeRecordDecl,ocamlTypeSumDecl,ocamlTypeDefAnd,ocamlComment,ocamlPpx
474474
hi link ocamlTypeDefImpl ocamlTypeCatchAll
475475

476-
" Type context opened by “type” (type definition), “constraint” (type
477-
" constraint) and “exception” (exception definition)
476+
" Type context opened by “type” (type definition) and “constraint” (type
477+
" constraint).
478+
" Match the opening keyword and the identifier then jump into
479+
" ocamlTypeDefImpl.
478480
syn region ocamlTypeDef
479-
\ matchgroup=ocamlKeyword start="\<type\>\(\_s\+\<nonrec\>\)\?\|\<constraint\>\|\<exception\>"
480-
\ matchgroup=ocamlTypedef end="\<\(\w\|'\)*\>"
481+
\ matchgroup=ocamlKeyword start="\<type\>\(\_s\+\<nonrec\>\)\?\|\<constraint\>"
482+
\ matchgroup=ocamlLCIdentifier end="\<\l\(\w\|'\)*\>"
483+
\ contains=@ocamlAllErrs,ocamlComment,ocamlTypeVariance,ocamlTypeVar
484+
\ skipwhite skipempty
485+
\ nextgroup=ocamlTypeDefImpl
486+
487+
" Exception definitions. Like ocamlTypeDef, jump into ocamlTypeDefImpl.
488+
syn region ocamlExceptionDef
489+
\ matchgroup=ocamlKeyword start="\<exception\>"
490+
\ matchgroup=ocamlConstructor end="\u\(\w\|'\)*\>"
481491
\ contains=@ocamlAllErrs,ocamlComment,ocamlTypeVariance,ocamlTypeVar
482492
\ skipwhite skipempty
483493
\ nextgroup=ocamlTypeDefImpl

0 commit comments

Comments
 (0)