|
6 | 6 | " Issac Trotts <[email protected]>
|
7 | 7 | " URL: https://github.com/ocaml/vim-ocaml
|
8 | 8 | " Last Change:
|
| 9 | +" 2024 Jan 25 - Add OCamldoc/Odoc highlighting (Samuel Hym, Nicolas Osborne) |
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)
|
@@ -86,11 +87,19 @@ syn region ocamlNone transparent matchgroup=ocamlEncl start="{" matchgroup=oca
|
86 | 87 | syn region ocamlNone transparent matchgroup=ocamlEncl start="\[" matchgroup=ocamlEncl end="\]" contains=ALLBUT,@ocamlContained,ocamlBrackErr
|
87 | 88 | syn region ocamlNone transparent matchgroup=ocamlEncl start="\[|" matchgroup=ocamlEncl end="|\]" contains=ALLBUT,@ocamlContained,ocamlArrErr
|
88 | 89 |
|
89 |
| - |
90 |
| -" Comments |
91 |
| -syn region ocamlComment start="(\*" end="\*)" contains=@Spell,ocamlComment,ocamlTodo |
| 90 | +" Comments and documentation |
92 | 91 | syn keyword ocamlTodo contained TODO FIXME XXX NOTE
|
93 | 92 |
|
| 93 | +if !exists('odoc_syntax_loading') |
| 94 | + " Load odoc syntax only when we are not in a *.mld file |
| 95 | + syn region ocamlComment start="(\*" end="\*)" contains=@Spell,ocamlComment,ocamlTodo |
| 96 | + syn include @ocamlOdoc syntax/odoc.vim |
| 97 | + syn region ocamlDocumentation matchgroup=ocamlComment start="(\*\*" end="\*)" contains=@ocamlOdoc |
| 98 | +else |
| 99 | + " Nested in odoc syntax: for some reason, allowing ocamlComment inside |
| 100 | + " ocamlComment in odocCodeBlock in ocamlDocumentation breaks |
| 101 | + syn region ocamlComment start="(\*" end="\*)" contains=@Spell,ocamlTodo |
| 102 | +endif |
94 | 103 |
|
95 | 104 | " Objects
|
96 | 105 | syn region ocamlEnd matchgroup=ocamlObject start="\<object\>" matchgroup=ocamlObject end="\<end\>" contains=ALLBUT,@ocamlContained,ocamlEndErr
|
@@ -662,7 +671,11 @@ hi def link ocamlPpxEncl ocamlEncl
|
662 | 671 |
|
663 | 672 | let b:current_syntax = "ocaml"
|
664 | 673 |
|
665 |
| -let &cpo = s:keepcpo |
666 |
| -unlet s:keepcpo |
| 674 | +" Because of the nesting (ocaml in odoc in ocaml), s:keepcpo might have been |
| 675 | +" unlet already |
| 676 | +if exists('s:keepcpo') |
| 677 | + let &cpo = s:keepcpo |
| 678 | + unlet s:keepcpo |
| 679 | +endif |
667 | 680 |
|
668 | 681 | " vim: ts=8
|
0 commit comments