113 lines
4.7 KiB
VimL
113 lines
4.7 KiB
VimL
" Vim syntax file
|
|
" Language: Markdown
|
|
" Maintainer: urosm <urosm@kompot.si>
|
|
" Last Change: 2024 Feb 14
|
|
|
|
if exists("b:current_syntax")
|
|
finish
|
|
endif
|
|
|
|
syntax spell toplevel
|
|
|
|
" emphasis
|
|
syn region markdownItalic matchgroup=markdownDelimiter start=/\\\@1<!\(\_^\|\s\|[[:punct:]]\)\@<=\*\S\@=/ skip=/\(\*\*\|__\)/ end=/\*\([[:punct:]]\|\s\|\_$\)\@=/ contains=@Spell
|
|
syn region markdownItalic matchgroup=markdownDelimiter start=/\\\@1<!\(\_^\|\s\|[[:punct:]]\)\@<=_\S\@=/ skip=/\(\*\*\|__\)/ end=/\S\@1<=_\([[:punct:]]\|\s\|\_$\)\@=/ contains=@Spell
|
|
|
|
" bold
|
|
syn region markdownBold matchgroup=markdownDelimiter start=/\(\\\@<!\*\)\{2}/ end=/\(\\\@<!\*\)\{2}/ contains=@Spell
|
|
syn region markdownBold matchgroup=markdownDelimiter start=/__/ end=/__/ contains=@Spell
|
|
|
|
" bold italic
|
|
syn region markdownBoldItalic matchgroup=markdownDelimiter start=/\*\{3}\(\S[^*]*\(\*\S\|\n[^*]*\*\S\)\)\@=/ end=/\S\@<=\*\{3}/ contains=@Spell
|
|
syn region markdownBoldItalic matchgroup=markdownDelimiter start=/\(___\)\S\@=/ end=/\S\@<=___/ contains=@Spell
|
|
|
|
syn region markdownBoldInItalic matchgroup=markdownDelimiter start=/\*\*/ end=/\*\*/ contained containedin=markdownItalic contains=@Spell
|
|
syn region markdownBoldInItalic matchgroup=markdownDelimiter start=/__/ end=/__/ contained containedin=markdownItalic contains=@Spell
|
|
hi def link markdownBoldInItalic markdownBoldItalic
|
|
|
|
syn region markdownItalicInBold matchgroup=markdownDelimiter start=/\\\@1<!\(\_^\|\s\|[[:punct:]]\)\@<=\*\S\@=/ skip=/\(\*\*\|__\)/ end=/\S\@<=\*\([[:punct:]]\|\s\|\_$\)\@=/ contained containedin=markdownBold contains=@Spell
|
|
syn region markdownItalicInBold matchgroup=markdownDelimiter start=/\\\@<!\(\_^\|\s\|[[:punct:]]\)\@<=_\S\@=/ skip=/\(\*\*\|__\)/ end=/\S\@<=_\([[:punct:]]\|\s\|\_$\)\@=/ contained containedin=markdownBold contains=@Spell
|
|
hi def link markdownItalicInBold markdownBoldItalic
|
|
|
|
" link
|
|
syn match markdownLink /!\=\[\_.\{-}\](\_.\{-})/ contains=markdownLinkLabel,markdownLinkURL
|
|
syn match markdownLinkLabel /\[\zs.*\ze\]/ contained
|
|
hi def link markdownLinkLabel markdownLabel
|
|
syn match markdownLinkURL /.*(\zs.*\ze)/ contained
|
|
hi def link markdownLinkURL markdownUnderlined
|
|
|
|
" automatic link
|
|
syn match markdownAutomaticLink /<\(https\{0,1}.\{-}\|[A-Za-z0-9!#$%&'*+\-/=?^_`{|}~.]\{-}@[A-Za-z0-9\-]\{-}\.\w\{-}\)>/
|
|
hi def link markdownAutomaticLink markdownUnderlined
|
|
|
|
" wikilink
|
|
" NOTE: update to support newlines in titles
|
|
syn match markdownWikilink /\[\[.*\]\]/ contains=markdownWikilinkLabel,markdownWikilinkURL
|
|
syn match markdownWikilinkLabel /\[\[\zs.\{-}\ze|.*\]\]/ contained
|
|
hi def link markdownWikilinkLabel markdownLabel
|
|
syn match markdownWikilinkURL /\%(\[\[\||\)\zs[^|]*\ze\]\]/ contained
|
|
hi def link markdownWikilinkURL markdownUnderlined
|
|
|
|
" footnote reference
|
|
syn match markdownFootnoteReference /\[\zs\^.\{-}\ze\]/
|
|
hi def link markdownFootnoteReference markdownLabel
|
|
|
|
" reference key
|
|
syn match markdownReferenceKey /@[[:alnum:]_][[:digit:][:lower:][:upper:]_:.#$%&-+?<>~\/]*/
|
|
hi def link markdownReferenceKey markdownLabel
|
|
|
|
" html comment
|
|
syn region markdownHTMLcomment start=/<!--/ end=/-->/ keepend contains=@Spell
|
|
hi def link markdownHTMLcomment markdownComment
|
|
|
|
" yaml
|
|
syn include @YAML syntax/yaml.vim
|
|
unlet! b:current_syntax
|
|
syn region markdownYAMLHeader start=/\%(\%^\|\_^\s*\n\)\@<=\_^-\{3}\ze\n.\+/ end=/^\([-.]\)\1\{2}$/ keepend contains=@YAML containedin=TOP
|
|
|
|
" styling
|
|
hi def link markdownComment Comment
|
|
hi def link markdownConstant Constant
|
|
hi def link markdownString String
|
|
hi def link markdownCharacter Character
|
|
hi def link markdownNumber Number
|
|
hi def link markdownBoolean Boolean
|
|
hi def link markdownFloat Float
|
|
hi def link markdownIdentifier Identifier
|
|
hi def link markdownFunction Function
|
|
hi def link markdownStatement Statement
|
|
hi def link markdownConditional Conditional
|
|
hi def link markdownRepeat Repeat
|
|
hi def link markdownLabel Label
|
|
hi def link markdownOperator Operator
|
|
hi def link markdownKeyword Keyword
|
|
hi def link markdownException Exception
|
|
hi def link markdownPreProc PreProc
|
|
hi def link markdownInclude Include
|
|
hi def link markdownDefine Define
|
|
hi def link markdownMacro Macro
|
|
hi def link markdownPreCondit PreCondit
|
|
hi def link markdownType Type
|
|
hi def link markdownStorageClass StorageClass
|
|
hi def link markdownStructure Structure
|
|
hi def link markdownTypedef Typedef
|
|
hi def link markdownSpecial Special
|
|
hi def link markdownSpecialChar SpecialChar
|
|
hi def link markdownTag Tag
|
|
hi def link markdownDelimiter Delimiter
|
|
hi def link markdownSpecialComment SpecialComment
|
|
hi def link markdownDebug Debug
|
|
hi def link markdownUnderlined Underlined
|
|
hi def link markdownIgnore Ignore
|
|
hi def link markdownError Error
|
|
|
|
hi def link markdownItalic Italic
|
|
hi def link markdownBold Bold
|
|
hi def link markdownBoldItalic BoldItalic
|
|
hi def link markdownStrike Strike
|
|
hi def link markdownTitle Title
|
|
|
|
let b:current_syntax = "markdown"
|
|
|
|
" vim:set sw=2:
|