-
Notifications
You must be signed in to change notification settings - Fork 40
Add OCamldoc/Odoc highlighting #106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
n-osborne
wants to merge
10
commits into
ocaml:master
Choose a base branch
from
n-osborne:odoc-syntax
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
87e4832
Add syntax highlighting for *.mld
n-osborne 5d2b639
Add documentation highlighting in OCaml files
n-osborne bed49ad
Fix highlighting of module parameter
n-osborne 2749fb5
syntax/odoc: improve following review of #106
Maelan 3650b4e
syntax/odoc: add missing @tags
Maelan cb78554
syntax/odoc: add missing crossref keywords
Maelan 14b1875
syntax/odoc: disable spell-checking inside LaTeX snippets
Maelan 67dcf37
syntax/odoc: make relevant regions transparent
Maelan ae494cb
syntax/odoc: shuffle lines around
Maelan cc050b3
Allow for line feed in odocCodeBlock marker
n-osborne File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
au BufNewFile,BufRead *.mld setf odoc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
" Issac Trotts <[email protected]> | ||
" URL: https://github.com/ocaml/vim-ocaml | ||
" Last Change: | ||
" 2024 Jan 25 - Add OCamldoc/Odoc highlighting (Samuel Hym, Nicolas Osborne) | ||
" 2019 Nov 05 - Accurate type highlighting (Maëlan) | ||
" 2018 Nov 08 - Improved highlighting of operators (Maëlan) | ||
" 2018 Apr 22 - Improved support for PPX (Andrey Popp) | ||
|
@@ -86,11 +87,21 @@ syn region ocamlNone transparent matchgroup=ocamlEncl start="{" matchgroup=oca | |
syn region ocamlNone transparent matchgroup=ocamlEncl start="\[" matchgroup=ocamlEncl end="\]" contains=ALLBUT,@ocamlContained,ocamlBrackErr | ||
syn region ocamlNone transparent matchgroup=ocamlEncl start="\[|" matchgroup=ocamlEncl end="|\]" contains=ALLBUT,@ocamlContained,ocamlArrErr | ||
|
||
|
||
" Comments | ||
syn region ocamlComment start="(\*" end="\*)" contains=@Spell,ocamlComment,ocamlTodo | ||
" Comments and documentation | ||
syn keyword ocamlTodo contained TODO FIXME XXX NOTE | ||
|
||
syn cluster ocamlCommentLike contains=ocamlComment,ocamlCommentInDoc,ocamlDocumentation,ocamlStopComment | ||
|
||
if !exists('odoc_syntax_loading') | ||
" Load odoc syntax only when we are not in a *.mld file | ||
syn region ocamlComment start="(\*" end="\*)" contains=@Spell,ocamlComment,ocamlTodo | ||
syn include @ocamlOdoc syntax/odoc.vim | ||
syn region ocamlDocumentation matchgroup=ocamlDocEncl start="(\*\*[*)]\@!" end="\*)" contains=@ocamlOdoc,ocamlCommentInDoc,@Spell,ocamlTodo | ||
else | ||
syn region ocamlCommentInDoc start="(\*" end="\*)" contains=@Spell,ocamlTodo,ocamlCommentInDoc | ||
endif | ||
|
||
syn match ocamlStopComment "(\*\*/\*\*)" | ||
|
||
" Objects | ||
syn region ocamlEnd matchgroup=ocamlObject start="\<object\>" matchgroup=ocamlObject end="\<end\>" contains=ALLBUT,@ocamlContained,ocamlEndErr | ||
|
@@ -129,9 +140,9 @@ syn match ocamlKeyword "\<include\>" skipwhite skipempty nextgroup=ocamlModPa | |
|
||
" "module" - somewhat complicated stuff ;-) | ||
" 2022-10: please document it? | ||
syn region ocamlModule matchgroup=ocamlKeyword start="\<module\>" matchgroup=ocamlModule end="\<_\|\u\(\w\|'\)*\>" contains=@ocamlAllErrs,ocamlComment skipwhite skipempty nextgroup=ocamlPreDef | ||
syn region ocamlPreDef start="."me=e-1 end="[a-z:=)]\@=" contained contains=@ocamlAllErrs,ocamlComment,ocamlModParam,ocamlGenMod,ocamlModTypeRestr nextgroup=ocamlModTypePre,ocamlModPreRHS | ||
syn region ocamlModParam start="(\*\@!" end=")" contained contains=ocamlGenMod,ocamlModParam,ocamlModParam1,ocamlSig,ocamlVal | ||
syn region ocamlModule matchgroup=ocamlKeyword start="\<module\>" matchgroup=ocamlModule end="\<_\|\u\(\w\|'\)*\>" contains=@ocamlAllErrs,@ocamlCommentLike skipwhite skipempty nextgroup=ocamlPreDef | ||
syn region ocamlPreDef start="."me=e-1 end="[a-z:=)]\@=" contained contains=@ocamlAllErrs,@ocamlCommentLike,ocamlModParam,ocamlGenMod,ocamlModTypeRestr nextgroup=ocamlModTypePre,ocamlModPreRHS | ||
syn region ocamlModParam start="(\*\@!" end=")" contained contains=ocamlGenMod,ocamlModParam1,ocamlSig,ocamlVal | ||
syn match ocamlModParam1 "\<\u\(\w\|'\)*\>" contained skipwhite skipempty | ||
syn match ocamlGenMod "()" contained skipwhite skipempty | ||
|
||
|
@@ -140,11 +151,11 @@ syn match ocamlModTypeRestr "\<\w\(\w\|'\)*\( *\. *\w\(\w\|'\)*\)*\>" contain | |
|
||
syn match ocamlModPreRHS "=" contained skipwhite skipempty nextgroup=ocamlModParam,ocamlFullMod | ||
syn keyword ocamlKeyword val | ||
syn region ocamlVal matchgroup=ocamlKeyword start="\<val\>" matchgroup=ocamlLCIdentifier end="\<\l\(\w\|'\)*\>" contains=@ocamlAllErrs,ocamlComment,ocamlFullMod skipwhite skipempty nextgroup=ocamlModTypePre | ||
syn region ocamlModRHS start="." end=". *\w\|([^*]"me=e-2 contained contains=ocamlComment skipwhite skipempty nextgroup=ocamlModParam,ocamlFullMod | ||
syn region ocamlVal matchgroup=ocamlKeyword start="\<val\>" matchgroup=ocamlLCIdentifier end="\<\l\(\w\|'\)*\>" contains=@ocamlAllErrs,@ocamlCommentLike,ocamlFullMod skipwhite skipempty nextgroup=ocamlModTypePre | ||
syn region ocamlModRHS start="." end=". *\w\|([^*]"me=e-2 contained contains=@ocamlCommentLike skipwhite skipempty nextgroup=ocamlModParam,ocamlFullMod | ||
syn match ocamlFullMod "\<\u\(\w\|'\)*\( *\. *\u\(\w\|'\)*\)*" contained skipwhite skipempty nextgroup=ocamlFuncWith | ||
|
||
syn region ocamlFuncWith start="([*)]\@!" end=")" contained contains=ocamlComment,ocamlWith,ocamlStruct skipwhite skipempty nextgroup=ocamlFuncWith | ||
syn region ocamlFuncWith start="([*)]\@!" end=")" contained contains=@ocamlCommentLike,ocamlWith,ocamlStruct skipwhite skipempty nextgroup=ocamlFuncWith | ||
|
||
syn region ocamlModTRWith start="(\*\@!" end=")" contained contains=@ocamlAENoParen,ocamlWith | ||
syn match ocamlWith "\<\(\u\(\w\|'\)* *\. *\)*\w\(\w\|'\)*\>" contained skipwhite skipempty nextgroup=ocamlWithRest | ||
|
@@ -157,10 +168,10 @@ syn region ocamlStruct matchgroup=ocamlStructEncl start="\<\(module\s\+\)\=str | |
syn region ocamlSig matchgroup=ocamlSigEncl start="\<sig\>" matchgroup=ocamlSigEncl end="\<end\>" contains=ALLBUT,@ocamlContained,ocamlEndErr | ||
|
||
" "functor" | ||
syn region ocamlFunctor start="\<functor\>" matchgroup=ocamlKeyword end="->" contains=@ocamlAllErrs,ocamlComment,ocamlModParam,ocamlGenMod skipwhite skipempty nextgroup=ocamlStruct,ocamlSig,ocamlFuncWith,ocamlFunctor | ||
syn region ocamlFunctor start="\<functor\>" matchgroup=ocamlKeyword end="->" contains=@ocamlAllErrs,@ocamlCommentLike,ocamlModParam,ocamlGenMod skipwhite skipempty nextgroup=ocamlStruct,ocamlSig,ocamlFuncWith,ocamlFunctor | ||
|
||
" "module type" | ||
syn region ocamlModTypeOf start="\<module\s\+type\(\s\+of\)\=\>" matchgroup=ocamlModule end="\<\w\(\w\|'\)*\>" contains=ocamlComment skipwhite skipempty nextgroup=ocamlMTDef | ||
syn region ocamlModTypeOf start="\<module\s\+type\(\s\+of\)\=\>" matchgroup=ocamlModule end="\<\w\(\w\|'\)*\>" contains=@ocamlCommentLike skipwhite skipempty nextgroup=ocamlMTDef | ||
syn match ocamlMTDef "=\s*\w\(\w\|'\)*\>"hs=s+1,me=s+1 skipwhite skipempty nextgroup=ocamlFullMod | ||
|
||
" Quoted strings | ||
|
@@ -323,7 +334,7 @@ syn cluster ocamlTypeExpr add=ocamlTypeParen | |
syn region ocamlTypeParen contained transparent | ||
\ matchgroup=ocamlEncl start="(\*\@!" | ||
\ matchgroup=ocamlEncl end=")" | ||
\ contains=@ocamlTypeExpr,ocamlComment,ocamlPpx | ||
\ contains=@ocamlTypeExpr,@ocamlCommentLike,ocamlPpx | ||
|
||
syn cluster ocamlTypeExpr add=ocamlTypeKeyChar,ocamlTypeAs | ||
syn match ocamlTypeKeyChar contained "->" | ||
|
@@ -386,7 +397,7 @@ syn cluster ocamlTypeExpr add=ocamlTypeObject | |
syn region ocamlTypeObject contained | ||
n-osborne marked this conversation as resolved.
Show resolved
Hide resolved
|
||
\ matchgroup=ocamlEncl start="<" | ||
\ matchgroup=ocamlEncl end=">" | ||
\ contains=ocamlTypeObjectDots,ocamlLCIdentifier,ocamlTypeObjectAnnot,ocamlTypeBlank,ocamlComment,ocamlPpx | ||
\ contains=ocamlTypeObjectDots,ocamlLCIdentifier,ocamlTypeObjectAnnot,ocamlTypeBlank,@ocamlCommentLike,ocamlPpx | ||
hi link ocamlTypeObject ocamlTypeCatchAll | ||
syn cluster ocamlTypeContained add=ocamlTypeObjectDots | ||
syn match ocamlTypeObjectDots contained "\.\." | ||
|
@@ -395,15 +406,15 @@ syn cluster ocamlTypeContained add=ocamlTypeObjectAnnot | |
syn region ocamlTypeObjectAnnot contained | ||
\ matchgroup=ocamlKeyChar start=":" | ||
\ matchgroup=ocamlKeyChar end=";\|>\@=" | ||
\ contains=@ocamlTypeExpr,ocamlComment,ocamlPpx | ||
\ contains=@ocamlTypeExpr,@ocamlCommentLike,ocamlPpx | ||
hi link ocamlTypeObjectAnnot ocamlTypeCatchAll | ||
|
||
" Record type definition | ||
syn cluster ocamlTypeContained add=ocamlTypeRecordDecl | ||
syn region ocamlTypeRecordDecl contained | ||
\ matchgroup=ocamlEncl start="{" | ||
\ matchgroup=ocamlEncl end="}" | ||
\ contains=ocamlTypeMutable,ocamlLCIdentifier,ocamlTypeRecordAnnot,ocamlTypeBlank,ocamlComment,ocamlPpx | ||
\ contains=ocamlTypeMutable,ocamlLCIdentifier,ocamlTypeRecordAnnot,ocamlTypeBlank,@ocamlCommentLike,ocamlPpx | ||
hi link ocamlTypeRecordDecl ocamlTypeCatchAll | ||
syn cluster ocamlTypeContained add=ocamlTypeMutable | ||
syn keyword ocamlTypeMutable contained mutable | ||
|
@@ -412,7 +423,7 @@ syn cluster ocamlTypeContained add=ocamlTypeRecordAnnot | |
syn region ocamlTypeRecordAnnot contained | ||
\ matchgroup=ocamlKeyChar start=":" | ||
\ matchgroup=ocamlKeyChar end=";\|}\@=" | ||
\ contains=@ocamlTypeExpr,ocamlComment,ocamlPpx | ||
\ contains=@ocamlTypeExpr,@ocamlCommentLike,ocamlPpx | ||
hi link ocamlTypeRecordAnnot ocamlTypeCatchAll | ||
|
||
" Polymorphic variant types | ||
|
@@ -421,7 +432,7 @@ syn cluster ocamlTypeExpr add=ocamlTypeVariant | |
syn region ocamlTypeVariant contained | ||
\ matchgroup=ocamlEncl start="\[>" start="\[<" start="\[@\@!" | ||
\ matchgroup=ocamlEncl end="\]" | ||
\ contains=ocamlTypeVariantKeyChar,ocamlTypeVariantConstr,ocamlTypeVariantAnnot,ocamlTypeBlank,ocamlComment,ocamlPpx | ||
\ contains=ocamlTypeVariantKeyChar,ocamlTypeVariantConstr,ocamlTypeVariantAnnot,ocamlTypeBlank,@ocamlCommentLike,ocamlPpx | ||
hi link ocamlTypeVariant ocamlTypeCatchAll | ||
syn cluster ocamlTypeContained add=ocamlTypeVariantKeyChar | ||
syn match ocamlTypeVariantKeyChar contained "|" | ||
|
@@ -434,7 +445,7 @@ syn cluster ocamlTypeContained add=ocamlTypeVariantAnnot | |
syn region ocamlTypeVariantAnnot contained | ||
\ matchgroup=ocamlKeyword start="\<of\>" | ||
\ matchgroup=ocamlKeyChar end="|\|>\|\]\@=" | ||
\ contains=@ocamlTypeExpr,ocamlTypeAmp,ocamlComment,ocamlPpx | ||
\ contains=@ocamlTypeExpr,ocamlTypeAmp,@ocamlCommentLike,ocamlPpx | ||
hi link ocamlTypeVariantAnnot ocamlTypeCatchAll | ||
syn cluster ocamlTypeContained add=ocamlTypeAmp | ||
syn match ocamlTypeAmp contained "&" | ||
|
@@ -449,7 +460,7 @@ syn region ocamlTypeSumDecl contained | |
\ matchgroup=ocamlTypeSumConstr start="(\_s*)" start="\[\_s*]" start="(\_s*::\_s*)" | ||
\ matchgroup=NONE end="\(\<type\>\|\<exception\>\|\<val\>\|\<module\>\|\<class\>\|\<method\>\|\<constraint\>\|\<inherit\>\|\<object\>\|\<struct\>\|\<open\>\|\<include\>\|\<let\>\|\<external\>\|\<in\>\|\<end\>\|)\|]\|}\|;\|;;\|=\)\@=" | ||
\ matchgroup=NONE end="\(\<and\>\)\@=" | ||
\ contains=ocamlTypeSumBar,ocamlTypeSumConstr,ocamlTypeSumAnnot,ocamlTypeBlank,ocamlComment,ocamlPpx | ||
\ contains=ocamlTypeSumBar,ocamlTypeSumConstr,ocamlTypeSumAnnot,ocamlTypeBlank,@ocamlCommentLike,ocamlPpx | ||
hi link ocamlTypeSumDecl ocamlTypeCatchAll | ||
syn cluster ocamlTypeContained add=ocamlTypeSumBar | ||
syn match ocamlTypeSumBar contained "|" | ||
|
@@ -469,15 +480,15 @@ syn region ocamlTypeSumAnnot contained | |
\ matchgroup=NONE end="|\@=" | ||
\ matchgroup=NONE end="\(\<type\>\|\<exception\>\|\<val\>\|\<module\>\|\<class\>\|\<method\>\|\<constraint\>\|\<inherit\>\|\<object\>\|\<struct\>\|\<open\>\|\<include\>\|\<let\>\|\<external\>\|\<in\>\|\<end\>\|)\|]\|}\|;\|;;\)\@=" | ||
\ matchgroup=NONE end="\(\<and\>\)\@=" | ||
\ contains=@ocamlTypeExpr,ocamlTypeRecordDecl,ocamlComment,ocamlPpx | ||
\ contains=@ocamlTypeExpr,ocamlTypeRecordDecl,@ocamlCommentLike,ocamlPpx | ||
hi link ocamlTypeSumAnnot ocamlTypeCatchAll | ||
|
||
" Type context opened by “type” (type definition), “constraint” (type | ||
" constraint) and “exception” (exception definition) | ||
syn region ocamlTypeDef | ||
\ matchgroup=ocamlKeyword start="\<type\>\(\_s\+\<nonrec\>\)\?\|\<constraint\>\|\<exception\>" | ||
\ matchgroup=NONE end="\(\<type\>\|\<exception\>\|\<val\>\|\<module\>\|\<class\>\|\<method\>\|\<constraint\>\|\<inherit\>\|\<object\>\|\<struct\>\|\<open\>\|\<include\>\|\<let\>\|\<external\>\|\<in\>\|\<end\>\|)\|]\|}\|;\|;;\)\@=" | ||
\ contains=@ocamlTypeExpr,ocamlTypeEq,ocamlTypePrivate,ocamlTypeDefDots,ocamlTypeRecordDecl,ocamlTypeSumDecl,ocamlTypeDefAnd,ocamlComment,ocamlPpx | ||
\ contains=@ocamlTypeExpr,ocamlTypeEq,ocamlTypePrivate,ocamlTypeDefDots,ocamlTypeRecordDecl,ocamlTypeSumDecl,ocamlTypeDefAnd,@ocamlCommentLike,ocamlPpx | ||
hi link ocamlTypeDef ocamlTypeCatchAll | ||
syn cluster ocamlTypeContained add=ocamlTypePrivate | ||
syn keyword ocamlTypePrivate contained private | ||
|
@@ -503,7 +514,7 @@ syn region ocamlTypeAnnot matchgroup=ocamlKeyChar start=":\(>\|\_s*type\>\|[>:=] | |
\ matchgroup=NONE end="\(\<type\>\|\<exception\>\|\<val\>\|\<module\>\|\<class\>\|\<method\>\|\<constraint\>\|\<inherit\>\|\<object\>\|\<struct\>\|\<open\>\|\<include\>\|\<let\>\|\<external\>\|\<in\>\|\<end\>\|)\|]\|}\|;\|;;\)\@=" | ||
\ matchgroup=NONE end="\(;\|}\)\@=" | ||
\ matchgroup=NONE end="\(=\|:>\)\@=" | ||
\ contains=@ocamlTypeExpr,ocamlComment,ocamlPpx | ||
\ contains=@ocamlTypeExpr,@ocamlCommentLike,ocamlPpx | ||
hi link ocamlTypeAnnot ocamlTypeCatchAll | ||
|
||
" Type annotation that gives the return type of a `fun` keyword | ||
|
@@ -512,7 +523,7 @@ syn cluster ocamlTypeContained add=ocamlFunTypeAnnot | |
syn region ocamlFunTypeAnnot contained containedin=ocamlFun | ||
\ matchgroup=ocamlKeyChar start=":" | ||
\ matchgroup=NONE end="\(->\)\@=" | ||
\ contains=@ocamlTypeExpr,ocamlComment,ocamlPpx | ||
\ contains=@ocamlTypeExpr,@ocamlCommentLike,ocamlPpx | ||
hi link ocamlFunTypeAnnot ocamlTypeCatchAll | ||
|
||
" Module paths (including functors) in types. | ||
|
@@ -525,14 +536,14 @@ syn match ocamlTypeModPath contained "\<\u\(\w\|'\)*\_s*\." | |
syn region ocamlTypeModPath contained transparent | ||
\ matchgroup=ocamlModPath start="\<\u\(\w\|'\)*\_s*(\*\@!" | ||
\ matchgroup=ocamlModPath end=")\_s*\." | ||
\ contains=ocamlTypeDotlessModPath,ocamlTypeBlank,ocamlComment,ocamlPpx | ||
\ contains=ocamlTypeDotlessModPath,ocamlTypeBlank,@ocamlCommentLike,ocamlPpx | ||
hi link ocamlTypeModPath ocamlModPath | ||
syn cluster ocamlTypeContained add=ocamlTypeDotlessModPath | ||
syn match ocamlTypeDotlessModPath contained "\<\u\(\w\|'\)*\_s*\.\?" | ||
syn region ocamlTypeDotlessModPath contained transparent | ||
\ matchgroup=ocamlModPath start="\<\u\(\w\|'\)*\_s*(\*\@!" | ||
\ matchgroup=ocamlModPath end=")\_s*\.\?" | ||
\ contains=ocamlTypeDotlessModPath,ocamlTypeBlank,ocamlComment,ocamlPpx | ||
\ contains=ocamlTypeDotlessModPath,ocamlTypeBlank,@ocamlCommentLike,ocamlPpx | ||
hi link ocamlTypeDotlessModPath ocamlTypeModPath | ||
|
||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | ||
|
@@ -577,6 +588,9 @@ hi def link ocamlCharErr Error | |
hi def link ocamlErr Error | ||
|
||
hi def link ocamlComment Comment | ||
hi def link ocamlDocEncl ocamlComment | ||
hi def link ocamlCommentInDoc ocamlComment | ||
hi def link ocamlStopComment PreProc | ||
hi def link ocamlShebang ocamlComment | ||
|
||
hi def link ocamlModPath Include | ||
|
@@ -662,7 +676,11 @@ hi def link ocamlPpxEncl ocamlEncl | |
|
||
let b:current_syntax = "ocaml" | ||
|
||
let &cpo = s:keepcpo | ||
unlet s:keepcpo | ||
" Because of the nesting (ocaml in odoc in ocaml), s:keepcpo might have been | ||
" unlet already | ||
if exists('s:keepcpo') | ||
let &cpo = s:keepcpo | ||
unlet s:keepcpo | ||
endif | ||
|
||
" vim: ts=8 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
" Vim syntax file | ||
" Language: Odoc/OCamldoc | ||
" Filenames: *.mld | ||
" Maintainers: Samuel Hym | ||
" Nicolas Osborne | ||
" URL: https://github.com/ocaml/vim-ocaml | ||
n-osborne marked this conversation as resolved.
Show resolved
Hide resolved
|
||
" Last Change: | ||
" 2024 Jan 26 - initial version | ||
|
||
" Quit when a syntax file was already loaded | ||
if !exists("odoc_syntax_loading") | ||
if exists("b:current_syntax") | ||
finish | ||
endif | ||
let odoc_syntax_loading = 1 | ||
endif | ||
|
||
let s:keepcpo = &cpo | ||
set cpo&vim | ||
|
||
syn spell toplevel | ||
|
||
syn case match | ||
|
||
syn include @odocSyntaxOCaml syntax/ocaml.vim | ||
unlet b:current_syntax | ||
|
||
n-osborne marked this conversation as resolved.
Show resolved
Hide resolved
|
||
syn cluster odocInline contains=odocBold,odocItalic,odocEmphasis,odocMiscInline,odocList,odocLinkText,odocUrl,odocCrossref,odocCode,odocCodeBlock,odocVerbatim,odocTargetSpecific,odocTag,odocEscaped,odocEscapedError,odocBraceError,odocTagError | ||
|
||
syn match odocBraceError "[{}]" | ||
|
||
syn region odocLinkText transparent matchgroup=odocMarker start="{\%({[!:]\)\@=" end="}" contains=odocUrl,odocCrossref,@Spell,@odocInline | ||
syn region odocUrl matchgroup=odocUrlMarker start="{:\_s*" end="\_s*}" | ||
" a bit leniant with ":" | ||
syn match odocCrossrefKw contained "\<\%(!modules\|module\%(-type\)\?\|class\%(-type\)\?\|val\|type\|exception\|method\|constructor\|extension\|extension-decl\|field\|instance-variable\|section\|page\)[-:]" | ||
syn match odocCrossrefKwDeprecated contained "\<\%(modtype\|classtype\|value\|exn\|const\|label\)[-:]" | ||
syn region odocCrossref matchgroup=odocCrossrefMarker start="{!" end="}" contains=odocCrossrefKw,odocCrossrefKwDeprecated | ||
|
||
syn region odocBold matchgroup=odocMarker start="{b\>" end="}" contains=@Spell,@odocInline | ||
syn region odocEmphasis matchgroup=odocMarker start="{e\>" end="}" contains=@Spell,@odocInline | ||
syn region odocItalic matchgroup=odocMarker start="{i\>" end="}" contains=@Spell,@odocInline | ||
syn region odocMiscInline matchgroup=odocMarker start="{[CLR^_]" end="}" contains=@Spell,@odocInline | ||
syn region odocVerbatim matchgroup=odocMarker start="{v\>" end="\<v}" | ||
|
||
n-osborne marked this conversation as resolved.
Show resolved
Hide resolved
|
||
syn region odocTargetSpecific matchgroup=odocUnknownTarget start="{%.\{-}:\|{%" end="%}" | ||
|
||
if get(g:,'odoc_html_support',0) | ||
syn include @odocHtml syntax/html.vim | ||
unlet b:current_syntax | ||
syn region odocTargetSpecific matchgroup=odocMarker start="{%html:" end="%}" contains=@odocHtml | ||
else | ||
syn region odocTargetSpecific matchgroup=odocMarker start="{%html:" end="%}" contains=@Spell | ||
endif | ||
|
||
syn region odocDyckWord contained transparent start="{" end="}" contains=odocDyckWord | ||
syn region odocTargetSpecific matchgroup=odocMarker start="{m\%(ath\)\?\>" end="}" contains=odocDyckWord | ||
syn region odocTargetSpecific matchgroup=odocMarker start="{%\%(latex\|texi\|man\):" end="%}" | ||
syn region odocHeading start="{[0-5]\%(\s\|$\|:\)\@=" end="}" contains=@Spell,odocHeadingLabel | ||
syn match odocHeadingLabel contained "\%({[0-5]\)\@<=:[^ \t:]*" | ||
syn region odocTable transparent matchgroup=odocMarker start="{t\>" end="}" contains=@Spell,@odocInline | ||
syn region odocTable transparent matchgroup=odocMarker start="{table\>" end="}" contains=odocTableRow | ||
syn region odocTableRow transparent matchgroup=odocMarker start="{tr\>" end="}" contains=odocTableEntry contained | ||
syn region odocTableEntry transparent matchgroup=odocMarker start="{t[dh]\>" end="}" contains=@Spell,@odocInline contained | ||
syn match odocEscapedBracket contained "\\[][]" | ||
syn region odocBalancedBracket contained transparent start="\[" end="]" | ||
syn region odocCode matchgroup=odocMarker start="\[" end="\]" contains=odocBalancedBracket,odocEscapedBracket | ||
syn region odocCodeBlock matchgroup=odocMarker start="{@[^\[]\+\[" end="\]}" | ||
syn region odocCodeBlock matchgroup=odocMarker start="{\%(@ocaml\%(\_s[^\[]*\)\?\)\?\[" end="\]}" contains=@odocSyntaxOCaml | ||
syn match odocListMarker "^\s*[-+]\s" | ||
syn region odocListItem contained transparent matchgroup=odocListMarker start="{\%(-\|li\>\)" end="}" contains=@Spell,@odocInline | ||
syn region odocList transparent matchgroup=odocListMarker start="{[ou]l\>" end="}" contains=odocListItem | ||
syn match odocTagError "@[a-zA-Z]*" | ||
syn match odocTag "@\%(author\|deprecated\|param\|raises\?\|returns\?\|see\|since\|before\|version\|open\|closed\|inline\|canonical\)\>" | ||
|
||
syn match odocEscapedError "\\." | ||
syn match odocEscaped "\\[][{}@\\]" | ||
|
||
n-osborne marked this conversation as resolved.
Show resolved
Hide resolved
|
||
" Shamelessly borrowed from HTML syntax | ||
hi def odocBold term=bold cterm=bold gui=bold | ||
hi def odocEmphasis term=underline cterm=underline gui=underline | ||
hi def odocItalic term=italic cterm=italic gui=italic | ||
|
||
hi def link odocUrlMarker odocMarker | ||
hi def link odocUrl Underlined | ||
hi def link odocCrossrefMarker odocCrossref " or odocMarker | ||
hi def link odocCrossref Label | ||
hi def link odocCrossrefKw Keyword | ||
hi def link odocCrossrefKwDeprecated Keyword " we may highlight it differently | ||
hi def link odocHeading Title | ||
hi def link odocHeadingLabel Label | ||
hi def link odocListMarker Operator | ||
hi def link odocMarker Delimiter | ||
hi def link odocTag Keyword | ||
|
||
hi def link odocBraceError Error | ||
hi def link odocUnknownTarget Error | ||
hi def link odocTagError Error | ||
hi def link odocEscapedError Error | ||
hi def link odocEscaped SpecialChar | ||
hi def link odocEscapedBracket odocEscaped | ||
|
||
let b:current_syntax = "odoc" | ||
|
||
unlet odoc_syntax_loading | ||
|
||
let &cpo = s:keepcpo | ||
unlet s:keepcpo | ||
|
||
" vim: ts=8 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.