]> git.r.bdr.sh - rbdr/dotfiles/blame - vim/syntax/markdown.vim
Update vim plugins
[rbdr/dotfiles] / vim / syntax / markdown.vim
CommitLineData
0d23b6e5
BB
1" Vim syntax file
2" Language: Markdown
3" Maintainer: Tim Pope <vimNOSPAM@tpope.org>
4" Filenames: *.markdown
5
6if exists("b:current_syntax")
7 finish
8endif
9
10runtime! syntax/html.vim
11unlet! b:current_syntax
12
13syn sync minlines=10
14syn case ignore
15
16syn match markdownValid '[<>]\S\@!'
17syn match markdownValid '&\%(#\=\w*;\)\@!'
18
19syn match markdownLineStart "^[<@]\@!" nextgroup=@markdownBlock
20
21syn cluster markdownBlock contains=markdownH1,markdownH2,markdownH3,markdownH4,markdownH5,markdownH6,markdownBlockquote,markdownListMarker,markdownOrderedListMarker,markdownCodeBlock,markdownRule
22syn cluster markdownInline contains=markdownLineBreak,markdownLinkText,markdownItalic,markdownBold,markdownCode,markdownEscape,@htmlTop
23
24syn match markdownH1 ".\+\n=\+$" contained contains=@markdownInline,markdownHeadingRule
25syn match markdownH2 ".\+\n-\+$" contained contains=@markdownInline,markdownHeadingRule
26
27syn match markdownHeadingRule "^[=-]\+$" contained
28
29syn region markdownH1 matchgroup=markdownHeadingDelimiter start="##\@!" end="#*\s*$" keepend oneline contains=@markdownInline contained
30syn region markdownH2 matchgroup=markdownHeadingDelimiter start="###\@!" end="#*\s*$" keepend oneline contains=@markdownInline contained
31syn region markdownH3 matchgroup=markdownHeadingDelimiter start="####\@!" end="#*\s*$" keepend oneline contains=@markdownInline contained
32syn region markdownH4 matchgroup=markdownHeadingDelimiter start="#####\@!" end="#*\s*$" keepend oneline contains=@markdownInline contained
33syn region markdownH5 matchgroup=markdownHeadingDelimiter start="######\@!" end="#*\s*$" keepend oneline contains=@markdownInline contained
34syn region markdownH6 matchgroup=markdownHeadingDelimiter start="#######\@!" end="#*\s*$" keepend oneline contains=@markdownInline contained
35
36syn match markdownBlockquote ">\s" contained nextgroup=@markdownBlock
37
38syn region markdownCodeBlock start=" \|\t" end="$" contained
39
40" TODO: real nesting
41syn match markdownListMarker " \{0,4\}[-*+]\%(\s\+\S\)\@=" contained
42syn match markdownOrderedListMarker " \{0,4}\<\d\+\.\%(\s*\S\)\@=" contained
43
44syn match markdownRule "\* *\* *\*[ *]*$" contained
45syn match markdownRule "- *- *-[ -]*$" contained
46
47syn match markdownLineBreak "\s\{2,\}$"
48
49syn region markdownIdDeclaration matchgroup=markdownLinkDelimiter start="^ \{0,3\}!\=\[" end="\]:" oneline keepend nextgroup=markdownUrl skipwhite
50syn match markdownUrl "\S\+" nextgroup=markdownUrlTitle skipwhite contained
51syn region markdownUrl matchgroup=markdownUrlDelimiter start="<" end=">" oneline keepend nextgroup=markdownUrlTitle skipwhite contained
52syn region markdownUrlTitle matchgroup=markdownUrlTitleDelimiter start=+"+ end=+"+ keepend contained
53syn region markdownUrlTitle matchgroup=markdownUrlTitleDelimiter start=+'+ end=+'+ keepend contained
54syn region markdownUrlTitle matchgroup=markdownUrlTitleDelimiter start=+(+ end=+)+ keepend contained
55
56syn region markdownLinkText matchgroup=markdownLinkTextDelimiter start="!\=\[\%(\_[^]]*]\%( \=[[(]\)\)\@=" end="\]\%( \=[[(]\)\@=" keepend nextgroup=markdownLink,markdownId skipwhite contains=@markdownInline,markdownLineStart
57syn region markdownLink matchgroup=markdownLinkDelimiter start="(" end=")" contains=markdownUrl keepend contained
58syn region markdownId matchgroup=markdownIdDelimiter start="\[" end="\]" keepend contained
59syn region markdownAutomaticLink matchgroup=markdownUrlDelimiter start="<\%(\w\+:\|[[:alnum:]_+-]\+@\)\@=" end=">" keepend oneline
60
61syn region markdownItalic start="\S\@<=\*\|\*\S\@=" end="\S\@<=\*\|\*\S\@=" keepend contains=markdownLineStart
62syn region markdownItalic start="\S\@<=_\|_\S\@=" end="\S\@<=_\|_\S\@=" keepend contains=markdownLineStart
63syn region markdownBold start="\S\@<=\*\*\|\*\*\S\@=" end="\S\@<=\*\*\|\*\*\S\@=" keepend contains=markdownLineStart
64syn region markdownBold start="\S\@<=__\|__\S\@=" end="\S\@<=__\|__\S\@=" keepend contains=markdownLineStart
65syn region markdownBoldItalic start="\S\@<=\*\*\*\|\*\*\*\S\@=" end="\S\@<=\*\*\*\|\*\*\*\S\@=" keepend contains=markdownLineStart
66syn region markdownBoldItalic start="\S\@<=___\|___\S\@=" end="\S\@<=___\|___\S\@=" keepend contains=markdownLineStart
67syn region markdownCode matchgroup=markdownCodeDelimiter start="`" end="`" keepend contains=markdownLineStart
68syn region markdownCode matchgroup=markdownCodeDelimiter start="`` \=" end=" \=``" keepend contains=markdownLineStart
69syn region markdownCode matchgroup=markdownCodeDelimiter start="^\s*\zs```\s*\w*\ze\s*$" end="^```\ze\s*$" keepend
70
71syn match markdownEscape "\\[][\\`*_{}()#+.!-]"
72syn match markdownError "\w\@<=_\w\@="
73
74hi def link markdownH1 htmlH1
75hi def link markdownH2 htmlH2
76hi def link markdownH3 htmlH3
77hi def link markdownH4 htmlH4
78hi def link markdownH5 htmlH5
79hi def link markdownH6 htmlH6
80hi def link markdownHeadingRule markdownRule
81hi def link markdownHeadingDelimiter Delimiter
82hi def link markdownOrderedListMarker markdownListMarker
83hi def link markdownListMarker htmlTagName
84hi def link markdownBlockquote Comment
85hi def link markdownRule PreProc
86
87hi def link markdownLinkText htmlLink
88hi def link markdownIdDeclaration Typedef
89hi def link markdownId Type
90hi def link markdownAutomaticLink markdownUrl
91hi def link markdownUrl Float
92hi def link markdownUrlTitle String
93hi def link markdownIdDelimiter markdownLinkDelimiter
94hi def link markdownUrlDelimiter htmlTag
95hi def link markdownUrlTitleDelimiter Delimiter
96
97hi def link markdownItalic htmlItalic
98hi def link markdownBold htmlBold
99hi def link markdownBoldItalic htmlBoldItalic
100hi def link markdownCodeDelimiter Delimiter
101
102hi def link markdownEscape Special
103hi def link markdownError Error
104
105let b:current_syntax = "markdown"
106
107" vim:set sw=2: