|
| 1 | +" Vim syntax file |
| 2 | +" Language: Odoc/OCamldoc |
| 3 | +" Filenames: *.mld |
| 4 | +" Maintainers: Samuel Hym |
| 5 | +" Nicolas Osborne |
| 6 | +" URL: https://github.com/ocaml/vim-ocaml |
| 7 | + |
| 8 | +" Quit when a syntax file was already loaded |
| 9 | +if !exists("odoc_syntax_loading") |
| 10 | + if exists("b:current_syntax") |
| 11 | + finish |
| 12 | + endif |
| 13 | + let odoc_syntax_loading = 1 |
| 14 | +endif |
| 15 | + |
| 16 | +let s:keepcpo = &cpo |
| 17 | +set cpo&vim |
| 18 | + |
| 19 | +syn case match |
| 20 | + |
| 21 | +syn include @odocSyntaxOCaml syntax/ocaml.vim |
| 22 | +unlet b:current_syntax |
| 23 | + |
| 24 | +syn cluster odocInline contains=odocBold,odocItalic,odocEmphasis,odocMiscInline,odocList,odocLink,odocCode,odocCrossref,odocCodeBlock,odocVerbatim,odocTargetSpecific,odocTag |
| 25 | + |
| 26 | +syn region odocLink matchgroup=odocLinkMarker start="{" end="}" contains=odocCrossref |
| 27 | +syn region odocBold matchgroup=odocMarker start="{b\>" end="}" contains=@Spell,@odocInline |
| 28 | +syn region odocEmphasis matchgroup=odocMarker start="{e\>" end="}" contains=@Spell,@odocInline |
| 29 | +syn region odocItalic matchgroup=odocMarker start="{i\>" end="}" contains=@Spell,@odocInline |
| 30 | +syn region odocMiscInline matchgroup=odocMarker start="{[CLR^_]" end="}" contains=@Spell,@odocInline |
| 31 | +syn region odocVerbatim matchgroup=odocMarker start="{v\>" end="\<v}" |
| 32 | + |
| 33 | +if get(g:,'odoc_html_support',0) |
| 34 | + syn include @odocHtml syntax/html.vim |
| 35 | + unlet b:current_syntax |
| 36 | + syn region odocTargetSpecific matchgroup=odocMarker start="{%html:" end="%}" contains=@odocHtml |
| 37 | +else |
| 38 | + syn region odocTargetSpecific matchgroup=odocMarker start="{%html:" end="%}" contains=@Spell |
| 39 | +endif |
| 40 | + |
| 41 | +syn region odocDyckWord contained start="{" end="}" contains=odocDyckWord |
| 42 | +syn region odocTargetSpecific matchgroup=odocMarker start="{m\%(ath\)\?\>" end="}" contains=odocDyckWord |
| 43 | +syn region odocTargetSpecific matchgroup=odocMarker start="{%\%(latex\|texi\|man\):" end="%}" contains=@Spell |
| 44 | +syn region odocHeading start="{[0-5]" end="}" contains=@Spell |
| 45 | +syn region odocTable matchgroup=odocMarker start="{t\>" end="}" contains=@Spell,@odocInline |
| 46 | +syn region odocTable matchgroup=odocMarker start="{table\>" end="}" contains=odocTableRow |
| 47 | +syn region odocTableRow matchgroup=odocMarker start="{tr\>" end="}" contains=odocTableEntry |
| 48 | +syn region odocTableEntry matchgroup=odocMarker start="{t[dh]\>" end="}" contains=@Spell,@odocInline |
| 49 | +syn region odocCode matchgroup=odocMarker start="\[" end="\]" |
| 50 | +syn region odocCodeBlock matchgroup=odocMarker start="{@[^\[]\+\[" end="\]}" |
| 51 | +syn region odocCodeBlock matchgroup=odocMarker start="{\%(@ocaml\%(\s[^\[]*\)\?\)\?\[" end="\]}" contains=@odocSyntaxOCaml |
| 52 | +syn match odocListMarker "^\s*[-+]\s" |
| 53 | +syn region odocListItem contained matchgroup=odocListMarker start="{\%(-\|li\>\)" end="}" contains=@Spell,@odocInline |
| 54 | +syn region odocList matchgroup=odocListMarker start="{[ou]l\>" end="}" contains=odocListItem |
| 55 | +" a bit leniant with ":" |
| 56 | +syn match odocCrossrefKw contained "\<\%(module\%(-type\)\?\|class\%(-type\)\?\|val\|type\|exception\|method\|constructor\|extension\|field\|instance-variable\|section\|page\)[-:]" |
| 57 | +syn region odocCrossref start="{!" end="}" contains=odocCrossrefKw |
| 58 | +syn match odocTag "@\%(author\|deprecated\|param\|raise\|return\|see\|since\|before\|version\)" |
| 59 | + |
| 60 | +" Shamelessly borrowed from HTML syntax |
| 61 | +hi def odocBold term=bold cterm=bold gui=bold |
| 62 | +hi def odocEmphasis term=bold,underline cterm=bold,underline gui=bold,underline |
| 63 | +hi def odocItalic term=italic cterm=italic gui=italic |
| 64 | + |
| 65 | +hi def link odocCrossref Float |
| 66 | +hi def link odocCrossrefKw Keyword |
| 67 | +hi def link odocHeading Title |
| 68 | +hi def link odocLink Underlined |
| 69 | +hi def link odocListMarker Operator |
| 70 | +hi def link odocMarker Delimiter |
| 71 | +hi def link odocTag Keyword |
| 72 | + |
| 73 | +let b:current_syntax = "odoc" |
| 74 | + |
| 75 | +unlet odoc_syntax_loading |
| 76 | + |
| 77 | +let &cpo = s:keepcpo |
| 78 | +unlet s:keepcpo |
| 79 | + |
| 80 | +" vim: ts=8 |
0 commit comments